Skip to content

Commit 1ca6d65

Browse files
committed
update github action build for exe and BOFs
1 parent 8eee39d commit 1ca6d65

3 files changed

Lines changed: 87 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build BOFs
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
release:
11+
name: Release (Object Files)
12+
runs-on: windows-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Configure CMake
18+
run: cmake -B build -G "Visual Studio 17 2022" -A x64
19+
20+
- name: Build BOFs
21+
run: cmake --build build --config Release
22+
23+
- name: Upload artifacts
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: BOFs-Release
27+
path: build/bofs/*.obj
28+
29+
debug:
30+
name: Debug (Executables)
31+
runs-on: windows-latest
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Configure CMake
37+
run: cmake -B build -G "Visual Studio 17 2022" -A x64 -DBUILD_DEBUG_EXES=ON
38+
39+
- name: Build Debug Executables
40+
run: cmake --build build --config Debug --target WhoAmI_debug EnumDeviceDrivers_debug GetSystemDirectory_debug Ipconfig_debug FileExfiltrationUrlEncoded_debug RegistryPersistence_debug TimeStomp_debug
41+
42+
- name: Upload artifacts
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: BOFs-Debug
46+
path: build/debug/Debug/*.exe

CMakeLists.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
cmake_minimum_required(VERSION 3.20)
22

3+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
4+
project(BeaconObjectFileLibrary LANGUAGES CXX)
5+
endif()
6+
37
set(BOF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Core ${CMAKE_CURRENT_SOURCE_DIR}/Core/base)
48
set(BOF_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bofs)
59

@@ -15,6 +19,7 @@ set(BOF_TARGETS
1519
TimeStomp
1620
)
1721

22+
# Release: compile-only BOF object files
1823
set(BOF_COPY_COMMANDS)
1924

2025
foreach(BOF_NAME ${BOF_TARGETS})
@@ -27,9 +32,31 @@ foreach(BOF_NAME ${BOF_TARGETS})
2732
)
2833
endforeach()
2934

30-
# Convenience target to build all BOFs and copy them
3135
add_custom_target(bofs ALL
3236
${BOF_COPY_COMMANDS}
3337
DEPENDS ${BOF_TARGETS}
3438
COMMENT "Copying BOF object files to ${BOF_OUTPUT_DIR}"
3539
)
40+
41+
# Debug: standalone executables with mocked Beacon APIs
42+
option(BUILD_DEBUG_EXES "Build debug executables for BOFs" OFF)
43+
44+
if(BUILD_DEBUG_EXES)
45+
set(MOCK_SOURCES
46+
${CMAKE_CURRENT_SOURCE_DIR}/Core/base/mock.cpp
47+
)
48+
49+
foreach(BOF_NAME ${BOF_TARGETS})
50+
add_executable(${BOF_NAME}_debug
51+
${CMAKE_CURRENT_SOURCE_DIR}/${BOF_NAME}/bof.cpp
52+
${MOCK_SOURCES}
53+
)
54+
target_include_directories(${BOF_NAME}_debug PRIVATE ${BOF_INCLUDE_DIRS})
55+
target_compile_definitions(${BOF_NAME}_debug PRIVATE _DEBUG)
56+
target_compile_options(${BOF_NAME}_debug PRIVATE /EHsc /std:c++20)
57+
set_target_properties(${BOF_NAME}_debug PROPERTIES
58+
OUTPUT_NAME ${BOF_NAME}
59+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/debug
60+
)
61+
endforeach()
62+
endif()

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22

33
A library of Beacon Object Files (BOFs) for Cobalt Strike. This solution uses a modified version of [Cobalt Strike/bof-vs](https://github.com/Cobalt-Strike/bof-vs) to support multiple BOF projects, unit testing, and debug builds within a single Visual Studio solution.
44

5+
## Download
6+
7+
Pre-built BOF object files are available from the latest [GitHub Actions run](https://github.com/Ap3x/Beacon-Object-File-Library/actions). Go to the most recent successful run and download the `BOFs` artifact.
8+
59
## BOFs
610

7-
| Project | Description |
8-
|---------|-------------|
9-
| EnumDeviceDrivers | Enumerates all loaded device drivers |
10-
| FileExfiltrationUrlEncoded | Exfiltrates a file via chunked URL-encoded GET requests |
11-
| GetSystemDirectory | Retrieves the Windows system directory path |
12-
| Ipconfig | Displays network adapter IP, subnet mask, and gateway |
13-
| RegistryPersistence | Installs or removes a Run key for persistence |
14-
| TimeStomp | Copies file timestamps from one file to another |
15-
| WhoAmI | Returns the current username |
11+
| Project | Description | Download |
12+
|---------|-------------|----------|
13+
| EnumDeviceDrivers | Enumerates all loaded device drivers | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
14+
| FileExfiltrationUrlEncoded | Exfiltrates a file via chunked URL-encoded GET requests | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
15+
| GetSystemDirectory | Retrieves the Windows system directory path | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
16+
| Ipconfig | Displays network adapter IP, subnet mask, and gateway | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
17+
| RegistryPersistence | Installs or removes a Run key for persistence | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
18+
| TimeStomp | Copies file timestamps from one file to another | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
19+
| WhoAmI | Returns the current username | [Latest](https://github.com/Ap3x/Beacon-Object-File-Library/actions) |
1620

1721
## Build Configurations
1822

0 commit comments

Comments
 (0)