mirror of
https://github.com/maxDcb/C2LinuxImplant
synced 2026-06-08 15:48:43 +00:00
Add Core package support
This commit is contained in:
+95
-33
@@ -4,53 +4,115 @@ project(C2LinuxImplant VERSION 0.0.0 LANGUAGES CXX C)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
##
|
||||
## Conan Dependencies
|
||||
##
|
||||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
|
||||
# --- Decide whether a prefix path was provided (var or env) ---
|
||||
set(_prefixes "")
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
# 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()
|
||||
|
||||
include_directories(${CMAKE_INCLUDE_PATH})
|
||||
# Optional: normalize whitespace
|
||||
string(STRIP "${_prefixes}" _prefixes)
|
||||
|
||||
include_directories(thirdParty)
|
||||
if(_prefixes)
|
||||
|
||||
##
|
||||
## Config Tests et Logs
|
||||
##
|
||||
message(STATUS "Using CMAKE_PREFIX_PATH: ${_prefixes}")
|
||||
|
||||
option(WITH_TESTS "Compile for tests" OFF)
|
||||
##
|
||||
## Conan Dependencies
|
||||
##
|
||||
|
||||
message(STATUS "WITH_TESTS is set to ${WITH_TESTS}")
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
|
||||
include_directories(${CMAKE_INCLUDE_PATH})
|
||||
|
||||
|
||||
##
|
||||
## C2Core dependency and build
|
||||
##
|
||||
|
||||
|
||||
find_package(C2Core CONFIG REQUIRED)
|
||||
|
||||
include_directories(thirdParty/base64)
|
||||
|
||||
add_subdirectory(beacon/beacon)
|
||||
|
||||
add_definitions(-DBUILD_IMPLANT)
|
||||
if(NOT WITH_TESTS)
|
||||
message(STATUS "[-] Tests are disabled.")
|
||||
else()
|
||||
message(STATUS "[+] Tests are enabled.")
|
||||
add_definitions(-DBUILD_TESTS)
|
||||
|
||||
message(STATUS "CMAKE_PREFIX_PATH not provided; using fallback strategy")
|
||||
|
||||
##
|
||||
## Conan Dependencies
|
||||
##
|
||||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
|
||||
include_directories(${CMAKE_INCLUDE_PATH})
|
||||
|
||||
include_directories(thirdParty)
|
||||
|
||||
##
|
||||
## Config Tests et Logs
|
||||
##
|
||||
|
||||
option(WITH_TESTS "Compile for tests" OFF)
|
||||
|
||||
message(STATUS "WITH_TESTS is set to ${WITH_TESTS}")
|
||||
|
||||
add_definitions(-DBUILD_IMPLANT)
|
||||
if(NOT WITH_TESTS)
|
||||
message(STATUS "[-] Tests are disabled.")
|
||||
else()
|
||||
message(STATUS "[+] Tests are enabled.")
|
||||
add_definitions(-DBUILD_TESTS)
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
## Build
|
||||
##
|
||||
|
||||
add_subdirectory(libs)
|
||||
|
||||
add_subdirectory(thirdParty)
|
||||
include_directories(thirdParty/base64)
|
||||
include_directories(thirdParty/donut/include)
|
||||
|
||||
if(WITH_TESTS)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
add_subdirectory(core/modules)
|
||||
add_subdirectory(core/beacon)
|
||||
|
||||
include_directories(core/beacon)
|
||||
include_directories(core/modules/ModuleCmd)
|
||||
add_subdirectory(beacon/beacon)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
## Build
|
||||
##
|
||||
|
||||
add_subdirectory(libs)
|
||||
|
||||
add_subdirectory(thirdParty)
|
||||
include_directories(thirdParty/base64)
|
||||
include_directories(thirdParty/donut/include)
|
||||
|
||||
if(WITH_TESTS)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
add_subdirectory(core/modules)
|
||||
add_subdirectory(core/beacon)
|
||||
|
||||
include_directories(core/beacon)
|
||||
include_directories(core/modules/ModuleCmd)
|
||||
add_subdirectory(beacon/beacon)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +60,33 @@ cmake .. -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./conan_provider.cmake -DWITH_TESTS=
|
||||
make -j4
|
||||
```
|
||||
|
||||
Project can be build with the C2Core package
|
||||
|
||||
```
|
||||
# download last linux package
|
||||
url="$(curl -sH 'Accept: application/vnd.github+json' \
|
||||
${GITHUB_TOKEN:+-H "Authorization: Bearer $GITHUB_TOKEN"} \
|
||||
'https://api.github.com/repos/maxDcb/C2Core/releases?per_page=100' \
|
||||
| jq -r '[.[] | select(.tag_name|startswith("linux-"))]
|
||||
| sort_by(.created_at) | reverse
|
||||
| .[0].assets[]
|
||||
| select(.name|test("^C2Core-Linux.*"))
|
||||
| .browser_download_url' | head -n1)"
|
||||
|
||||
fname="${url##*/}"
|
||||
curl -L "$url" -o "$fname"
|
||||
echo "Downloaded: $fname"
|
||||
|
||||
mkdir -p C2Core-Linux && tar -xzf C2Core-Linux.tar.gz -C C2Core-Linux
|
||||
|
||||
export CMAKE_PREFIX_PATH=`pwd`/C2Core-Linux
|
||||
|
||||
cmake .. -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./conan_provider.cmake
|
||||
|
||||
make -j4
|
||||
```
|
||||
|
||||
|
||||
### Output Locations
|
||||
|
||||
* Compiled Beacons: `Release/Beacons`
|
||||
|
||||
Reference in New Issue
Block a user