Skip to content

Commit 70e4edb

Browse files
committed
Run under cmd prompt
1 parent 0012375 commit 70e4edb

File tree

7 files changed

+80
-12
lines changed

7 files changed

+80
-12
lines changed

.github/workflows/verify.yml

+42-2
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,29 @@ jobs:
263263
fail-fast: false
264264
matrix:
265265
os:
266-
- windows-2019
266+
- windows-2022
267267
ruby:
268268
- 3.0.6
269269

270270
name: ${{ matrix.os }}
271271
steps:
272+
# https://github.com/actions/runner-images/issues/5143
273+
# https://github.com/actions/runner-images/issues/9701
274+
- name: Install components
275+
run: |
276+
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
277+
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
278+
vs_installer.exe modify --installPath "$InstallPath" --add Microsoft.VisualStudio.Component.VC.Redist.MSM --norestart --nocache
279+
280+
echo "check program dir"
281+
get-childitem -recurse -path '*.msm'
282+
283+
echo "check install path"
284+
Set-Location $InstallPath
285+
get-childitem -recurse -path '*.msm'
286+
287+
288+
272289
- name: Checkout omnibus
273290
uses: actions/checkout@v4
274291
with:
@@ -288,6 +305,20 @@ jobs:
288305
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
289306
bundler: 2.2.33
290307

308+
# TODO: Comment
309+
- name: Checkout pcaprub
310+
uses: actions/checkout@v4
311+
with:
312+
repository: pcaprub/pcaprub
313+
path: pcaprub
314+
ref: '5440ca93dafd15e7d3bb009fc1bb9a15e80d03f9'
315+
316+
- name: Compile pcaprub
317+
run: |
318+
cd pcaprub
319+
bundle
320+
rake gem
321+
291322
# Checkout framework
292323
- name: Checkout metasploit-framework code
293324
uses: actions/checkout@v4
@@ -302,6 +333,15 @@ jobs:
302333
ls local/cache
303334
304335
- name: Run omnibus
336+
shell: cmd
337+
env:
338+
MSYSTEM: MINGW64
305339
run: |
306340
cd metasploit-omnibus
307-
make
341+
342+
rem Don't run via `make`, as the process will be spawned under msys2 - and the ridk.cmd
343+
rem ruby installer will forcibly kill the msys2 process before attempting to install ruby
344+
make dependencies
345+
346+
rem build the metasploit-framework package
347+
ruby bin/omnibus build metasploit-framework

Makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
.DEFAULT_GOAL := all
22

33
.PHONY: all
4-
all: certs/ca-certificates.crt
4+
all: certs/ca-certificates.crt dependencies
55
# export SSL_CERT_FILE=${PWD}/certs/ca-certificates.crt
6+
7+
# build the metasploit-framework package
8+
ruby bin/omnibus build metasploit-framework
9+
10+
.PHONY: dependencies
11+
dependencies:
612
# Ensure consistent bundler versions
713
gem install bundler -v 2.2.3
814

@@ -12,9 +18,6 @@ all: certs/ca-certificates.crt
1218

1319
gem install win32-process -v 0.9.0
1420

15-
# build the metasploit-framework package
16-
ruby bin/omnibus build metasploit-framework
17-
1821
certs/ca-certificates.crt:
1922
mkdir -p certs
2023
curl -L -o certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ docker build --tag metasploit-omnibus-builder - < ./docker/ubuntu1204-x86/Docker
3232
Or on OSX you can use the following script to build all images following the latest Docker image naming convention:
3333

3434
```shell
35-
export BUILD_DATE=$(date "+%Y_%m"); ls ./docker | xargs -I IMAGE_NAME /bin/bash -x -c "docker build --tag rapid7/IMAGE_NAME-omnibus:$BUILD_DATE -f ./docker/IMAGE_NAME/Dockerfile ./docker/IMAGE_NAME"
35+
export BUILD_DATE=$(date "+%Y_%m_%d"); ls ./docker | xargs -I IMAGE_NAME /bin/bash -x -c "docker build --tag rapid7/IMAGE_NAME-omnibus:$BUILD_DATE -f ./docker/IMAGE_NAME/Dockerfile ./docker/IMAGE_NAME"
3636
```
3737

