mitre / caldera

Automated Adversary Emulation Platform
https://caldera.mitre.org
Apache License 2.0
5.5k stars 1.05k forks source link

ERROR: Failed building wheel for donut-shellcode #2857

Closed cventour closed 5 months ago

cventour commented 8 months ago

Describe the bug Following the instructions to build caldera locally or in a container, I am getting an error while the requirements.txt packages are deployed. More specifically the error is

ERROR: Failed building wheel for donut-shellcode Failed to build donut-shellcode ERROR: Could not build wheels for donut-shellcode, which is required to install pyproject.toml-based projects

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/mitre/caldera.git --recursive
  2. pip3 install -r requirements.txt

Expected behavior Deployment of prerequisites should be succesul.

Screenshots ERROR MESSAGE IN DETAIL

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.0/120.0 kB 11.5 MB/s eta 0:00:00 Downloading sphinxcontrib_devhelp-1.0.5-py3-none-any.whl (83 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.5/83.5 kB 5.9 MB/s eta 0:00:00 Downloading sphinxcontrib_qthelp-1.0.6-py3-none-any.whl (89 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.4/89.4 kB 7.6 MB/s eta 0:00:00 Downloading certifi-2023.11.17-py3-none-any.whl (162 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.5/162.5 kB 14.9 MB/s eta 0:00:00 Downloading idna-3.6-py3-none-any.whl (61 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.6/61.6 kB 5.3 MB/s eta 0:00:00 Downloading pathspec-0.12.1-py3-none-any.whl (31 kB) Downloading urllib3-2.1.0-py3-none-any.whl (104 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.6/104.6 kB 8.8 MB/s eta 0:00:00 Building wheels for collected packages: aiohttp-apispec, donut-shellcode, svglib, scantree Building wheel for aiohttp-apispec (pyproject.toml) ... done Created wheel for aiohttp-apispec: filename=aiohttp_apispec-2.2.3-py3-none-any.whl size=2672621 sha256=a18cd223583685540d7d6f1b5eba0ef57e35389a5d78aaf55a473796b4c24119 Stored in directory: /Users/cventour/Library/Caches/pip/wheels/0c/6f/96/fb5a6f3849333cc9bafd0049b57c2efe59c0ba016de7b370ca Building wheel for donut-shellcode (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for donut-shellcode (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [130 lines of output] running bdist_wheel running build running build_ext building 'donut' extension creating build creating build/temp.macosx-14-arm64-cpython-311 creating build/temp.macosx-14-arm64-cpython-311/loader clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Iinclude -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c donut.c -o build/temp.macosx-14-arm64-cpython-311/donut.o In file included from donut.c:32: In file included from include/donut.h:66: include/pe.h:14:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]

include "pshpack4.h" // 4 byte packing is the default

           ^
  include/pshpack4.h:31:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack(4)
          ^
  In file included from donut.c:32:
  In file included from include/donut.h:66:
  include/pe.h:22:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "pshpack2.h"                   // 16 bit headers are 2 byte packed
           ^
  include/pshpack2.h:31:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack(2)
          ^
  In file included from donut.c:32:
  In file included from include/donut.h:66:
  include/pe.h:57:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "poppack.h"                    // Back to 4 byte packing
           ^
  include/poppack.h:34:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack()
          ^
  donut.c:574:19: warning: comparison of integers of different signs: 'ULONG64' (aka 'unsigned long long') and 'int' [-Wsign-compare]
            if (ofs != -1) {
                ~~~ ^  ~~
  donut.c:579:22: warning: comparison of integers of different signs: 'ULONG64' (aka 'unsigned long long') and 'int' [-Wsign-compare]
                if(ofs != -1) {
                   ~~~ ^  ~~
  donut.c:667:15: warning: comparison of integers of different signs: 'int' and 'uint64_t' (aka 'unsigned long long') [-Wsign-compare]
      for(i=0; i<len; i++) {
               ~^~~~
  donut.c:983:7: warning: 'strcpy' will always overflow; destination buffer has size 1, but the source string has length 2 (including NUL byte) [-Wfortify-source]
        strcpy(inst->etwRet64, "\xc3");
        ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/secure/_string.h:84:3: note: expanded from macro 'strcpy'
                  __builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                  ^
  donut.c:1481:16: warning: comparison of integers of different signs: 'ULONG64' (aka 'unsigned long long') and 'int' [-Wsign-compare]
          if(ofs != -1) {
             ~~~ ^  ~~
  8 warnings generated.
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Iinclude -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c donutmodule.c -o build/temp.macosx-14-arm64-cpython-311/donutmodule.o
  In file included from donutmodule.c:36:
  In file included from include/donut.h:66:
  include/pe.h:14:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "pshpack4.h"                   // 4 byte packing is the default
           ^
  include/pshpack4.h:31:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack(4)
          ^
  In file included from donutmodule.c:36:
  In file included from include/donut.h:66:
  include/pe.h:22:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "pshpack2.h"                   // 16 bit headers are 2 byte packed
           ^
  include/pshpack2.h:31:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack(2)
          ^
  In file included from donutmodule.c:36:
  In file included from include/donut.h:66:
  include/pe.h:57:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "poppack.h"                    // Back to 4 byte packing
           ^
  include/poppack.h:34:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack()
          ^
  donutmodule.c:199:9: warning: incompatible function pointer types initializing 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') with an expression of type 'PyObject *(PyObject *, PyObject *, PyObject *)' (aka 'struct _object *(struct _object *, struct _object *, struct _object *)') [-Wincompatible-function-pointer-types]
          Donut_Create, // C wrapper function
          ^~~~~~~~~~~~
  4 warnings generated.
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Iinclude -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c encrypt.c -o build/temp.macosx-14-arm64-cpython-311/encrypt.o
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Iinclude -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c format.c -o build/temp.macosx-14-arm64-cpython-311/format.o
  In file included from format.c:32:
  In file included from include/format.h:35:
  In file included from include/donut.h:66:
  include/pe.h:14:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "pshpack4.h"                   // 4 byte packing is the default
           ^
  include/pshpack4.h:31:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack(4)
          ^
  In file included from format.c:32:
  In file included from include/format.h:35:
  In file included from include/donut.h:66:
  include/pe.h:22:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "pshpack2.h"                   // 16 bit headers are 2 byte packed
           ^
  include/pshpack2.h:31:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack(2)
          ^
  In file included from format.c:32:
  In file included from include/format.h:35:
  In file included from include/donut.h:66:
  include/pe.h:57:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
  #include "poppack.h"                    // Back to 4 byte packing
           ^
  include/poppack.h:34:9: note: previous '#pragma pack' directive that modifies alignment is here
  #pragma pack()
          ^
  format.c:107:8: warning: variable 'base64' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
      if(b64_encode(NULL, pic_len, NULL, &outlen)) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  format.c:145:10: note: uninitialized use occurs here
      free(base64);
           ^~~~~~
  format.c:107:5: note: remove the 'if' if its condition is always true
      if(b64_encode(NULL, pic_len, NULL, &outlen)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  format.c:104:21: note: initialize the variable 'base64' to silence this warning
      void     *base64;
                      ^
                       = NULL
  4 warnings generated.
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Iinclude -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c hash.c -o build/temp.macosx-14-arm64-cpython-311/hash.o
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Iinclude -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c loader/clib.c -o build/temp.macosx-14-arm64-cpython-311/loader/clib.o
  creating build/lib.macosx-14-arm64-cpython-311
  clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk build/temp.macosx-14-arm64-cpython-311/donut.o build/temp.macosx-14-arm64-cpython-311/donutmodule.o build/temp.macosx-14-arm64-cpython-311/encrypt.o build/temp.macosx-14-arm64-cpython-311/format.o build/temp.macosx-14-arm64-cpython-311/hash.o build/temp.macosx-14-arm64-cpython-311/loader/clib.o lib/aplib64.a -Llib -o build/lib.macosx-14-arm64-cpython-311/donut.cpython-311-darwin.so
  ld: archive member '/' not a mach-o file in '/private/var/folders/zt/kwgqdzms6sx7kd1_49y1b_yw0000gn/T/pip-install-2dj_drq8/donut-shellcode_528943409bef42c090599324be0e70c5/lib/aplib64.a'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command '/usr/bin/clang' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for donut-shellcode Building wheel for svglib (setup.py) ... done Created wheel for svglib: filename=svglib-1.5.1-py3-none-any.whl size=30903 sha256=0ef7d20df90be99c6476ee6f6bf289fda482e372bfc801d3df454defdfb5a926 Stored in directory: /Users/cventour/Library/Caches/pip/wheels/7e/01/0e/e6e336915d6e8448890a695770ba88fe030cc71060988016f6 Building wheel for scantree (setup.py) ... done Created wheel for scantree: filename=scantree-0.0.1-py3-none-any.whl size=14399 sha256=6792ed9b5ee5925aeadc4617d31ed8a2483b4d00ebbc389af337cfa74bd814ad Stored in directory: /Users/cventour/Library/Caches/pip/wheels/b7/e4/26/d20dc7412cb3cec815e872d4698fb23f8beb8ff767307d935d Successfully built aiohttp-apispec svglib scantree Failed to build donut-shellcode ERROR: Could not build wheels for donut-shellcode, which is required to install pyproject.toml-based projects


Desktop (please complete the following information):

Additional context Add any other context about the problem here.

jmayer93 commented 8 months ago

Same ^

sad-af777 commented 8 months ago

I had ran into the same issue in RHEL 8.0 and for me the fix was python-devel package e.g., yum install python38-devel then ran the requirement.txt. Hope this helps

elegantmoose commented 7 months ago

Looking into now.

Christopherhausner commented 7 months ago

Same issue anyone solve it?

cventour commented 7 months ago

After researching it seems the donut package does not support ARM CPUs, hence it is not building on a Mac with M series chipset.

As a workaround you can remove donut from the requirements and try to install again.

In my use case, removing donut from the requirements did not have any impact on how I use caldera which is just chaining and automating some activities

Christopherhausner commented 7 months ago

After researching it seems the donut package does not support ARM CPUs, hence it is not building on a Mac with M series chipset.

As a workaround you can remove donut from the requirements and try to install again.

In my use case, removing donut from the requirements did not have any impact on how I use caldera which is just chaining and automating some activities

How would you remove donut from the requirements?

elegantmoose commented 7 months ago

Apologies for delayed response.

See https://github.com/mitre/caldera/issues/2873#issuecomment-1939483235.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days