Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MinGW debug builds #690

Open
cdelafuente-r7 opened this issue Dec 15, 2023 · 0 comments
Open

Add support for MinGW debug builds #690

cdelafuente-r7 opened this issue Dec 15, 2023 · 0 comments

Comments

@cdelafuente-r7
Copy link
Contributor

The Makefile used to compile Meterpreter with MinGW has no support to Debug builds. This can be achieved by passing some flags to cmake.

  • CMAKE_BUILD_TYPE
COMMON_GEN=-Wno-dev -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_BUILD_TYPE=Debug

However, doing so will break the build:

...
[ 97%] Building C object ext_server_kiwi/CMakeFiles/ext_server_kiwi.dir/meterpreter/source/extensions/kiwi/mimikatz/modules/sqlite3.c.obj
[ 97%] Linking C shared library ext_server_kiwi.x86.dll
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/ext_server_kiwi.dir/objects.a(kuhl_m_crypto_pki.c.obj): in function `kuhl_m_crypto_c_sc_auth':
/meterpreter/source/extensions/kiwi/mimikatz/mimikatz/modules/crypto/kuhl_m_crypto_pki.c:641: undefined reference to `kuhl_m_crypto_c_sc_auth_Ext_Free'
/usr/bin/i686-w64-mingw32-ld: /meterpreter/source/extensions/kiwi/mimikatz/mimikatz/modules/crypto/kuhl_m_crypto_pki.c:642: undefined reference to `kuhl_m_crypto_c_sc_auth_Ext_Free'
/usr/bin/i686-w64-mingw32-ld: /meterpreter/source/extensions/kiwi/mimikatz/mimikatz/modules/crypto/kuhl_m_crypto_pki.c:645: undefined reference to `kuhl_m_crypto_c_sc_auth_Ext_Free'
collect2: error: ld returned 1 exit status
make[3]: *** [ext_server_kiwi/CMakeFiles/ext_server_kiwi.dir/build.make:1907: ext_server_kiwi/ext_server_kiwi.x86.dll] Error 1
make[3]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make[2]: *** [CMakeFiles/Makefile2:664: ext_server_kiwi/CMakeFiles/ext_server_kiwi.dir/all] Error 2
make[2]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make[1]: *** [Makefile:84: all] Error 2
make[1]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make: *** [Makefile:29: meterpreter-x86-build] Error 2
make: *** [docker] Error 2
  • DBGTRACE
    COMMON_GEN=-Wno-dev -DUSE_STATIC_MSVC_RUNTIMES=ON -DDBGTRACE=ON

This will also break the build:

...
[ 26%] Linking C shared library metsrv.x86.dll
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(base.c.obj):base.c:(.text+0xdb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(base_dispatch.c.obj):base_dispatch.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(base_inject.c.obj):base_inject.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(channel.c.obj):channel.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(core.c.obj):core.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(metapi.c.obj):metapi.c:(.data+0x1d8): undefined reference to `get_logging_context'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(metapi.c.obj):metapi.c:(.data+0x1dc): undefined reference to `get_lock'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(metsrv.c.obj):metsrv.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(metsrv.c.obj):metsrv.c:(.text+0xe40): undefined reference to `init_logging'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(packet_encryption.c.obj):packet_encryption.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(pivot_packet_dispatch.c.obj):pivot_packet_dispatch.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(pivot_tree.c.obj):pivot_tree.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(remote.c.obj):remote.c:(.text+0xc8): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(remote_dispatch.c.obj):remote_dispatch.c:(.text+0xcb): undefined reference to `log_to_file'
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/metsrv.dir/objects.a(remote_thread.c.obj):remote_thread.c:(.text+0xcb): more undefined references to `log_to_file' follow
collect2: error: ld returned 1 exit status
make[3]: *** [metsrv/CMakeFiles/metsrv.dir/build.make:488: metsrv/metsrv.x86.dll] Error 1
make[3]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make[2]: *** [CMakeFiles/Makefile2:394: metsrv/CMakeFiles/metsrv.dir/all] Error 2
make[2]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make[1]: *** [Makefile:84: all] Error 2
make[1]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make: *** [Makefile:29: meterpreter-x86-build] Error 2
make: *** [docker] Error 2

The source/logging/logging.* source code seems to be missing.

  • DBGTRACE_VERBOSE
    COMMON_GEN=-Wno-dev -DUSE_STATIC_MSVC_RUNTIMES=ON -DDBGTRACE_VERBOSE=ON

This also breaks the builds the same way than with DBGTRACE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant