diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml
index b7e697a1..622c475f 100644
--- a/.github/workflows/verify.yml
+++ b/.github/workflows/verify.yml
@@ -263,12 +263,27 @@ jobs:
fail-fast: false
matrix:
os:
- - windows-2019
+ - 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:
@@ -288,6 +303,20 @@ jobs:
# https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
bundler: 2.2.33
+ # TODO: Comment
+ - name: Checkout pcaprub
+ uses: actions/checkout@v4
+ with:
+ repository: pcaprub/pcaprub
+ path: pcaprub
+ ref: '5440ca93dafd15e7d3bb009fc1bb9a15e80d03f9'
+
+ - name: Compile pcaprub
+ run: |
+ cd pcaprub
+ bundle
+ rake gem
+
# Checkout framework
- name: Checkout metasploit-framework code
uses: actions/checkout@v4
@@ -302,6 +331,15 @@ jobs:
ls local/cache
- name: Run omnibus
+ shell: cmd
+ env:
+ MSYSTEM: MINGW64
run: |
cd metasploit-omnibus
- make
+
+ rem Don't run via `make`, as the process will be spawned under msys2 - and the ridk.cmd
+ rem ruby installer will forcibly kill the msys2 process before attempting to install ruby
+ make dependencies
+
+ rem build the metasploit-framework package
+ ruby bin/omnibus build metasploit-framework
diff --git a/Makefile b/Makefile
index 92cdd1eb..d1682201 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,14 @@
.DEFAULT_GOAL := all
.PHONY: all
-all: certs/ca-certificates.crt
+all: certs/ca-certificates.crt dependencies
# export SSL_CERT_FILE=${PWD}/certs/ca-certificates.crt
+
+ # build the metasploit-framework package
+ ruby bin/omnibus build metasploit-framework
+
+.PHONY: dependencies
+dependencies:
# Ensure consistent bundler versions
gem install bundler -v 2.2.3
@@ -12,9 +18,6 @@ all: certs/ca-certificates.crt
gem install win32-process -v 0.9.0
- # build the metasploit-framework package
- ruby bin/omnibus build metasploit-framework
-
certs/ca-certificates.crt:
mkdir -p certs
curl -L -o certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem
diff --git a/README.md b/README.md
index 183c9c20..07c38373 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ docker build --tag metasploit-omnibus-builder - < ./docker/ubuntu1204-x86/Docker
Or on OSX you can use the following script to build all images following the latest Docker image naming convention:
```shell
-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"
+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"
```
You can then run a new container using the above tagged image, whilst mounting the current directory as a volume:
diff --git a/config/software/metasploit-framework.rb b/config/software/metasploit-framework.rb
index b4737b15..438c2f55 100644
--- a/config/software/metasploit-framework.rb
+++ b/config/software/metasploit-framework.rb
@@ -80,7 +80,9 @@
end
bundle "config set force_ruby_platform true", env: env
- bundle "install", env: env
+ bundle_env = with_standard_compiler_flags(with_embedded_path)
+ bundle_env['MAKE'] = 'make -j4'
+ bundle "install --jobs=4", env: bundle_env
if windows?
delete "#{install_dir}/embedded/msys64"
diff --git a/config/software/pcaprub.rb b/config/software/pcaprub.rb
index f5b9dc56..5e7d2ddb 100644
--- a/config/software/pcaprub.rb
+++ b/config/software/pcaprub.rb
@@ -15,7 +15,7 @@
#
name "pcaprub"
-default_version "0.12.4"
+default_version "0.13.1"
if windows?
dependency "ruby-windows"
@@ -32,6 +32,16 @@
build do
env = with_standard_compiler_flags(with_embedded_path)
env['SSL_CERT_FILE'] = "#{install_dir}/embedded/ssl/cert.pem"
- gem "install pcaprub" \
- " --version '#{version}' --no-document", env: env
+
+ # Use version of pcaprub relative to the current directory
+ local_pcaprub_checkout = File.expand_path(File.join(Dir.pwd, "..", "pcaprub"))
+ command "echo checking for path: #{local_pcaprub_checkout}", env: env
+ if File.exist?(local_pcaprub_checkout)
+ gem "install --local #{local_pcaprub_checkout}/pkg/pcaprub-#{version}.gem", env: env
+ command "echo after new pcaprub code", env: env
+ else
+ command "echo before old pcaprub code", env: env
+ gem "install pcaprub" \
+ " --version '#{version}' --no-document", env: env
+ end
end
diff --git a/config/software/ruby-windows-devkit.rb b/config/software/ruby-windows-devkit.rb
index 61cce00b..33e9b892 100644
--- a/config/software/ruby-windows-devkit.rb
+++ b/config/software/ruby-windows-devkit.rb
@@ -28,6 +28,10 @@
embedded_dir = "#{install_dir}/embedded"
command "echo before!", env: env, cwd: embedded_dir
+ # Ruby Installer for windows:
+ # 1 - MSYS2 base installation
+ # 2 - MSYS2 system update (optional)
+ # 3 - MSYS2 and MINGW development toolchain
command "#{embedded_dir}/bin/ridk.cmd install 2 3", env: env, cwd: embedded_dir
command "echo after!", env: env, cwd: embedded_dir
end
diff --git a/resources/metasploit-framework/msi/source.wxs.erb b/resources/metasploit-framework/msi/source.wxs.erb
index def052f8..3e76ccf2 100644
--- a/resources/metasploit-framework/msi/source.wxs.erb
+++ b/resources/metasploit-framework/msi/source.wxs.erb
@@ -76,7 +76,33 @@
-
+
+
+ <%
+ # https://learn.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=msvc-170
+ # In Visual Studio 2022 and 2019, merge module files are part of an optional installable component named C++
+ # Redistributable MSMs in the Visual Studio Installer. The merge modules are installed by default as part of a C++ install
+ # in Visual Studio 2017 and Visual Studio 2015. When installed in Visual Studio 2022, you'll find the redistributable
+ # merge modules in %VCINSTALLDIR%Redist\MSVC\v143\MergeModules. In the latest version of Visual Studio 2019, the redistributable
+ # merge modules are in %VCINSTALLDIR%Redist\MSVC\v142\MergeModules. In both Visual Studio 2019 and Visual Studio 2017, they're
+ # also found in %VCToolsRedistDir%MergeModules. In Visual Studio 2015, they're found in Program Files [(x86)]\Common Files\Merge Modules.
+ possible_crt_paths = [
+ # Visual studio 2022 enterprise - when installed with vs_installer.exe
+ 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\v143\MergeModules\Microsoft_VC143_CRT_x64.msm',
+ # Visual studio 2013 default install
+ 'C:\Program Files (x86)\Common Files\Merge Modules\microsoft_vc120_crt_x64.msm'
+ ]
+ crt_path = possible_crt_paths.find { |path| File.exist?(path) }
+ raise "Could not find valid CRT path - tried #{possible_crt_paths.join(", ")}." if crt_path.nil?
+ %>
+