-
Notifications
You must be signed in to change notification settings - Fork 208
492 lines (435 loc) · 17.3 KB
/
verify.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
name: Verify
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
actions: none
checks: none
contents: read
deployments: none
id-token: none
issues: none
discussions: none
packages: none
pages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'
jobs:
# The job checkout structure is:
# .
# ├── metasploit-omnibus
# └── metasploit-framework (Only if ARM or Windows builds)
#
docker_arm:
runs-on: ${{ matrix.os }}
timeout-minutes: 600
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# From: 'ls ./docker/'
docker:
# Skipped as not working
# - { dockerfile: 'debian-aarch64', previousImage: '' }
- { name: 'debian-armv7', previousDockerhubImage: 'rapid7/msf-debian-armv7-omnibus:2024_04' }
name: ${{ matrix.os }} - ${{ matrix.docker.name }}
steps:
- name: Checkout omnibus
uses: actions/checkout@v4
with:
path: metasploit-omnibus
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: changes
with:
filters: |
docker:
- 'docker/**'
working-directory: metasploit-omnibus
# Set the env vars for either a new build, or a previously successful build
- name: Set docker build metadata
run: |
export BUILD_DATE=$(date "+%Y_%m")
echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV"
if test "${HAS_MODIFIED_DOCKERFILES}" = 'true'; then
echo 'New build required'
echo "DOCKER_IMAGE=rapid7/${DOCKER_NAME}-omnibus:${BUILD_DATE}" >> "$GITHUB_ENV"
else
echo 'Reusing old image'
echo "DOCKER_IMAGE=${PREVIOUS_DOCKERHUB_IMAGE}" >> "$GITHUB_ENV"
fi
env:
HAS_MODIFIED_DOCKERFILES: ${{ steps.changes.outputs.docker }}
DOCKER_NAME: ${{ matrix.docker.name }}
PREVIOUS_DOCKERHUB_IMAGE: ${{ matrix.docker.previousDockerhubImage }}
- name: Build Docker image
if: steps.changes.outputs.docker == 'true'
run: |
/bin/bash -x -c "cd metasploit-omnibus && docker build --tag ${DOCKER_IMAGE} -f ./docker/${DOCKER_NAME}/Dockerfile ./docker/${DOCKER_NAME}"
env:
DOCKER_NAME: ${{ matrix.docker.name }}
# Checkout again - but with the submodules enabled to start a real build
- name: Checkout omnibus and submodules
uses: actions/checkout@v4
with:
submodules: true
path: metasploit-omnibus
# Checkout framework
- name: Checkout metasploit-framework code
uses: actions/checkout@v4
with:
repository: rapid7/metasploit-framework
path: metasploit-framework
# If testing a custom branch is required
# ref: 'update-bundler-version'
- name: Run omnibus
run: |
set -x
echo "Building new image from ${DOCKER_IMAGE}"
mkdir -p metasploit-omnibus/certs
curl -L -o metasploit-omnibus/certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem
cat > Dockerfile_temp <<EOF
FROM ${DOCKER_IMAGE}
RUN ["cross-build-start"]
COPY metasploit-omnibus /metasploit-omnibus
COPY metasploit-framework /metasploit-framework
RUN bash -l -c "cd /metasploit-omnibus && make"
RUN ["cross-build-end"]
EOF
cat > Dockerfile_temp.dockerignore <<EOF
*
!metasploit-omnibus
!metasploit-framework
EOF
export TEMP_DOCKER_IMAGE=${DOCKER_IMAGE}-build-artifacts
docker build --no-cache --rm --tag ${TEMP_DOCKER_IMAGE} --file Dockerfile_temp .
# Create the temp image and copy out the build assets
id=$(docker create ${TEMP_DOCKER_IMAGE})
docker cp $id:/metasploit-omnibus/pkg metasploit-omnibus
docker rm -v $id
docker rmi ${TEMP_DOCKER_IMAGE}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: metasploit-${{ matrix.docker.name }}-installers
path: |
metasploit-omnibus/pkg/*.pkg
metasploit-omnibus/pkg/*.rpm
metasploit-omnibus/pkg/*.msi
metasploit-omnibus/pkg/*.deb
retention-days: 1
docker_intel:
runs-on: ${{ matrix.os }}
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# From: 'ls ./docker/'
docker:
- name: 'centos6-x64'
previousDockerhubImage: 'rapid7/msf-centos6-x64-omnibus:2024_04'
installer: 'sudo rpm -i metasploit-omnibus/pkg/metasploit-framework*.rpm'
# Currently fails as it uses an older Ruby version:
- name: 'fedora30-x64'
# XXX: Previous dockerhub image fails as using Ruby 2.5.3 still
previousDockerhubImage: 'rapid7/msf-fedora30-x64-omnibus:2024_04'
installer: 'sudo rpm -i metasploit-omnibus/pkg/metasploit-framework*.rpm'
# Currently fails on rate limiting on Kali's side:
# - name: 'kali109-x64'
# previousDockerhubImage: 'rapid7/msf-kali109-x64-omnibus:2020_03'
# installer: 'sudo dpkg -i metasploit-omnibus/pkg/metasploit-framework_*_amd64.deb'
- name: 'ubuntu1204-x64'
previousDockerhubImage: 'rapid7/msf-ubuntu1204-x64-omnibus:2024_04'
installer: 'sudo dpkg -i metasploit-omnibus/pkg/*.deb'
- name: 'ubuntu1204-x86'
previousDockerhubImage: 'rapid7/msf-ubuntu1204-x86-omnibus:2024_04'
linux32: true
installer: 'sudo dpkg -i metasploit-omnibus/pkg/metasploit-framework_*_i386.deb'
- name: 'ubuntu1804-x64'
previousDockerhubImage: 'rapid7/msf-ubuntu1804-x64-omnibus:2024_04'
installer: 'sudo dpkg -i metasploit-omnibus/pkg/metasploit-framework_*_amd64.deb'
name: ${{ matrix.os }} - ${{ matrix.docker.name }}
steps:
- name: Checkout omnibus
uses: actions/checkout@v4
with:
path: metasploit-omnibus
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: changes
with:
filters: |
docker:
- 'docker/**'
working-directory: metasploit-omnibus
# Set the env vars for either a new build, or a previously successful build
- name: Set docker build metadata
run: |
export BUILD_DATE=$(date "+%Y_%m")
echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV"
if test "${HAS_MODIFIED_DOCKERFILES}" = 'true'; then
echo 'New build required'
echo "DOCKER_IMAGE=rapid7/${DOCKER_NAME}-omnibus:${BUILD_DATE}" >> "$GITHUB_ENV"
else
echo 'Reusing old image'
echo "DOCKER_IMAGE=${PREVIOUS_DOCKERHUB_IMAGE}" >> "$GITHUB_ENV"
fi
env:
HAS_MODIFIED_DOCKERFILES: ${{ steps.changes.outputs.docker }}
DOCKER_NAME: ${{ matrix.docker.name }}
PREVIOUS_DOCKERHUB_IMAGE: ${{ matrix.docker.previousDockerhubImage }}
- name: Build Docker image
if: steps.changes.outputs.docker == 'true'
run: |
/bin/bash -x -c "cd metasploit-omnibus && docker build --tag ${DOCKER_IMAGE} -f ./docker/${IMAGE_NAME}/Dockerfile ./docker/${IMAGE_NAME}"
env:
IMAGE_NAME: ${{ matrix.docker.name }}
# Checkout again - but with the submodules enabled to start a real build
- name: Checkout omnibus and submodules
uses: actions/checkout@v4
with:
submodules: true
path: metasploit-omnibus
- name: Run omnibus
run: |
set -x
mkdir -p metasploit-omnibus/certs
curl -L -o metasploit-omnibus/certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem
# If required, change reported architecture in new program environment and set personality flags
if [ ! -z "${LINUX32}" ] ; then
echo 'setting linux32'
/bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} linux32 /bin/bash -l -c 'cd metasploit-omnibus && ARCH=x86_64 make'"
else
/bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} /bin/bash -l -c 'cd metasploit-omnibus && make'"
fi
env:
LINUX32: ${{ matrix.docker.linux32 }}
- name: Test artifact
run: |
echo "Testing artifact"
cat > test_script.sh <<EOF
#!/bin/bash -ex
find metasploit-omnibus/pkg
$INSTALL_ARTIFACT
mkdir ~/.msf4; touch ~/.msf4/initial_setup_complete
msfconsole -qx 'setg variable test; version; exit'
msfvenom -p windows/meterpreter/reverse_tcp -f exe -o test.exe
msfd -h
msfrpc -h
msfrpcd -h
msfdb -h
msfbinscan -h
msfrop -h
msfelfscan -h
msfmachscan -h
msfpescan -h
# msfupdate
EOF
chmod +x ./test_script.sh
# If required, change reported architecture in new program environment and set personality flags
if [ ! -z "${LINUX32}" ] ; then
echo 'setting linux32'
/bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} linux32 /bin/bash -l -c './test_script.sh'"
else
/bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} /bin/bash -l -c './test_script.sh'"
fi
env:
LINUX32: ${{ matrix.docker.linux32 }}
INSTALL_ARTIFACT: ${{ matrix.docker.installer }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: metasploit-${{ matrix.docker.name }}-installers
path: |
metasploit-omnibus/pkg/*.pkg
metasploit-omnibus/pkg/*.rpm
metasploit-omnibus/pkg/*.msi
metasploit-omnibus/pkg/*.deb
retention-days: 1
osx:
runs-on: ${{ matrix.os }}
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
os:
- macos-11
ruby:
- 3.0.6
name: ${{ matrix.os }}
steps:
- name: Checkout omnibus
uses: actions/checkout@v4
with:
submodules: true
path: metasploit-omnibus
- name: Setup Ruby
env:
BUNDLE_FORCE_RUBY_PLATFORM: true
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cache-version: 4
working-directory: metasploit-omnibus
- name: Run omnibus
run: |
sudo mkdir -p /var/cache/omnibus
sudo mkdir -p /opt/metasploit-framework
sudo chown `whoami` /var/cache/omnibus
sudo chown `whoami` /opt/metasploit-framework
cd metasploit-omnibus
make
- name: Test artifact
run: |
echo "Testing artifact"
sudo rm -rf /opt/metasploit-framework
/usr/bin/find metasploit-omnibus/pkg
PACKAGE=$(pwd)/$(/usr/bin/find metasploit-omnibus/pkg/metasploit*.pkg | head -n 1)
sudo installer -pkg ${PACKAGE} -target /
/opt/metasploit-framework/bin/msfconsole -qx 'setg variable test; version; exit'
/opt/metasploit-framework/bin/msfvenom -p windows/meterpreter/reverse_tcp -f exe -o test.exe
/opt/metasploit-framework/bin/msfd -h
/opt/metasploit-framework/bin/msfrpc -h
/opt/metasploit-framework/bin/msfrpcd -h
/opt/metasploit-framework/bin/msfdb -h
/opt/metasploit-framework/bin/msfbinscan -h
/opt/metasploit-framework/bin/msfrop -h
/opt/metasploit-framework/bin/msfelfscan -h
/opt/metasploit-framework/bin/msfmachscan -h
/opt/metasploit-framework/bin/msfpescan -h
# /opt/metasploit-framework/bin/msfupdate
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: metasploit-osx-installers
path: |
metasploit-omnibus/pkg/*.pkg
metasploit-omnibus/pkg/*.rpm
metasploit-omnibus/pkg/*.msi
metasploit-omnibus/pkg/*.deb
retention-days: 1
windows:
runs-on: ${{ matrix.os }}
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
os:
- windows-2022
ruby:
- 3.0.6
name: ${{ matrix.os }}
steps:
# https://github.com/actions/runner-images/issues/5143
# https://github.com/actions/runner-images/issues/9701
- name: Install visual studio components
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$componentsToRemove= @(
"Microsoft.VisualStudio.Component.VC.Redist.MSM"
)
[string]$workloadArgs = $componentsToRemove | ForEach-Object {" --add " + $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
# should be run twice
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
- name: Checkout omnibus
uses: actions/checkout@v4
with:
submodules: true
path: metasploit-omnibus
- name: Setup Ruby
env:
BUNDLE_FORCE_RUBY_PLATFORM: true
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: false
cache-version: 4
working-directory: metasploit-omnibus
# Github actions with Ruby requires Bundler 2.2.18+
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
bundler: 2.2.33
# If you need to build a custom version of pcaprub:
# - name: Checkout pcaprub
# uses: actions/checkout@v4
# with:
# repository: pcaprub/pcaprub
# path: pcaprub
# ref: '5440ca93dafd15e7d3bb009fc1bb9a15e80d03f9'
# - name: Create pcaprub gem
# run: |
# cd pcaprub
# bundle
# rake gem
# Checkout framework
- name: Checkout metasploit-framework code
uses: actions/checkout@v4
with:
repository: rapid7/metasploit-framework
path: metasploit-framework
- name: Extract xz files
run: |
cd metasploit-omnibus
xz -d local/cache/*.xz
ls local/cache
- name: Run omnibus
shell: cmd
env:
MSYSTEM: MINGW64
run: |
cd metasploit-omnibus
make dependencies
rem Don't run the main build itself under `make`, as the process will be spawned under msys2
rem and the ridk.cmd Ruby installer will forcibly kill the msys2 process before attempting to install ruby
ruby bin/omnibus build metasploit-framework
# Currently hangs on Github actions - but passes locally, potential cause within the debug.log file:
#
# Info 1603.The file C:\Windows\system32\vcruntime140_1.dll is being held in use. Close that application and retry.
#
# - name: Test artifact
# shell: pwsh
# run: |
# Set-PSDebug -Trace 1
# echo "Testing artifact"
# Remove-Item c:\metasploit-framework -Recurse -ErrorAction Ignore
# dir metasploit-omnibus\pkg
# echo '' > debug.log
# $artifact = (Get-ChildItem -Path "metasploit-omnibus/pkg/*.msi")[0].Name
# $install_process = Start-Process msiexec.exe -ArgumentList "/i metasploit-omnibus\pkg\$artifact /quiet /qn /l*v debug.log" -NoNewWindow -PassThru
# $log_process = Start-Process "powershell" "Get-Content -Path debug.log -Wait" -NoNewWindow -PassThru
# $install_process.WaitForExit()
# $log_process.Kill()
# echo "finished install"
# c:\metasploit-framework\bin\msfconsole -qx 'setg variable test; version; exit'
# c:\metasploit-framework\bin\msfvenom -p windows/meterpreter/reverse_tcp -f exe -o test.exe
# c:\metasploit-framework\bin\msfd -h
# c:\metasploit-framework\bin\msfrpc -h
# c:\metasploit-framework\bin\msfrpcd -h
# c:\metasploit-framework\bin\msfdb -h
# c:\metasploit-framework\bin\msfbinscan -h
# c:\metasploit-framework\bin\msfrop -h
# c:\metasploit-framework\bin\msfelfscan -h
# c:\metasploit-framework\bin\msfmachscan -h
# c:\metasploit-framework\bin\msfpescan -h
# c:\metasploit-framework\bin\msfupdate
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: metasploit-windows-installers
path: |
metasploit-omnibus/pkg/*.pkg
metasploit-omnibus/pkg/*.rpm
metasploit-omnibus/pkg/*.msi
metasploit-omnibus/pkg/*.deb
retention-days: 1