Skip to content

Commit

Permalink
Run under cmd prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
adfoster-r7 committed Apr 19, 2024
1 parent 0012375 commit d4942ef
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 12 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,19 @@ 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 components
run: |
cmd.exe /c vs_installer.exe modify --installPath "$InstallPath" --add Microsoft.VisualStudio.Component.VC.Redist.MSM --norestart --nocache
cmd.exe /c vs_installer.exe modify --installPath "$InstallPath" --add Microsoft.VisualStudio.Component.VC.Redist.MSM --norestart --nocache
- name: Checkout omnibus
uses: actions/checkout@v4
with:
Expand All @@ -288,6 +295,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
Expand All @@ -302,6 +323,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
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion config/software/metasploit-framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 13 additions & 3 deletions config/software/pcaprub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

name "pcaprub"
default_version "0.12.4"
default_version "0.13.1"

if windows?
dependency "ruby-windows"
Expand All @@ -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
4 changes: 4 additions & 0 deletions config/software/ruby-windows-devkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion resources/metasploit-framework/msi/source.wxs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@
</Directory>
</Directory>
</Directory>
<Merge Id="CRT" Language="0" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\microsoft_vc120_crt_x64.msm" DiskId="1" />
<!--
The following shell command exited with status 103:
$ 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"
Output:
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'.
Error:
(nothing)
-->
<!-- <Merge Id="CRT" Language="0" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\microsoft_vc120_crt_x64.msm" DiskId="1" /> -->
<Merge Id="CRT" Language="0" SourceFile="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Merge Modules\microsoft_vc120_crt_x64.msm" DiskId="1" />
</Directory>

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

0 comments on commit d4942ef

Please sign in to comment.