1
- name : Acceptance
1
+ name : Meterpreter Acceptance
2
2
3
3
# Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
4
4
# concurrency:
56
56
# - cron: '*/15 * * * *'
57
57
58
58
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
+
59
89
# Run all test individually, note there is a separate final job for aggregating the test results
60
90
test :
91
+ needs : java_meterpreter_compilation
92
+ if : always() && (needs.java_meterpreter_compilation.result == 'success' || needs.java_meterpreter_compilation.result == 'skipped')
93
+
61
94
strategy :
62
95
fail-fast : false
63
96
matrix :
@@ -146,44 +179,36 @@ jobs:
146
179
# ├── metasploit-framework
147
180
# └── metasploit-payloads (Only if the "payload-testing-branch" GitHub label is applied)
148
181
# └── 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
-
157
182
- 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') }}
159
184
uses : actions/checkout@v4
160
185
with :
161
186
repository : rapid7/mettle
162
187
path : mettle
163
188
ref : ${{ env.mettleCommit }}
164
189
165
190
- 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') }}
167
192
run : |
168
193
echo "METTLE_VERSION=$(grep -oh '[0-9].[0-9].[0-9]*' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV
169
194
working-directory : mettle
170
195
171
196
- 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') }}
173
198
run : |
174
199
set -x
175
200
ruby -pi.bak -e "gsub(/${{ env.METTLE_VERSION }}/, '${{ env.METTLE_VERSION }}-dev')" lib/metasploit_payloads/mettle/version.rb
176
201
working-directory : mettle
177
202
178
203
- 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') }}
180
205
run : |
181
206
docker run --rm=true --tty --volume=$(pwd):/mettle --workdir=/mettle rapid7/build:mettle rake mettle:build mettle:check
182
207
rake build
183
208
working-directory : mettle
184
209
185
210
- 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') }}
187
212
run : |
188
213
make TARGET=x86_64-apple-darwin
189
214
rake build
@@ -203,18 +228,39 @@ jobs:
203
228
bundler-cache : true
204
229
cache-version : 4
205
230
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
209
231
210
232
- 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') }}
212
234
run : |
213
235
cp ../mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem .
214
236
working-directory : metasploit-framework
215
237
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
+
216
262
- 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') }}
218
264
run : |
219
265
set -x
220
266
bundle exec gem install metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem
@@ -225,21 +271,16 @@ jobs:
225
271
working-directory : metasploit-framework
226
272
227
273
- 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')
229
275
uses : actions/checkout@v4
230
276
with :
231
277
repository : rapid7/metasploit-payloads
232
278
path : metasploit-payloads
233
279
ref : ${{ env.metasploitPayloadsCommit }}
234
280
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
-
240
281
- name : Build Windows payloads via Visual Studio 2019 Build (Windows)
241
282
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') }}
243
284
run : |
244
285
cd c/meterpreter
245
286
git submodule init && git submodule update
@@ -248,15 +289,15 @@ jobs:
248
289
249
290
- name : Build Windows payloads via Visual Studio 2022 Build (Windows)
250
291
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') }}
252
293
run : |
253
294
cd c/meterpreter
254
295
git submodule init && git submodule update
255
296
make.bat
256
297
working-directory : metasploit-payloads
257
298
258
299
- 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') }}
260
301
run : |
261
302
make install-php install-python install-windows
262
303
working-directory : metasploit-payloads
@@ -287,9 +328,9 @@ jobs:
287
328
# Generate a final report from the previous test results
288
329
report :
289
330
name : Generate report
290
- needs : test
331
+ needs : [ test]
291
332
runs-on : ubuntu-latest
292
- if : always()
333
+ if : always() && needs.test.result != 'skipped'
293
334
294
335
steps :
295
336
- name : Checkout code
@@ -306,15 +347,12 @@ jobs:
306
347
BUNDLE_FORCE_RUBY_PLATFORM : true
307
348
uses : ruby/setup-ruby@v1
308
349
with :
309
- ruby-version : ' ${{ matrix.ruby }} '
350
+ ruby-version : ' 3.3 '
310
351
bundler-cache : true
311
352
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
315
353
316
354
- uses : actions/download-artifact@v4
317
- id : download
355
+ id : raw_report_data
318
356
if : always()
319
357
with :
320
358
# Note: Not specifying a name will download all artifacts from the previous workflow jobs
@@ -328,11 +366,11 @@ jobs:
328
366
curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
329
367
tar -zxvf allure-$VERSION.tgz -C .
330
368
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
333
371
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
336
374
337
375
- name : archive results
338
376
if : always()
0 commit comments