Skip to content

Commit fa2d13b

Browse files
committed
Move Java meterpreter compilation to linux
1 parent 97e50cc commit fa2d13b

File tree

6 files changed

+82
-44
lines changed

6 files changed

+82
-44
lines changed

.github/workflows/command_shell_acceptance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
name: Acceptance
2+
name: Command Shell Acceptance
33

44
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
55
#concurrency:

.github/workflows/ldap_acceptance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Acceptance
1+
name: LDAP Acceptance
22

33
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
44
#concurrency:

.github/workflows/meterpreter_acceptance.yml

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Acceptance
1+
name: Meterpreter Acceptance
22

33
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
44
#concurrency:
@@ -56,8 +56,41 @@ on:
5656
# - cron: '*/15 * * * *'
5757

5858
jobs:
59+
# Compile Java Meterpreter via docker if required, we can't always do this on the
60+
# host environment (i.e. for macos). So it instead gets compiled first on a linux
61+
# host, then the artifacts are copied back to the host later
62+
java_meterpreter_compilation:
63+
name: Compile Java Meterpreter
64+
runs-on: ubuntu-latest
65+
if: ${{ contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
66+
67+
env:
68+
metasploitPayloadsCommit: ${{ github.event.inputs.metasploitPayloadsCommit || 'master' }}
69+
70+
steps:
71+
- name: Checkout metasploit-payloads
72+
uses: actions/checkout@v4
73+
with:
74+
repository: rapid7/metasploit-payloads
75+
path: metasploit-payloads
76+
ref: ${{ env.metasploitPayloadsCommit }}
77+
78+
- name: Build Java and Android payloads
79+
run: |
80+
mkdir $(pwd)/java-artifacts
81+
docker run --rm -w "$(pwd)" -v "$(pwd):$(pwd)" rapid7/msf-ubuntu-x64-meterpreter:latest /bin/bash -c "set -x && cd metasploit-payloads/java && mvn package -Dandroid.sdk.path=/usr/local/android-sdk -Dandroid.release=true -Ddeploy.path=../../java-artifacts -Dmaven.test.skip=true -P deploy && mvn -Dmaven.test.skip=true -Ddeploy.path=../../java-artifacts -P deploy package"
82+
83+
- name: Store Java artifacts
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: java-artifacts
87+
path: java-artifacts
88+
5989
# Run all test individually, note there is a separate final job for aggregating the test results
6090
test:
91+
needs: java_meterpreter_compilation
92+
if: always() && (needs.java_meterpreter_compilation.result == 'success' || needs.java_meterpreter_compilation.result == 'skipped')
93+
6194
strategy:
6295
fail-fast: false
6396
matrix:
@@ -146,44 +179,36 @@ jobs:
146179
# ├── metasploit-framework
147180
# └── metasploit-payloads (Only if the "payload-testing-branch" GitHub label is applied)
148181
# └── mettle (Only if the "payload-testing-mettle-branch" GitHub label is applied)
149-
150-
- name: Install Docker - macOS
151-
if: ${{ ( matrix.meterpreter.name == 'java') && (runner.os == 'macos' ) && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
152-
run: |
153-
brew install docker
154-
colima delete
155-
colima start --arch x86_64
156-
157182
- name: Checkout mettle
158-
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
183+
if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
159184
uses: actions/checkout@v4
160185
with:
161186
repository: rapid7/mettle
162187
path: mettle
163188
ref: ${{ env.mettleCommit }}
164189

165190
- name: Get mettle version
166-
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
191+
if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
167192
run: |
168193
echo "METTLE_VERSION=$(grep -oh '[0-9].[0-9].[0-9]*' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV
169194
working-directory: mettle
170195

171196
- name: Prerequisite mettle gem setup
172-
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
197+
if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
173198
run: |
174199
set -x
175200
ruby -pi.bak -e "gsub(/${{ env.METTLE_VERSION }}/, '${{ env.METTLE_VERSION }}-dev')" lib/metasploit_payloads/mettle/version.rb
176201
working-directory: mettle
177202

178203
- name: Compile mettle payloads
179-
if: ${{ matrix.meterpreter.name == 'mettle' && runner.os != 'macos' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
204+
if: ${{ matrix.meterpreter.name == 'mettle' && runner.os != 'macos' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
180205
run: |
181206
docker run --rm=true --tty --volume=$(pwd):/mettle --workdir=/mettle rapid7/build:mettle rake mettle:build mettle:check
182207
rake build
183208
working-directory: mettle
184209

185210
- name: Compile mettle payloads - macOS
186-
if: ${{ matrix.meterpreter.name == 'mettle' && runner.os == 'macos' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
211+
if: ${{ matrix.meterpreter.name == 'mettle' && runner.os == 'macos' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
187212
run: |
188213
make TARGET=x86_64-apple-darwin
189214
rake build
@@ -203,18 +228,39 @@ jobs:
203228
bundler-cache: true
204229
cache-version: 4
205230
working-directory: metasploit-framework
206-
# Github actions with Ruby requires Bundler 2.2.18+
207-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
208-
bundler: 2.2.33
209231

210232
- name: Move mettle gem into framework
211-
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'mettle-testing-branch')) }}
233+
if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
212234
run: |
213235
cp ../mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem .
214236
working-directory: metasploit-framework
215237

238+
- uses: actions/download-artifact@v4
239+
name: Download Java meterpreter
240+
id: download_java_meterpreter
241+
if: ${{ matrix.meterpreter.name == 'java' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
242+
with:
243+
# Note: Not specifying a name will download all artifacts from the previous workflow jobs
244+
path: raw-data
245+
246+
- name: Extract Java Meterpreter (Unix)
247+
if: ${{ matrix.meterpreter.name == 'java' && runner.os != 'Windows' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
248+
shell: bash
249+
run: |
250+
set -x
251+
download_path=${{steps.download_java_meterpreter.outputs.download-path}}
252+
cp -r $download_path/java-artifacts/data/* ./metasploit-framework/data
253+
254+
- name: Extract Java Meterpreter (Windows)
255+
if: ${{ matrix.meterpreter.name == 'java' && runner.os == 'Windows' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
256+
shell: bash
257+
run: |
258+
set -x
259+
download_path=$(cygpath -u '${{steps.download_java_meterpreter.outputs.download-path}}')
260+
cp -r $download_path/java-artifacts/data/* ./metasploit-framework/data
261+
216262
- name: Install mettle gem
217-
if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.issue.labels.*.name, 'payload-testing-mettle-branch')) }}
263+
if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') }}
218264
run: |
219265
set -x
220266
bundle exec gem install metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem
@@ -225,21 +271,16 @@ jobs:
225271
working-directory: metasploit-framework
226272

227273
- name: Checkout metasploit-payloads
228-
if: contains(github.event.issue.labels.*.name, 'payload-testing-branch')
274+
if: contains(github.event.pull_request.labels.*.name, 'payload-testing-branch')
229275
uses: actions/checkout@v4
230276
with:
231277
repository: rapid7/metasploit-payloads
232278
path: metasploit-payloads
233279
ref: ${{ env.metasploitPayloadsCommit }}
234280

235-
- name: Build Java and Android payloads
236-
if: ${{ (matrix.meterpreter.name == 'java') && (runner.os != 'Windows') && (contains(github.event.issue.labels.*.name, 'payload-testing-branch')) }}
237-
run: |
238-
docker run --rm -w "$(pwd)" -v "$(pwd):$(pwd)" rapid7/msf-ubuntu-x64-meterpreter:latest /bin/bash -c "cd metasploit-payloads/java && make clean && make android && mvn -P deploy package"
239-
240281
- name: Build Windows payloads via Visual Studio 2019 Build (Windows)
241282
shell: cmd
242-
if: ${{ (runner.os == 'Windows') && (matrix.os == 'windows-2019') && (contains(github.event.issue.labels.*.name, 'payload-testing-branch')) }}
283+
if: ${{ matrix.meterpreter.name == 'windows_meterpreter' && matrix.os == 'windows-2019' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
243284
run: |
244285
cd c/meterpreter
245286
git submodule init && git submodule update
@@ -248,15 +289,15 @@ jobs:
248289

249290
- name: Build Windows payloads via Visual Studio 2022 Build (Windows)
250291
shell: cmd
251-
if: ${{ (runner.os == 'Windows') && (matrix.os == 'windows-2022') && (contains(github.event.issue.labels.*.name, 'payload-testing-branch')) }}
292+
if: ${{ matrix.meterpreter.name == 'windows_meterpreter' && matrix.os == 'windows-2022' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
252293
run: |
253294
cd c/meterpreter
254295
git submodule init && git submodule update
255296
make.bat
256297
working-directory: metasploit-payloads
257298

258299
- name: Build PHP, Python and Windows payloads
259-
if: ${{ ((matrix.meterpreter.name == 'php') || (matrix.meterpreter.name == 'python') || (runner.os == 'Windows')) && (contains(github.event.issue.labels.*.name, 'payload-testing-branch'))}}
300+
if: ${{ (matrix.meterpreter.name == 'php' || matrix.meterpreter.name == 'python' || runner.os == 'Windows') && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') }}
260301
run: |
261302
make install-php install-python install-windows
262303
working-directory: metasploit-payloads
@@ -287,9 +328,9 @@ jobs:
287328
# Generate a final report from the previous test results
288329
report:
289330
name: Generate report
290-
needs: test
331+
needs: [test]
291332
runs-on: ubuntu-latest
292-
if: always()
333+
if: always() && needs.test.result != 'skipped'
293334

294335
steps:
295336
- name: Checkout code
@@ -306,15 +347,12 @@ jobs:
306347
BUNDLE_FORCE_RUBY_PLATFORM: true
307348
uses: ruby/setup-ruby@v1
308349
with:
309-
ruby-version: '${{ matrix.ruby }}'
350+
ruby-version: '3.3'
310351
bundler-cache: true
311352
cache-version: 4
312-
# Github actions with Ruby requires Bundler 2.2.18+
313-
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
314-
bundler: 2.2.33
315353

316354
- uses: actions/download-artifact@v4
317-
id: download
355+
id: raw_report_data
318356
if: always()
319357
with:
320358
# Note: Not specifying a name will download all artifacts from the previous workflow jobs
@@ -328,11 +366,11 @@ jobs:
328366
curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
329367
tar -zxvf allure-$VERSION.tgz -C .
330368
331-
ls -la ${{steps.download.outputs.download-path}}
332-
./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report
369+
ls -la ${{steps.raw_report_data.outputs.download-path}}
370+
./allure-$VERSION/bin/allure generate ${{steps.raw_report_data.outputs.download-path}}/* -o ./allure-report
333371
334-
find ${{steps.download.outputs.download-path}}
335-
bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html
372+
find ${{steps.raw_report_data.outputs.download-path}}
373+
bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.raw_report_data.outputs.download-path}} > ./allure-report/support_matrix.html
336374
337375
- name: archive results
338376
if: always()

.github/workflows/mysql_acceptance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Acceptance
1+
name: MySQL Acceptance
22

33
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
44
#concurrency:

.github/workflows/postgres_acceptance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Acceptance
1+
name: Postgres Acceptance
22

33
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
44
#concurrency:

.github/workflows/smb_acceptance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Acceptance
1+
name: SMB Acceptance
22

33
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
44
#concurrency:

0 commit comments

Comments
 (0)