|
1 | | -name: Release |
| 1 | +name: CI CD |
2 | 2 |
|
3 | | -on: |
| 3 | +on: |
4 | 4 | workflow_dispatch: |
| 5 | + pull_request: |
5 | 6 | push: |
| 7 | + branches: |
| 8 | + - "**" |
6 | 9 | tags: |
7 | | - - '*' |
| 10 | + - "*" |
8 | 11 |
|
9 | 12 | env: |
10 | | - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 13 | + BUILD_DIR: build-conan |
11 | 14 | BUILD_TYPE: Release |
| 15 | + RELEASE_TARBALL: Release.tar.gz |
| 16 | + RELEASE_ARTIFACT: C2LinuxImplant-Linux-Release |
12 | 17 |
|
13 | 18 | permissions: |
14 | | - contents: write |
| 19 | + contents: read |
15 | 20 |
|
16 | 21 | jobs: |
17 | | - buildAndRelease: |
18 | | - # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. |
19 | | - # You can convert this to a matrix build if you need cross-platform coverage. |
20 | | - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
21 | | - # compile for old libc to cover more linux versions |
| 22 | + build-test: |
| 23 | + name: Build and test Linux deliverables |
22 | 24 | runs-on: ubuntu-22.04 |
23 | 25 |
|
24 | 26 | steps: |
25 | | - - uses: actions/checkout@v4 |
26 | | - |
27 | | - - name: Install Samba client dev headers |
28 | | - run: | |
29 | | - sudo apt-get update |
30 | | - sudo apt-get install -y libsmbclient-dev |
31 | | -
|
32 | | - # Update references |
33 | | - - name: Git Sumbodule Update |
34 | | - run: | |
35 | | - git submodule update --init |
36 | | - |
37 | | - - name: Get Conan |
38 | | - # You may pin to the exact commit or the version. |
39 | | - # uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d |
40 | | - uses: turtlebrowser/get-conan@v1.2 |
41 | | - |
42 | | - - name: Create default profile |
43 | | - run: conan profile detect |
44 | | - |
45 | | - - name: Configure CMake |
46 | | - run: cmake -B ${{github.workspace}}/build -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=${{github.workspace}}/conan_provider.cmake |
47 | | - |
48 | | - - name: Build |
49 | | - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 18 |
50 | | - |
51 | | - - name: Prep release |
52 | | - shell: bash |
53 | | - run: | |
54 | | - rm ./Release/Beacons/.gitignore |
55 | | - mv ./Release/Beacons ./Release/LinuxBeacons |
56 | | - rm ./Release/Modules/.gitignore |
57 | | - mv ./Release/Modules ./Release/LinuxModules |
58 | | - tar -zcvf Release.tar.gz Release |
59 | | -
|
60 | | - - name: Upload release |
61 | | - uses: svenstaro/upload-release-action@v2 |
62 | | - with: |
63 | | - repo_token: ${{ secrets.GITHUB_TOKEN }} |
64 | | - file: Release.tar.gz |
65 | | - asset_name: Release.tar.gz |
66 | | - tag: ${{ github.ref }} |
67 | | - overwrite: true |
68 | | - body: "Linux beacons and modules" |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + submodules: recursive |
69 | 31 |
|
| 32 | + - name: Set up Python |
| 33 | + uses: actions/setup-python@v5 |
| 34 | + with: |
| 35 | + python-version: "3.x" |
| 36 | + |
| 37 | + - name: Install Linux dependencies |
| 38 | + run: | |
| 39 | + sudo apt-get update |
| 40 | + sudo apt-get install -y libsmbclient-dev |
| 41 | +
|
| 42 | + - name: Install Conan |
| 43 | + run: | |
| 44 | + python -m pip install --upgrade pip |
| 45 | + python -m pip install "conan>=2,<3" |
| 46 | + conan profile detect --force |
| 47 | +
|
| 48 | + - name: Cache Conan packages |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: ~/.conan2 |
| 52 | + key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt') }} |
| 53 | + restore-keys: | |
| 54 | + conan-${{ runner.os }}- |
| 55 | +
|
| 56 | + - name: Configure |
| 57 | + run: | |
| 58 | + cmake \ |
| 59 | + -S . \ |
| 60 | + -B "$BUILD_DIR" \ |
| 61 | + -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ |
| 62 | + -DC2CORE_BUILD_TESTS=ON \ |
| 63 | + -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="$GITHUB_WORKSPACE/conan_provider.cmake" |
| 64 | +
|
| 65 | + - name: Build |
| 66 | + run: cmake --build "$BUILD_DIR" --config "$BUILD_TYPE" --parallel "$(nproc)" |
| 67 | + |
| 68 | + - name: Test |
| 69 | + run: ctest --test-dir "$BUILD_DIR" --output-on-failure --timeout 60 |
| 70 | + |
| 71 | + - name: Validate deliverables |
| 72 | + run: | |
| 73 | + set -euo pipefail |
| 74 | +
|
| 75 | + expected_beacons=( |
| 76 | + BeaconDns |
| 77 | + BeaconGithub |
| 78 | + BeaconHttp |
| 79 | + BeaconSmb |
| 80 | + BeaconTcp |
| 81 | + ) |
| 82 | +
|
| 83 | + expected_modules=( |
| 84 | + libAssemblyExec.so |
| 85 | + libCat.so |
| 86 | + libChangeDirectory.so |
| 87 | + libChisel.so |
| 88 | + libCimExec.so |
| 89 | + libCoff.so |
| 90 | + libDcomExec.so |
| 91 | + libDotnetExec.so |
| 92 | + libDownload.so |
| 93 | + libEnumerateRdpSessions.so |
| 94 | + libEnumerateShares.so |
| 95 | + libEvasion.so |
| 96 | + libGetEnv.so |
| 97 | + libInject.so |
| 98 | + libIpConfig.so |
| 99 | + libKerberosUseTicket.so |
| 100 | + libKeyLogger.so |
| 101 | + libKillProcess.so |
| 102 | + libListDirectory.so |
| 103 | + libListProcesses.so |
| 104 | + libMakeToken.so |
| 105 | + libMiniDump.so |
| 106 | + libMkDir.so |
| 107 | + libNetstat.so |
| 108 | + libPowershell.so |
| 109 | + libPrintWorkingDirectory.so |
| 110 | + libPsExec.so |
| 111 | + libPwSh.so |
| 112 | + libRegistry.so |
| 113 | + libRemove.so |
| 114 | + libRev2self.so |
| 115 | + libRun.so |
| 116 | + libScreenShot.so |
| 117 | + libScript.so |
| 118 | + libShell.so |
| 119 | + libSpawnAs.so |
| 120 | + libSshExec.so |
| 121 | + libStealToken.so |
| 122 | + libTaskScheduler.so |
| 123 | + libTree.so |
| 124 | + libUpload.so |
| 125 | + libWhoami.so |
| 126 | + libWinRM.so |
| 127 | + libWmiExec.so |
| 128 | + ) |
| 129 | +
|
| 130 | + for file in "${expected_beacons[@]}"; do |
| 131 | + test -s "Release/Beacons/$file" || { |
| 132 | + echo "Missing or empty beacon deliverable: $file" >&2 |
| 133 | + exit 1 |
| 134 | + } |
| 135 | + done |
| 136 | +
|
| 137 | + for file in "${expected_modules[@]}"; do |
| 138 | + test -s "Release/Modules/$file" || { |
| 139 | + echo "Missing or empty module deliverable: $file" >&2 |
| 140 | + exit 1 |
| 141 | + } |
| 142 | + done |
| 143 | +
|
| 144 | + - name: Stage release archive |
| 145 | + run: | |
| 146 | + set -euo pipefail |
| 147 | + stage="artifacts/Release" |
| 148 | +
|
| 149 | + rm -rf artifacts "$RELEASE_TARBALL" |
| 150 | + mkdir -p "$stage/LinuxBeacons" "$stage/LinuxModules" |
| 151 | +
|
| 152 | + find Release/Beacons -maxdepth 1 -type f ! -name ".gitignore" -exec cp -t "$stage/LinuxBeacons" {} + |
| 153 | + find Release/Modules -maxdepth 1 -type f ! -name ".gitignore" -exec cp -t "$stage/LinuxModules" {} + |
| 154 | +
|
| 155 | + tar -C artifacts -czf "$RELEASE_TARBALL" Release |
| 156 | +
|
| 157 | + - name: Upload CI artifact |
| 158 | + uses: actions/upload-artifact@v4 |
| 159 | + with: |
| 160 | + name: ${{ env.RELEASE_ARTIFACT }} |
| 161 | + path: ${{ env.RELEASE_TARBALL }} |
| 162 | + if-no-files-found: error |
| 163 | + |
| 164 | + release: |
| 165 | + name: Publish GitHub release |
| 166 | + runs-on: ubuntu-22.04 |
| 167 | + needs: build-test |
| 168 | + if: startsWith(github.ref, 'refs/tags/') |
| 169 | + permissions: |
| 170 | + contents: write |
| 171 | + |
| 172 | + steps: |
| 173 | + - name: Download release archive |
| 174 | + uses: actions/download-artifact@v4 |
| 175 | + with: |
| 176 | + name: ${{ env.RELEASE_ARTIFACT }} |
| 177 | + |
| 178 | + - name: Upload release |
| 179 | + uses: svenstaro/upload-release-action@v2 |
| 180 | + with: |
| 181 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 182 | + file: ${{ env.RELEASE_TARBALL }} |
| 183 | + asset_name: ${{ env.RELEASE_TARBALL }} |
| 184 | + tag: ${{ github.ref }} |
| 185 | + overwrite: true |
| 186 | + body: "Linux beacons and modules" |
0 commit comments