TheWover / donut

Generates x86, x64, or AMD64+x86 position-independent shellcode that loads .NET Assemblies, PE files, and other Windows payloads from memory and runs them with parameters
BSD 3-Clause "New" or "Revised" License
3.53k stars 628 forks source link

donut-shell code installation issue #57

Closed Michealpool closed 4 years ago

Michealpool commented 4 years ago

i am getting while running this command. pip3 install donut-shellcode OS: Ubuntu 16.0.4 python version:3.6.10

==================================================================== Using cached donut-shellcode-0.9.2.tar.gz (149 kB) Building wheels for collected packages: donut-shellcode Building wheel for donut-shellcode (setup.py) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3xopcy2r/donut-shellcode/setup.py'"'"'; file='"'"'/tmp/pip-install-3xopcy2r/donut-shellcode/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-h11qdgs6 cwd: /tmp/pip-install-3xopcy2r/donut-shellcode/ Complete output (19 lines): /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) running bdist_wheel running build running build_ext building 'donut' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/payload x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donut.c -o build/temp.linux-x86_64-3.6/donut.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c hash.c -o build/temp.linux-x86_64-3.6/hash.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c encrypt.c -o build/temp.linux-x86_64-3.6/encrypt.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c payload/clib.c -o build/temp.linux-x86_64-3.6/payload/clib.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donutmodule.c -o build/temp.linux-x86_64-3.6/donutmodule.o donutmodule.c:34:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Failed building wheel for donut-shellcode Running setup.py clean for donut-shellcode Failed to build donut-shellcode Installing collected packages: donut-shellcode Running setup.py install for donut-shellcode ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3xopcy2r/donut-shellcode/setup.py'"'"'; file='"'"'/tmp/pip-install-3xopcy2r/donut-shellcode/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-gz8vjj14/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/donut-shellcode cwd: /tmp/pip-install-3xopcy2r/donut-shellcode/ Complete output (19 lines): /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) running install running build running build_ext building 'donut' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/payload x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donut.c -o build/temp.linux-x86_64-3.6/donut.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c hash.c -o build/temp.linux-x86_64-3.6/hash.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c encrypt.c -o build/temp.linux-x86_64-3.6/encrypt.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c payload/clib.c -o build/temp.linux-x86_64-3.6/payload/clib.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donutmodule.c -o build/temp.linux-x86_64-3.6/donutmodule.o donutmodule.c:34:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Command errored out with exit status

Flangvik commented 4 years ago

To fix this, clone the repo, edit the first line of setup.py from this

from setuptools import Extension, setup, sys

To this

from setuptools import Extension, setup import sys

Then, do

pip3 uninstall donut-shellcode pip3 install . pip3 freeze | grep donut-shellcode

Michealpool commented 4 years ago

Thank you Flangvik for your response. the said changes has been applied in donut setup.py file. i am still getting this error.

root@test-virtual-machine:~/donut# pip3 install . Processing /root/caldera/donut Building wheels for collected packages: donut-shellcode Building wheel for donut-shellcode (setup.py) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-x2zk24ek/setup.py'"'"'; file='"'"'/tmp/pip-req-build-x2zk24ek/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-kkzj1j05 cwd: /tmp/pip-req-build-x2zk24ek/ Complete output (20 lines): running bdist_wheel running build running build_ext building 'donut' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/loader x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donut.c -o build/temp.linux-x86_64-3.6/donut.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c hash.c -o build/temp.linux-x86_64-3.6/hash.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c encrypt.c -o build/temp.linux-x86_64-3.6/encrypt.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c format.c -o build/temp.linux-x86_64-3.6/format.o format.c: In function ‘base64_template’: format.c:58:14: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized] uint32_t i, len, x; ^ x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c loader/clib.c -o build/temp.linux-x86_64-3.6/loader/clib.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donutmodule.c -o build/temp.linux-x86_64-3.6/donutmodule.o donutmodule.c:34:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Failed building wheel for donut-shellcode

Flangvik commented 4 years ago

Based on the error response it still seems you have not applied the changes correctly, import sys is suppose to be on a separate line below

Michealpool commented 4 years ago

Thank you for your response. the said the changes has been applied, now i am getting below error.

=================================================================

ERROR: Command errored out with exit status 1: command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-eu0etpb5/setup.py'"'"'; file='"'"'/tmp/pip-req-build-eu0etpb5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-dvr7pi5t cwd: /tmp/pip-req-build-eu0etpb5/ Complete output (6 lines): Traceback (most recent call last): File "", line 1, in File "/tmp/pip-req-build-eu0etpb5/setup.py", line 1 from setuptools import Extension, setup, ^ SyntaxError: trailing comma not allowed without surrounding parentheses

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Flangvik commented 4 years ago

"trailing comma not allowed without surrounding parentheses" You have an extra "," after "setup," that needs to be removed. from from setuptools import Extension, setup, to from setuptools import Extension, setup

Michealpool commented 4 years ago

Thank your for your quick response.changes applied as suggested, but still getting the error.

from setuptools import Extension, setup import sys

======================================================================= pip3 install . Processing /root/caldera/donut Building wheels for collected packages: donut-shellcode Building wheel for donut-shellcode (setup.py) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-p8dj85ur/setup.py'"'"'; file='"'"'/tmp/pip-req-build-p8dj85ur/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-23ee5oph cwd: /tmp/pip-req-build-p8dj85ur/ Complete output (20 lines): running bdist_wheel running build running build_ext building 'donut' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/loader x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donut.c -o build/temp.linux-x86_64-3.6/donut.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c hash.c -o build/temp.linux-x86_64-3.6/hash.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c encrypt.c -o build/temp.linux-x86_64-3.6/encrypt.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c format.c -o build/temp.linux-x86_64-3.6/format.o format.c: In function ‘base64_template’: format.c:58:14: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized] uint32_t i, len, x; ^ x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c loader/clib.c -o build/temp.linux-x86_64-3.6/loader/clib.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donutmodule.c -o build/temp.linux-x86_64-3.6/donutmodule.o donutmodule.c:34:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Failed building wheel for donut-shellcode Running setup.py clean for donut-shellcode Failed to build donut-shellcode Installing collected packages: donut-shellcode Running setup.py install for donut-shellcode ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-p8dj85ur/setup.py'"'"'; file='"'"'/tmp/pip-req-build-p8dj85ur/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-e_b50h7m/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/donut-shellcode cwd: /tmp/pip-req-build-p8dj85ur/ Complete output (20 lines): running install running build running build_ext building 'donut' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/loader x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donut.c -o build/temp.linux-x86_64-3.6/donut.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c hash.c -o build/temp.linux-x86_64-3.6/hash.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c encrypt.c -o build/temp.linux-x86_64-3.6/encrypt.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c format.c -o build/temp.linux-x86_64-3.6/format.o format.c: In function ‘base64_template’: format.c:58:14: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized] uint32_t i, len, x; ^ x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c loader/clib.c -o build/temp.linux-x86_64-3.6/loader/clib.o x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -I/usr/include/python3.6m -c donutmodule.c -o build/temp.linux-x86_64-3.6/donutmodule.o donutmodule.c:34:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-p8dj85ur/setup.py'"'"'; file='"'"'/tmp/pip-req-build-p8dj85ur/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-e_b50h7m/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/donut-shellcode Check the logs for full command output.

Michealpool commented 4 years ago

Hello Flangvik,

The issue has been resolved by upgrading python-Dev enviorment. It was set to python-Dev3.5 while the package required python3.6-dev.