Skip to content

Commit b36fb1b

Browse files
committed
feat(c/sniffer): optional mingw flag to disable the reflective loader
1 parent 771df67 commit b36fb1b

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

c/meterpreter/source/extensions/sniffer/sniffer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ Command customCommands[] =
3535
// include the Reflectiveloader() function, we end up linking back to the metsrv.dll's Init function
3636
// but this doesnt matter as we wont ever call DLL_METASPLOIT_ATTACH as that is only used by the
3737
// second stage reflective dll inject payload and not the metsrv itself when it loads extensions.
38-
#define RDIDLL_NOEXPORT
39-
#include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"
38+
#ifndef NO_REFLECTIVE_LOADER
39+
#define RDIDLL_NOEXPORT
40+
#include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"
41+
#else
42+
HINSTANCE hAppInstance = NULL;
43+
#include "../../ReflectiveDLLInjection/dll/src/DirectSyscall.c"
44+
#endif
4045

4146
#define check_pssdk(); if(!hMgr && pktsdk_initialize()!=0){ met_api->packet.transmit_response(hErr, remote, response);return(hErr); }
4247

c/meterpreter/workspace/ext_server_sniffer/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ endif()
2525
set(SRC_DIR ../../source/extensions/sniffer)
2626
file(GLOB SRC_FILES
2727
${SRC_DIR}/*.c
28-
${MOD_DEF_DIR}/extension.def
28+
${EXTENSION_DEF_FILE}
2929
)
3030
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
3131
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
32-
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
33-
set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
32+
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${EXTENSION_DEF_FILE}\"")
33+
set_source_files_properties(${EXTENSION_DEF_FILE} PROPERTIES HEADER_FILE_ONLY TRUE)
3434

3535
set(PSSDK_LIB_DIR ${PSSDK_DIR}/PSSDK_VC${PSSDK_VER}_LIB/_Libs)
3636
if(IS_X64)
@@ -39,6 +39,10 @@ endif()
3939

4040
set(LINK_LIBS ${PSSDK_LIB_DIR}/pssdk_vc${PSSDK_VER}_mt.lib ws2_32)
4141
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS} ${MET_RDI_ASM})
42+
43+
if(EXCLUDE_REFLECTIVE_LOADER)
44+
target_compile_definitions(${PROJECT_NAME} PRIVATE NO_REFLECTIVE_LOADER)
45+
endif()
4246
if(MSVC)
4347
target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
4448
endif()

0 commit comments

Comments
 (0)