3838
You can then run a new container using the above tagged image, whilst mounting the current directory as a volume:

config/software/metasploit-framework.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
end
8181

8282
bundle "config set force_ruby_platform true", env: env
83-
bundle "install", env: env
83+
bundle_env = with_standard_compiler_flags(with_embedded_path)
84+
bundle_env['MAKE'] = 'make -j4'
85+
bundle "install --jobs=4", env: bundle_env
8486

8587
if windows?
8688
delete "#{install_dir}/embedded/msys64"

config/software/pcaprub.rb

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
name "pcaprub"
18-
default_version "0.12.4"
18+
default_version "0.13.1"
1919

2020
if windows?
2121
dependency "ruby-windows"
@@ -32,6 +32,16 @@
3232
build do
3333
env = with_standard_compiler_flags(with_embedded_path)
3434
env['SSL_CERT_FILE'] = "#{install_dir}/embedded/ssl/cert.pem"
35-
gem "install pcaprub" \
36-
" --version '#{version}' --no-document", env: env
35+
36+
# Use version of pcaprub relative to the current directory
37+
local_pcaprub_checkout = File.expand_path(File.join(Dir.pwd, "..", "pcaprub"))
38+
command "echo checking for path: #{local_pcaprub_checkout}", env: env
39+
if File.exist?(local_pcaprub_checkout)
40+
gem "install --local #{local_pcaprub_checkout}/pkg/pcaprub-#{version}.gem", env: env
41+
command "echo after new pcaprub code", env: env
42+
else
43+
command "echo before old pcaprub code", env: env
44+
gem "install pcaprub" \
45+
" --version '#{version}' --no-document", env: env
46+
end
3747
end

config/software/ruby-windows-devkit.rb

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
embedded_dir = "#{install_dir}/embedded"
2929

3030
command "echo before!", env: env, cwd: embedded_dir
31+
# Ruby Installer for windows:
32+
# 1 - MSYS2 base installation
33+
# 2 - MSYS2 system update (optional)
34+
# 3 - MSYS2 and MINGW development toolchain
3135
command "#{embedded_dir}/bin/ridk.cmd install 2 3", env: env, cwd: embedded_dir
3236
command "echo after!", env: env, cwd: embedded_dir
3337
end

resources/metasploit-framework/msi/source.wxs.erb

+10-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@
7676
</Directory>
7777
</Directory>
7878
</Directory>
79-
<Merge Id="CRT" Language="0" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\microsoft_vc120_crt_x64.msm" DiskId="1" />
79+
<!--
80+
The following shell command exited with status 103:
81+
$ light.exe -nologo -sval -ext WixUIExtension -cultures:en-us -loc "D:\a\_temp\metasploit-framework20240418-1808-v6mss1\localization-en-us.wxl" project-files.wixobj source.wixobj -out "C:\omnibus-ruby\pkg\metasploit-framework-0.0.0-20240418232212-1rapid7-1-x64.msi"
82+
Output:
83+
D:\a\_temp\metasploit-framework20240418-1808-v6mss1\source.wxs(79) : error LGHT0103 : The system cannot find the file 'C:\Program Files (x86)\Common Files\Merge Modules\microsoft_vc120_crt_x64.msm'.
84+
Error:
85+
(nothing)
86+
-->
87+
<!-- <Merge Id="CRT" Language="0" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\microsoft_vc120_crt_x64.msm" DiskId="1" /> -->
88+
<Merge Id="CRT" Language="0" SourceFile="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Merge Modules\microsoft_vc120_crt_x64.msm" DiskId="1" />
8089
</Directory>
8190

8291
<SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]" />

0 commit comments

Comments
 (0)