forked from rapid7/metasploit-payloads
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
60 lines (49 loc) · 1.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
60 lines (49 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
set(PROJECT_NAME metsrv)
project(${PROJECT_NAME} C)
include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt)
add_definitions(
-D_USRDLL
-DUNICODE
-D_UNICODE
-D_CRT_SECURE_NO_WARNINGS
)
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
endif()
include_directories(../../source/common)
include_directories(../../source/ReflectiveDLLInjection/common)
set(SRC_DIR ../../source/metsrv)
if(EXCLUDE_REFLECTIVE_LOADER)
file(GLOB SRC_FILES
${SRC_DIR}/*.c
)
else()
file(GLOB SRC_FILES
${SRC_DIR}/*.c
${MOD_DEF_DIR}/metsrv.def
)
endif()
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/metsrv.def\"")
set_source_files_properties(${MOD_DEF_DIR}/metsrv.def PROPERTIES HEADER_FILE_ONLY TRUE)
else()
# Prevent MinGW from auto-exporting symbols.
# With metsrv.def present this yields a single explicit export; without it, zero exports.
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,--exclude-all-symbols")
endif()
set(LINK_LIBS advapi32 winhttp wininet crypt32)
if(MSVC)
target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
target_link_options(${PROJECT_NAME} PUBLIC "/safeseh:no")
else()
set(LINK_LIBS ${LINK_LIBS} ws2_32)
endif()
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS} ${MET_RDI_ASM})
if(EXCLUDE_REFLECTIVE_LOADER)
target_compile_definitions(${PROJECT_NAME} PRIVATE NO_REFLECTIVE_LOADER)
endif()
# Post processing (required for all Meterpreter DLLs)
editbin(${PROJECT_NAME} ${BIN_SUBSYSTEM})
copyoutput(${PROJECT_NAME} ${BIN_OUTPUT_DIR})