Introduce shared c2_base64 CMake target

This commit is contained in:
maxdcb
2026-04-20 20:40:25 +02:00
parent 3a7b021822
commit 04fc881a07
4 changed files with 32 additions and 38 deletions
+1 -1
View File
@@ -3,7 +3,6 @@ set(C2CORE_BEACON_COMMON_SOURCES
../listener/Listener.cpp
../listener/ListenerTcp.cpp
../listener/ListenerSmb.cpp
../../thirdParty/base64/base64.cpp
)
set(C2CORE_BEACON_COMMON_LINK_LIBS
@@ -11,6 +10,7 @@ set(C2CORE_BEACON_COMMON_LINK_LIBS
PipeHandler
MemoryModule
SocksServer
c2_base64
)
set(C2CORE_BEACON_HTTP_LINK_LIBS)
+16 -16
View File
@@ -17,8 +17,7 @@ add_executable(beacon_unit_tests
../Beacon.cpp
../../listener/Listener.cpp
../../listener/ListenerTcp.cpp
../../listener/ListenerSmb.cpp
../../../thirdParty/base64/base64.cpp)
../../listener/ListenerSmb.cpp)
target_link_libraries(beacon_unit_tests
Catch2::Catch2WithMain
@@ -27,7 +26,8 @@ target_link_libraries(beacon_unit_tests
SocketHandler
PipeHandler
MemoryModule
SocksServer)
SocksServer
c2_base64)
add_test(NAME beacon_unit_tests COMMAND beacon_unit_tests)
@@ -38,8 +38,7 @@ add_executable(testBeaconDns
../BeaconDns.cpp
../../listener/Listener.cpp
../../listener/ListenerTcp.cpp
../../listener/ListenerSmb.cpp
../../../thirdParty/base64/base64.cpp)
../../listener/ListenerSmb.cpp)
target_link_libraries(testBeaconDns
nlohmann_json::nlohmann_json
@@ -47,7 +46,8 @@ target_link_libraries(testBeaconDns
Dnscommunication
PipeHandler
MemoryModule
SocksServer)
SocksServer
c2_base64)
add_test(NAME testBeaconDns COMMAND testBeaconDns)
@@ -57,8 +57,7 @@ add_executable(testBeaconGithub
../BeaconGithub.cpp
../../listener/Listener.cpp
../../listener/ListenerTcp.cpp
../../listener/ListenerSmb.cpp
../../../thirdParty/base64/base64.cpp)
../../listener/ListenerSmb.cpp)
target_link_libraries(testBeaconGithub
nlohmann_json::nlohmann_json
@@ -66,6 +65,7 @@ target_link_libraries(testBeaconGithub
PipeHandler
MemoryModule
SocksServer
c2_base64
${C2CORE_BEACON_TEST_HTTP_LINK_LIBS})
add_test(NAME testBeaconGithub COMMAND testBeaconGithub)
@@ -76,8 +76,7 @@ add_executable(testBeaconHttp
../BeaconHttp.cpp
../../listener/Listener.cpp
../../listener/ListenerTcp.cpp
../../listener/ListenerSmb.cpp
../../../thirdParty/base64/base64.cpp)
../../listener/ListenerSmb.cpp)
target_link_libraries(testBeaconHttp
nlohmann_json::nlohmann_json
@@ -85,6 +84,7 @@ target_link_libraries(testBeaconHttp
PipeHandler
MemoryModule
SocksServer
c2_base64
${C2CORE_BEACON_TEST_HTTP_LINK_LIBS})
add_test(NAME testBeaconHttp COMMAND testBeaconHttp)
@@ -95,15 +95,15 @@ add_executable(testBeaconSmb
../BeaconSmb.cpp
../../listener/Listener.cpp
../../listener/ListenerTcp.cpp
../../listener/ListenerSmb.cpp
../../../thirdParty/base64/base64.cpp)
../../listener/ListenerSmb.cpp)
target_link_libraries(testBeaconSmb
nlohmann_json::nlohmann_json
SocketHandler
PipeHandler
MemoryModule
SocksServer)
SocksServer
c2_base64)
add_test(NAME testBeaconSmb COMMAND testBeaconSmb)
@@ -113,14 +113,14 @@ add_executable(testBeaconTcp
../BeaconTcp.cpp
../../listener/Listener.cpp
../../listener/ListenerTcp.cpp
../../listener/ListenerSmb.cpp
../../../thirdParty/base64/base64.cpp)
../../listener/ListenerSmb.cpp)
target_link_libraries(testBeaconTcp
nlohmann_json::nlohmann_json
SocketHandler
PipeHandler
MemoryModule
SocksServer)
SocksServer
c2_base64)
add_test(NAME testBeaconTcp COMMAND testBeaconTcp)
+10 -15
View File
@@ -1,6 +1,5 @@
include_directories(..)
include_directories(../../modules/ModuleCmd)
include_directories(../../thirdParty/base64)
if(BUILD_TEAMSERVER)
set(additionalLib "spdlog::spdlog")
@@ -11,13 +10,13 @@ endif()
# Unit tests using Catch2
add_executable(listener_unit_tests
testListener.cpp
../Listener.cpp
../../thirdParty/base64/base64.cpp)
../Listener.cpp)
target_link_libraries(listener_unit_tests
Catch2::Catch2WithMain
Catch2::Catch2
nlohmann_json::nlohmann_json
c2_base64
${additionalLib})
add_test(NAME listener_unit_tests COMMAND listener_unit_tests)
@@ -26,32 +25,28 @@ add_test(NAME listener_unit_tests COMMAND listener_unit_tests)
add_executable(testListenerDns
testListenerDns.cpp
../Listener.cpp
../ListenerDns.cpp
../../thirdParty/base64/base64.cpp)
target_link_libraries(testListenerDns nlohmann_json::nlohmann_json Dnscommunication ${additionalLib})
../ListenerDns.cpp)
target_link_libraries(testListenerDns nlohmann_json::nlohmann_json Dnscommunication c2_base64 ${additionalLib})
add_test(NAME testListenerDns COMMAND testListenerDns)
add_executable(testListenerGithub
testListenerGithub.cpp
../Listener.cpp
../ListenerGithub.cpp
../../thirdParty/base64/base64.cpp)
target_link_libraries(testListenerGithub nlohmann_json::nlohmann_json openssl::openssl httplib::httplib ${additionalLib})
../ListenerGithub.cpp)
target_link_libraries(testListenerGithub nlohmann_json::nlohmann_json openssl::openssl httplib::httplib c2_base64 ${additionalLib})
add_test(NAME testListenerGithub COMMAND testListenerGithub)
add_executable(testListenerSmb
testListenerSmb.cpp
../Listener.cpp
../ListenerSmb.cpp
../../thirdParty/base64/base64.cpp)
target_link_libraries(testListenerSmb nlohmann_json::nlohmann_json PipeHandler ${additionalLib})
../ListenerSmb.cpp)
target_link_libraries(testListenerSmb nlohmann_json::nlohmann_json PipeHandler c2_base64 ${additionalLib})
add_test(NAME testListenerSmb COMMAND testListenerSmb)
add_executable(testListenerTcp
testListenerTcp.cpp
../Listener.cpp
../ListenerTcp.cpp
../../thirdParty/base64/base64.cpp)
target_link_libraries(testListenerTcp nlohmann_json::nlohmann_json SocketHandler ${additionalLib})
../ListenerTcp.cpp)
target_link_libraries(testListenerTcp nlohmann_json::nlohmann_json SocketHandler c2_base64 ${additionalLib})
add_test(NAME testListenerTcp COMMAND testListenerTcp)
+5 -6
View File
@@ -1,14 +1,13 @@
if(C2CORE_BUILD_TESTS)
include_directories(../../../thirdParty/base64)
add_executable(testsModuleCmd tests/testsModuleCmd.cpp ../../../thirdParty/base64/base64.cpp)
target_link_libraries(testsModuleCmd nlohmann_json::nlohmann_json)
add_executable(testsModuleCmd tests/testsModuleCmd.cpp)
target_link_libraries(testsModuleCmd nlohmann_json::nlohmann_json c2_base64)
add_custom_command(TARGET testsModuleCmd POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:testsModuleCmd> "${C2_TEST_BIN_OUTPUT_DIR}/$<TARGET_FILE_NAME:testsModuleCmd>")
add_test(NAME testsModuleCmd COMMAND "${C2_TEST_BIN_OUTPUT_DIR}/$<TARGET_FILE_NAME:testsModuleCmd>")
add_executable(testsTools tests/testsTools.cpp ../../../thirdParty/base64/base64.cpp)
target_link_libraries(testsTools nlohmann_json::nlohmann_json)
add_executable(testsTools tests/testsTools.cpp)
target_link_libraries(testsTools nlohmann_json::nlohmann_json c2_base64)
add_custom_command(TARGET testsTools POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:testsTools> "${C2_TEST_BIN_OUTPUT_DIR}/$<TARGET_FILE_NAME:testsTools>")
add_test(NAME testsTools COMMAND "${C2_TEST_BIN_OUTPUT_DIR}/$<TARGET_FILE_NAME:testsTools>")
@@ -26,4 +25,4 @@ if(C2CORE_BUILD_TESTS)
$<TARGET_FILE:testsHwbp> "${C2_TEST_BIN_OUTPUT_DIR}/$<TARGET_FILE_NAME:testsHwbp>")
add_test(NAME testsHwbp COMMAND "${C2_TEST_BIN_OUTPUT_DIR}/$<TARGET_FILE_NAME:testsHwbp>")
endif()
endif()
endif()