1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-08 14:36:22 +01:00

Add peinjector cross compile

This commit is contained in:
OJ 2020-05-27 12:15:03 +10:00
parent dd5243fae5
commit 9dc7a32d6a
No known key found for this signature in database
GPG Key ID: 10D3B9A154E6DF61
4 changed files with 53 additions and 20 deletions

View File

@ -244,6 +244,26 @@ meterpreter-ext-kiwi-x64-gen:
meterpreter-ext-kiwi-x64-build: meterpreter-ext-kiwi-x64-build:
@cmake --build workspace/build/mingw-x64-ext-kiwi $(COMMON_BUILD) @cmake --build workspace/build/mingw-x64-ext-kiwi $(COMMON_BUILD)
### PeInjector
meterpreter-ext-peinjector: meterpreter-ext-peinjector-x86 meterpreter-ext-peinjector-x64
meterpreter-ext-peinjector-x86: meterpreter-ext-peinjector-x86-gen meterpreter-ext-peinjector-x86-build
meterpreter-ext-peinjector-x86-gen:
@cmake -S workspace -B workspace/build/mingw-x86-ext-peinjector -DBUILD_ALL=OFF -DBUILD_EXT_PEINJECTOR=ON $(COMMON_GEN_X86)
meterpreter-ext-peinjector-x86-build:
@cmake --build workspace/build/mingw-x86-ext-peinjector $(COMMON_BUILD)
meterpreter-ext-peinjector-x64: meterpreter-ext-peinjector-x64-gen meterpreter-ext-peinjector-x64-build
meterpreter-ext-peinjector-x64-gen:
@cmake -S workspace -B workspace/build/mingw-x64-ext-peinjector -DBUILD_ALL=OFF -DBUILD_EXT_PEINJECTOR=ON $(COMMON_GEN_X64)
meterpreter-ext-peinjector-x64-build:
@cmake --build workspace/build/mingw-x64-ext-peinjector $(COMMON_BUILD)
########################################################################################## ##########################################################################################
### Container-based Builds ### Container-based Builds
########################################################################################## ##########################################################################################
@ -352,3 +372,12 @@ docker-ext-kiwi-x86:
docker-ext-kiwi-x64: docker-ext-kiwi-x64:
@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-kiwi-x64 @docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-kiwi-x64
docker-ext-peinjector:
@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-peinjector
docker-ext-peinjector-x86:
@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-peinjector-x86
docker-ext-peinjector-x64:
@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-peinjector-x64

View File

@ -177,6 +177,9 @@ endif()
if(BUILD_EXT_KIWI) if(BUILD_EXT_KIWI)
set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_kiwi) set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_kiwi)
endif() endif()
if(BUILD_EXT_PEINJECTOR)
set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_peinjector)
endif()
if(BUILD_EXT_SNIFFER) if(BUILD_EXT_SNIFFER)
if(MSVC) if(MSVC)
@ -191,9 +194,6 @@ if(BUILD_EXT_SNIFFER)
endif() endif()
if(MSVC) if(MSVC)
if(BUILD_EXT_PEINJECTOR)
set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_peinjector)
endif()
if(BUILD_EXT_MIMIKATZ) if(BUILD_EXT_MIMIKATZ)
set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_mimikatz) set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_mimikatz)
endif() endif()

View File

@ -10,10 +10,12 @@ add_definitions(
-D_UNICODE -D_UNICODE
) )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
endif()
include_directories(../../source/common) include_directories(../../source/common)
include_directories(../../source/ReflectiveDllInjection/common) include_directories(../../source/ReflectiveDLLInjection/common)
set(SRC_DIR ../../source/extensions/peinjector) set(SRC_DIR ../../source/extensions/peinjector)
file(GLOB SRC_FILES file(GLOB SRC_FILES
@ -22,8 +24,10 @@ file(GLOB SRC_FILES
) )
add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH}) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"") if(MSVC)
set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE) set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
endif()
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS}) target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
if(MSVC) if(MSVC)

View File

@ -11,19 +11,19 @@ RUN apt-get update && \
apt-get dist-upgrade -y && \ apt-get dist-upgrade -y && \
apt-get -y install software-properties-common && \ apt-get -y install software-properties-common && \
dpkg --add-architecture i386 && \ dpkg --add-architecture i386 && \
apt-get update apt-get update && \
RUN apt-get -y install bison flex gcc gcc-multilib jam make wget apt-get -y install bison flex gcc gcc-multilib jam make wget \
RUN apt-get -y install ruby rake bundler git ruby rake bundler git \
RUN apt-get -y install mingw-w64-x86-64-dev mingw-w64-i686-dev mingw-w64-x86-64-dev mingw-w64-i686-dev \
RUN apt-get -y install g++-mingw-w64-i686 g++-mingw-w64-x86-64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 \
RUN apt-get -y install gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 \
RUN apt-get -y install cmake cmake \
RUN apt-get -y install maven maven \
RUN apt-get -y install wine python python3 wine python python3 \
RUN apt-get -y install openjdk-8-jdk openjdk-8-jdk \
RUN apt-get -y install php-cli php-cli && \
#apt-get clean && \ apt-get clean && \
#rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Android NDK # Android NDK
RUN wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2 && \ RUN wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2 && \