mirror of
https://github.com/maxDcb/C2LinuxImplant
synced 2026-06-08 15:48:43 +00:00
Maj core & clean
This commit is contained in:
+51
-96
@@ -2,113 +2,68 @@ cmake_minimum_required(VERSION 3.24.0 FATAL_ERROR)
|
||||
|
||||
project(C2LinuxImplant VERSION 0.0.0 LANGUAGES CXX C)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# --- Decide whether a prefix path was provided (var or env) ---
|
||||
set(_prefixes "")
|
||||
|
||||
# Prefer the CMake var if set on the command line/cache.
|
||||
if(DEFINED CMAKE_PREFIX_PATH AND NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
|
||||
set(_prefixes "${CMAKE_PREFIX_PATH}")
|
||||
elseif(DEFINED ENV{CMAKE_PREFIX_PATH} AND NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
|
||||
# fall back to environment variable
|
||||
set(_prefixes "$ENV{CMAKE_PREFIX_PATH}")
|
||||
endif()
|
||||
|
||||
# Optional: normalize whitespace
|
||||
string(STRIP "${_prefixes}" _prefixes)
|
||||
|
||||
if(_prefixes)
|
||||
|
||||
message(STATUS "Using CMAKE_PREFIX_PATH: ${_prefixes}")
|
||||
|
||||
##
|
||||
## Conan Dependencies
|
||||
##
|
||||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
|
||||
include_directories(${CMAKE_INCLUDE_PATH})
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
option(C2CORE_BUILD_TESTS "Enable C2Core tests from the parent project" OFF)
|
||||
|
||||
set(C2_RUNTIME_MODULE_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/Release/Modules" CACHE PATH
|
||||
"Directory where C2Core runtime modules are copied after build")
|
||||
set(C2_TEST_BIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/tests" CACHE PATH
|
||||
"Directory where C2Core test binaries are copied after build")
|
||||
|
||||
file(MAKE_DIRECTORY "${C2_RUNTIME_MODULE_OUTPUT_DIR}")
|
||||
file(MAKE_DIRECTORY "${C2_TEST_BIN_OUTPUT_DIR}")
|
||||
|
||||
|
||||
add_definitions(-DBUILD_IMPLANT)
|
||||
|
||||
|
||||
##
|
||||
## C2Core dependency and build
|
||||
##
|
||||
##
|
||||
## Conan Dependencies
|
||||
##
|
||||
|
||||
find_package(C2Core CONFIG REQUIRED)
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
include_directories(thirdParty/base64)
|
||||
|
||||
add_subdirectory(beacon/beacon)
|
||||
|
||||
else()
|
||||
|
||||
message(STATUS "CMAKE_PREFIX_PATH not provided; using fallback strategy")
|
||||
|
||||
add_definitions(-DBUILD_IMPLANT)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
find_package(Libssh2 REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED CONFIG)
|
||||
|
||||
include_directories(${CMAKE_INCLUDE_PATH})
|
||||
|
||||
get_target_property(C2_NLOHMANN_JSON_INCLUDE_DIRS nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(C2_NLOHMANN_JSON_INCLUDE_DIRS)
|
||||
include_directories(BEFORE ${C2_NLOHMANN_JSON_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
## Conan Dependencies
|
||||
##
|
||||
##
|
||||
## Build
|
||||
##
|
||||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
|
||||
include_directories(thirdParty)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
add_subdirectory(libs)
|
||||
|
||||
include_directories(${CMAKE_INCLUDE_PATH})
|
||||
add_subdirectory(thirdParty)
|
||||
include_directories(thirdParty/base64)
|
||||
include_directories(thirdParty/donut/include)
|
||||
|
||||
##
|
||||
## Fetch for core
|
||||
##
|
||||
set(DONUT_BUILD_DIR "${CMAKE_BINARY_DIR}/thirdParty/donut")
|
||||
add_library(Donut STATIC IMPORTED)
|
||||
set_target_properties(Donut PROPERTIES
|
||||
IMPORTED_LOCATION "${DONUT_BUILD_DIR}/lib/libdonut.a"
|
||||
)
|
||||
|
||||
include(FetchContent)
|
||||
add_subdirectory(core/modules)
|
||||
add_subdirectory(core/beacon)
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries" FORCE)
|
||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "Build static libraries" FORCE)
|
||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(
|
||||
libssh2
|
||||
GIT_REPOSITORY https://github.com/libssh2/libssh2.git
|
||||
GIT_TAG libssh2-1.11.1
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(libssh2)
|
||||
include_directories(core/listener)
|
||||
include_directories(core/beacon)
|
||||
include_directories(core/modules/ModuleCmd)
|
||||
add_subdirectory(beacon/beacon)
|
||||
|
||||
|
||||
##
|
||||
## Build
|
||||
##
|
||||
|
||||
include_directories(thirdParty)
|
||||
|
||||
add_subdirectory(libs)
|
||||
|
||||
add_subdirectory(thirdParty)
|
||||
include_directories(thirdParty/base64)
|
||||
include_directories(thirdParty/donut/include)
|
||||
|
||||
set(DONUT_BUILD_DIR "${CMAKE_BINARY_DIR}/thirdParty/donut")
|
||||
add_library(Donut STATIC IMPORTED)
|
||||
set_target_properties(Donut PROPERTIES
|
||||
IMPORTED_LOCATION "${DONUT_BUILD_DIR}/lib/libdonut.a"
|
||||
)
|
||||
|
||||
add_subdirectory(core/modules)
|
||||
add_subdirectory(core/beacon)
|
||||
|
||||
include_directories(core/listener)
|
||||
include_directories(core/beacon)
|
||||
include_directories(core/modules/ModuleCmd)
|
||||
add_subdirectory(beacon/beacon)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
find_package(PythonInterp)
|
||||
find_package(Python)
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
set(PYTHON_SCRIPT "${CMAKE_SOURCE_DIR}//beacon/beacon/handleConfig.py")
|
||||
set(GENERATED_HEADER "${CMAKE_BINARY_DIR}/cryptDef.hpp")
|
||||
add_custom_command(
|
||||
OUTPUT ${GENERATED_HEADER}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SCRIPT} -o ${GENERATED_HEADER}
|
||||
COMMAND ${Python3_EXECUTABLE} ${PYTHON_SCRIPT} -o ${GENERATED_HEADER}
|
||||
COMMENT "Generating header.hpp using handleConfig.py"
|
||||
VERBATIM
|
||||
)
|
||||
@@ -62,4 +61,3 @@ set_property(TARGET BeaconDns PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||
target_link_libraries(BeaconDns BeaconDnsLib)
|
||||
add_custom_command(TARGET BeaconDns POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:BeaconDns> "${CMAKE_SOURCE_DIR}/Release/Beacons/$<TARGET_FILE_NAME:BeaconDns>")
|
||||
|
||||
|
||||
+7
-2
@@ -1,6 +1,11 @@
|
||||
[requires]
|
||||
openssl/3.3.1
|
||||
cpp-httplib/0.16.3
|
||||
openssl/3.6.2
|
||||
cpp-httplib/0.39.0
|
||||
libssh2/1.11.1
|
||||
nlohmann_json/3.12.0
|
||||
|
||||
[options]
|
||||
libssh2/*:shared=False
|
||||
|
||||
[layout]
|
||||
cmake_layout
|
||||
|
||||
+1
-1
Submodule core updated: ccffb848ca...04fc881a07
Vendored
+18
-1
@@ -1,5 +1,22 @@
|
||||
set(C2_BASE64_SOURCE_DIR "${CMAKE_SOURCE_DIR}/thirdParty/base64" CACHE PATH
|
||||
"Path to the cpp-base64 source tree consumed by C2Core")
|
||||
set(C2_DONUT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/thirdParty/donut" CACHE PATH
|
||||
"Path to the donut source tree consumed by C2Core")
|
||||
|
||||
add_library(c2_base64 STATIC
|
||||
"${C2_BASE64_SOURCE_DIR}/base64.cpp"
|
||||
)
|
||||
|
||||
target_include_directories(c2_base64 PUBLIC
|
||||
"${C2_BASE64_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
set_target_properties(c2_base64 PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
# donut
|
||||
file(COPY ${CMAKE_SOURCE_DIR}/thirdParty/donut DESTINATION ${CMAKE_BINARY_DIR}/thirdParty)
|
||||
file(COPY "${C2_DONUT_SOURCE_DIR}" DESTINATION "${CMAKE_BINARY_DIR}/thirdParty")
|
||||
execute_process(COMMAND bash -c "cd ${CMAKE_BINARY_DIR}/thirdParty/donut && make -f Makefile")
|
||||
set(Donut "${CMAKE_BINARY_DIR}/thirdParty/donut/lib/libdonut.a" PARENT_SCOPE)
|
||||
set(aplib64 "${CMAKE_BINARY_DIR}/thirdParty/donut/lib/aplib64.a" PARENT_SCOPE)
|
||||
|
||||
Reference in New Issue
Block a user