The Burp Suite User Forum was discontinued on the 1st November 2024.

Burp Suite User Forum

For support requests, go to the Support Center. To discuss with other Burp users, head to our Discord page.

SUPPORT CENTER DISCORD

Unable to import Crypto.Cipher module for python plugin

Elijah | Last updated: Sep 16, 2020 05:08AM UTC

Please refer to the following stack trace: Traceback (most recent call last): File "C:\Users\..\plugin.py", line 15, in <module> from Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5 File "C:\Python27\Lib\site-packages\Crypto\Cipher\__init__.py", line 27, in <module> from Crypto.Cipher._mode_ecb import _create_ecb_cipher File "C:\Python27\Lib\site-packages\Crypto\Cipher\_mode_ecb.py", line 29, in <module> from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, File "C:\Python27\Lib\site-packages\Crypto\Util\_raw_api.py", line 166, in <module> from ctypes import (CDLL, c_void_p, byref, c_ulong, c_ulonglong, c_size_t, ImportError: cannot import name create_string_buffer at org.python.core.Py.ImportError(Py.java:328) at org.python.core.imp.importFromAs(imp.java:1168) at org.python.core.imp.importFrom(imp.java:1132) at Crypto.Util._raw_api$py.f$0(C:\Python27\Lib\site-packages\Crypto\Util\_raw_api.py:321) at Crypto.Util._raw_api$py.call_function(C:\Python27\Lib\site-packages\Crypto\Util\_raw_api.py) at org.python.core.PyTableCode.call(PyTableCode.java:167) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:436) at org.python.core.imp.createFromPyClass(imp.java:236) at org.python.core.imp.createFromPyClass(imp.java:205) at org.python.core.imp.loadFromSource(imp.java:651) at org.python.core.imp.find_module(imp.java:543) at org.python.core.PyModule.impAttr(PyModule.java:106) at org.python.core.imp.import_next(imp.java:842) at org.python.core.imp.import_logic(imp.java:904) at org.python.core.imp.import_module_level(imp.java:978) at org.python.core.imp.importName(imp.java:1062) at org.python.core.ImportFunction.__call__(__builtin__.java:1280) at org.python.core.PyObject.__call__(PyObject.java:431) at org.python.core.__builtin__.__import__(__builtin__.java:1232) at org.python.core.imp.importFromAs(imp.java:1156) at org.python.core.imp.importFrom(imp.java:1132) at Crypto.Cipher._mode_ecb$py.f$0(C:\Python27\Lib\site-packages\Crypto\Cipher\_mode_ecb.py:204) at Crypto.Cipher._mode_ecb$py.call_function(C:\Python27\Lib\site-packages\Crypto\Cipher\_mode_ecb.py) at org.python.core.PyTableCode.call(PyTableCode.java:167) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:436) at org.python.core.imp.createFromPyClass(imp.java:236) at org.python.core.imp.createFromPyClass(imp.java:205) at org.python.core.imp.loadFromSource(imp.java:651) at org.python.core.imp.find_module(imp.java:543) at org.python.core.PyModule.impAttr(PyModule.java:106) at org.python.core.imp.import_next(imp.java:842) at org.python.core.imp.import_logic(imp.java:904) at org.python.core.imp.import_module_level(imp.java:978) at org.python.core.imp.importName(imp.java:1062) at org.python.core.ImportFunction.__call__(__builtin__.java:1280) at org.python.core.PyObject.__call__(PyObject.java:431) at org.python.core.__builtin__.__import__(__builtin__.java:1232) at org.python.core.imp.importFromAs(imp.java:1156) at org.python.core.imp.importFrom(imp.java:1132) at Crypto.Cipher$py.f$0(C:\Python27\Lib\site-packages\Crypto\Cipher\__init__.py:54) at Crypto.Cipher$py.call_function(C:\Python27\Lib\site-packages\Crypto\Cipher\__init__.py) at org.python.core.PyTableCode.call(PyTableCode.java:167) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:436) at org.python.core.imp.createFromPyClass(imp.java:236) at org.python.core.imp.createFromPyClass(imp.java:205) at org.python.core.imp.loadFromSource(imp.java:651) at org.python.core.imp.find_module(imp.java:543) at org.python.core.PyModule.impAttr(PyModule.java:106) at org.python.core.imp.import_next(imp.java:842) at org.python.core.imp.import_logic(imp.java:904) at org.python.core.imp.import_module_level(imp.java:978) at org.python.core.imp.importName(imp.java:1062) at org.python.core.ImportFunction.__call__(__builtin__.java:1280) at org.python.core.PyObject.__call__(PyObject.java:431) at org.python.core.__builtin__.__import__(__builtin__.java:1232) at org.python.core.imp.importFromAs(imp.java:1156) at org.python.core.imp.importFrom(imp.java:1132) at org.python.pycode._pyx5.f$0(C:\Users\..\plugin.py:23) at org.python.pycode._pyx5.call_function(C:\Users\..\plugin.py) at org.python.core.PyTableCode.call(PyTableCode.java:167) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1386) at org.python.core.__builtin__.execfile_flags(__builtin__.java:535) at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:286) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at burp.cbw.<init>(Unknown Source) at burp.b7f.a(Unknown Source) at burp.f96.lambda$panelLoaded$0(Unknown Source) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at java.base/java.lang.Thread.run(Thread.java:832)

Hannah, PortSwigger Agent | Last updated: Sep 16, 2020 09:16AM UTC

Is this an issue that you are having with a BApp extension, or is it one that you've developed yourself?

Elijah | Last updated: Sep 16, 2020 10:44AM UTC

Hi Hannah This is an issue I am having with an extension I developed myself. Please advise, thank you!

Stephen | Last updated: Sep 17, 2020 12:47AM UTC

Hi Elijah Jython wont load Python modules with native module components, such as Crypto. You will get the same result as above if you try and load this directly inside a Jython interpreter. I ran into the same issue previously and I used the Java crypto library Bouncy Castle instead to do crypto operations in a Python/Jython Burp extension.

Elijah | Last updated: Sep 18, 2020 06:09AM UTC