BC-SECURITY / Empire

Empire is a post-exploitation and adversary emulation framework that is used to aid Red Teams and Penetration Testers.
https://bc-security.gitbook.io/empire-wiki/
BSD 3-Clause "New" or "Revised" License
4.26k stars 580 forks source link

[BUG] Fail to build on Python 3.12 #752

Open D3vil0p3r opened 3 weeks ago

D3vil0p3r commented 3 weeks ago

Is there an existing issue for this?

Empire Version

5.11.5

Python Version

3.12

Operating System

Arch Linux

Database

MySQL

Current Behavior

When I build Empire from source, during the building, I get the following error:

  gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/tmp/makepkg/powershell-empire/src=/usr/src/debug/powershell-empire -flto=auto -fPIC -Iinclude -I/tmp/tmpckfgzqgz/.venv/include -I/usr/include/python3.12 -c donutmodule.c -o build/temp.linux-x86_64-cpython-312/donutmodule.o
  donutmodule.c:199:9: error: initialization of ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} from incompatible pointer type ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} [-Wincompatible-pointer-types]
    199 |         Donut_Create, // C wrapper function
        |         ^~~~~~~~~~~~
  donutmodule.c:199:9: note: (near initialization for ‘Donut_FunctionsTable[0].ml_meth’)
  error: command '/usr/bin/gcc' failed with exit code 1

This could be related to https://github.com/TheWover/donut/pull/158

Expected Behavior

Building and installing correctly.

Steps To Reproduce

poetry config --local virtualenvs.in-project true
poetry config --local virtualenvs.prefer-active-python true
poetry install --no-root --compile

Anything else?

No response

D3vil0p3r commented 3 weeks ago

@vinnybod can you please update donut-shellcode in pyproject.toml to 1.1?

DevinCarpenter commented 1 week ago

@D3vil0p3r Agreed. Needs to be updated. I ran into the same issue with the version of donut-shellcode currently used. I posted my notes for an easy fix.

Ran into issue installing donut-shellcode
- Installing donut-shellcode (1.0.2): Failed
ChefBuildError
Backend subprocess exited when trying to invoke build_wheel
Need to change the donut version required to be 1.1 in the pyproject.toml. pyproject.toml is located in the root empire directory
# Change this line
donut-shellcode = { version = "^1.0.2", markers = "platform_machine == 'x86_64' or platform_machine == 'amd64'" }
# To this line
donut-shellcode = { version = "^1.1", markers = "platform_machine == 'x86_64' or platform_machine == 'amd64'" }
We will get another error if we run the install script:
pyproject.toml changed significantly since poetry.lock was last generated. Run `poetry lock [--no-update]` to fix the lock file.
This can be fixed by generating the poetry lock file again
poetry lock
now re-run the install script. Success.
./ps-empire install -y
vinnybod commented 1 week ago

Updated donut in 5.11.6

D3vil0p3r commented 1 week ago

@DevinCarpenter can you confirm everything works correctly now?