Skip to content

Commit

Permalink
Land #195, Add support for ruby 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
adfoster-r7 authored May 20, 2024
2 parents 44803b4 + b15a187 commit a7e39a6
Show file tree
Hide file tree
Showing 41 changed files with 1,004 additions and 183 deletions.
490 changes: 490 additions & 0 deletions .github/workflows/verify.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pkg/*
bin/*
files/**/cache/
vendor/cookbooks
certs
.idea

# RVM management
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.5
3.0.6
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

# Install omnibus
# gem 'omnibus', '~> 4.0'
gem 'omnibus', git: 'https://github.com/rapid7/omnibus', branch: 'r7_8.2.4_custom'
gem 'omnibus', git: 'https://github.com/rapid7/omnibus', branch: 'r7_9.0.23_custom'

# Use Chef's software definitions. It is recommended that you write your own
# software definitions, but you can clone/fork Chef's to get you started.
Expand Down
112 changes: 58 additions & 54 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,124 +1,128 @@
GIT
remote: https://github.com/rapid7/omnibus
revision: 5b238e62088797782f6b7ca1ddda3a0e7128c224
branch: r7_8.2.4_custom
revision: c6dc312d985e85fb35b8e9f8e49b607abd91665c
branch: r7_9.0.23_custom
specs:
omnibus (8.2.4)
aws-sdk-s3 (~> 1)
omnibus (9.0.23)
aws-sdk-s3 (~> 1.116.0)
chef-cleanroom (~> 1.0)
chef-utils (>= 15.4)
contracts (>= 0.16.0, < 0.17.0)
ffi-yajl (~> 2.2)
license_scout (~> 1.0)
mixlib-shellout (>= 2.0, < 4.0)
mixlib-versioning
ohai (>= 15, < 17)
ohai (>= 16, < 19)
pedump
rexml (~> 3.2)
ruby-progressbar (~> 1.7)
thor (>= 0.18, < 2.0)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
awesome_print (1.9.2)
aws-eventstream (1.2.0)
aws-partitions (1.522.0)
aws-sdk-core (3.121.5)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.520.1)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.50.0)
aws-sdk-core (~> 3, >= 3.121.2)
aws-eventstream (1.3.0)
aws-partitions (1.916.0)
aws-sdk-core (3.192.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.79.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.104.0)
aws-sdk-core (~> 3, >= 3.121.2)
aws-sdk-s3 (1.116.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.4.0)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
byebug (11.1.3)
chef-cleanroom (1.0.4)
chef-config (16.16.13)
chef-cleanroom (1.0.5)
chef-config (18.4.12)
addressable
chef-utils (= 16.16.13)
chef-utils (= 18.4.12)
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
tomlrb (~> 1.2)
chef-utils (16.16.13)
chef-utils (18.4.12)
concurrent-ruby
citrus (3.0.2)
coderay (1.1.3)
concurrent-ruby (1.2.3)
contracts (0.16.1)
ffi (1.15.4)
ffi-yajl (2.4.0)
ffi (1.16.3)
ffi-yajl (2.6.0)
libyajl2 (>= 1.2)
fuzzyurl (0.9.0)
iostruct (0.0.4)
iostruct (0.0.5)
ipaddress (0.8.3)
jmespath (1.6.2)
json (2.6.1)
json (2.7.2)
libyajl2 (2.1.0)
license_scout (1.2.13)
license_scout (1.3.7)
ffi-yajl (~> 2.2)
mixlib-shellout (>= 2.2, < 4.0)
toml-rb (>= 1, < 3)
method_source (1.0.0)
mixlib-cli (2.1.8)
mixlib-config (3.0.9)
mixlib-config (3.0.27)
tomlrb
mixlib-log (3.0.9)
mixlib-shellout (3.2.5)
mixlib-shellout (3.2.7)
chef-utils
mixlib-versioning (1.2.12)
multipart-post (2.1.1)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
ohai (16.13.0)
chef-config (>= 12.8, < 17)
chef-utils (>= 16.0, < 17)
multipart-post (2.4.0)
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-ssh (7.2.3)
ohai (18.1.3)
chef-config (>= 14.12, < 19)
chef-utils (>= 16.0, < 19)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
ipaddress
mixlib-cli (>= 1.7.0)
mixlib-config (>= 2.0, < 4.0)
mixlib-log (>= 2.0.1, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
mixlib-shellout (~> 3.2, >= 3.2.5)
plist (~> 3.1)
train-core
wmi-lite (~> 1.0)
pedump (0.6.2)
pedump (0.6.7)
awesome_print
iostruct (>= 0.0.4)
multipart-post (>= 2.0.0)
rainbow
zhexdump (>= 0.0.2)
plist (3.6.0)
pry (0.13.1)
plist (3.7.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.6)
rainbow (3.0.0)
ruby-progressbar (1.11.0)
thor (1.1.0)
toml-rb (2.1.0)
pry (>= 0.13, < 0.15)
public_suffix (5.0.5)
rainbow (3.1.1)
rexml (3.2.6)
ruby-progressbar (1.13.0)
thor (1.3.1)
toml-rb (2.2.0)
citrus (~> 3.0, > 3.0)
tomlrb (1.3.0)
train-core (3.8.1)
train-core (3.12.3)
addressable (~> 2.5)
ffi (!= 1.13.0)
json (>= 1.8, < 3.0)
mixlib-shellout (>= 2.0, < 4.0)
net-scp (>= 1.2, < 4.0)
net-ssh (>= 2.9, < 7.0)
wmi-lite (1.0.5)
zhexdump (0.0.2)
net-scp (>= 1.2, < 5.0)
net-ssh (>= 2.9, < 8.0)
wmi-lite (1.0.7)
zhexdump (0.1.0)

PLATFORMS
ruby
Expand All @@ -128,4 +132,4 @@ DEPENDENCIES
pry-byebug

BUNDLED WITH
2.1.4
2.2.33
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.DEFAULT_GOAL := all

.PHONY: all
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

# install omnibus' dependencies
bundle install
bundle binstubs --all

gem install win32-process -v 0.9.0

certs/ca-certificates.crt:
mkdir -p certs
curl -L -o certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem

.PHONY: clean
clean:
bin/omnibus clean metasploit-framework
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ You can build images yourself:
```shell
git clone https://github.com/rapid7/metasploit-omnibus.git
cd metasploit-omnibus
docker build --tag metasploit-omnibus-builder - < ./docker/kali109-x64/Dockerfile
docker build --tag metasploit-omnibus-builder - < ./docker/ubuntu1204-x86/Dockerfile
```

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/msf-IMAGE_NAME-omnibus:$BUILD_DATE -f ./docker/IMAGE_NAME/Dockerfile ./docker/IMAGE_NAME"
```

Pushing

```shell
export BUILD_DATE=$(date "+%Y_%m"); ls ./docker | xargs -I IMAGE_NAME /bin/bash -x -c "docker push rapid7/msf-IMAGE_NAME-omnibus:$BUILD_DATE"
```

You can then run a new container using the above tagged image, whilst mounting the current directory as a volume:
Expand All @@ -38,15 +50,15 @@ docker run -it --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins metas
Or you can run a new container using pre-built images from [Rapid7's Docker Hub account](https://hub.docker.com/u/rapid7):

```shell
docker run -it --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins rapid7/msf-kali109-x64-omnibus:2019_01 /bin/bash --login
docker run -it --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins rapid7/msf-ubuntu1204-x86-omnibus:2021_11 /bin/bash --login
```

By default, `metasploit-omnibus` will download the latest version of Metasploit framework from Github, but also supports building with local copies from `/metasploit-framework` - [full details](https://github.com/rapid7/metasploit-omnibus/blob/9cd575bcdd19d8fedf4a94c4ca2d1d6c253628c2/config/software/metasploit-framework.rb#L2-L8).

To build omnibus with a local version of Metasploit framework, you can mount your framework repository as a volume to `/metasploit-framework` within the container. The following command assumes that the repository exists within the parent directory:

```shell
docker run -it --rm --volume $(pwd):$(pwd) --volume=$(pwd)/../metasploit-framework:/metasploit-framework --workdir $(pwd) --user jenkins rapid7/msf-kali109-x64-omnibus:2019_01 /bin/bash --login
docker run -it --rm --volume $(pwd):$(pwd) --volume=$(pwd)/../metasploit-framework:/metasploit-framework --workdir $(pwd) --user jenkins rapid7/msf-ubuntu1204-x86-omnibus:2021_11 /bin/bash --login
```

When running inside the container, you can perform a normal ommibus build:
Expand All @@ -56,13 +68,24 @@ When running inside the container, you can perform a normal ommibus build:
git submodule update -i
# install omnibus' dependencies
bundle install --binstubs
bundle install
bundle binstubs --all
# build the metasploit-framework package
bin/omnibus build metasploit-framework
```

When complete, there will be a new installable .deb file under the 'pkg' directory. Note that the use of Docker volumes may cause builds to run slower.
When complete, there will be a new installable `.deb` file under the 'pkg' directory. Note that the use of Docker volumes may cause builds to run slower.

To test the `.deb` file, install it - and then open msfconsole:

```
# install
sudo dpkg -i pkg/metasploit-framework_6.3.39~20231017232715.git.3.47e0cd3~1rapid7-1_amd64.deb
# Run to verify
msfconsole
```

## Building on Ubuntu / Debian systems

Expand Down Expand Up @@ -96,7 +119,7 @@ Checkout the metasploit-framework installer builder and install omnibus' depende
git clone https://github.com/rapid7/metasploit-omnibus.git
cd metasploit-omnibus
# install omnibus' dependencies
bundle install --binstubs
bundle install && bundle binstubs --all
```

Finally, build the installer itself:
Expand All @@ -111,7 +134,7 @@ when complete, there will be a new installable .deb file under the 'pkg' directo
From Windows 10, install ruby, msys2, ruby-devkit, wixtoolset, git. Add the following command to the the preparation steps before executing the `build` command.
```
xz -d local/cache/*.xz
```
```

## Building on OS X

Expand Down
10 changes: 10 additions & 0 deletions config/patches/metasploit-framework/bundler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/Gemfile.lock b/Gemfile.lock
index 6802316759..89aaddd322 100644
--- Gemfile.lock 2024-05-17 12:32:16
+++ Gemfile.lock 2024-05-17 12:32:59
@@ -574,4 +574,4 @@
yard

BUNDLED WITH
- 2.1.4
+ 2.5.10
16 changes: 16 additions & 0 deletions config/patches/ruby/ruby-fast-load_31.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/load.c b/load.c
index a2b9da4..05ea96e 100644
--- a/load.c
+++ b/load.c
@@ -981,6 +981,11 @@ search_required(rb_vm_t *vm, VALUE fname, volatile VALUE *path, feature_func rb_
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 'r';
}
+ else if ((ft = rb_feature_p(vm, ftptr, 0, FALSE, FALSE, &loading)) == 's') {
+ if (loading) *path = rb_filesystem_str_new_cstr(loading);
+ return 's';
+ }
+
tmp = fname;
type = rb_find_file_ext(&tmp, ft == 's' ? ruby_ext : loadable_ext);
switch (type) {
24 changes: 24 additions & 0 deletions config/patches/rubygems/rubygems-3.5.10.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 48b7344aee..08728c209c 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true

-require_relative "deprecate"
-
##
# Available list of platforms for targeting Gem installations.
#
@@ -24,11 +22,6 @@ def self.match(platform)
match_platforms?(platform, Gem.platforms)
end

- class << self
- extend Gem::Deprecate
- rubygems_deprecate :match, "Gem::Platform.match_spec? or match_gem?"
- end
-
def self.match_platforms?(platform, platforms)
platform = Gem::Platform.new(platform) unless platform.is_a?(Gem::Platform)
platforms.any? do |local_platform|
1 change: 1 addition & 0 deletions config/projects/metasploit-framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

install_dir "#{default_root}/metasploit-framework"

# Version is extracted from the latest Git tag found in the local Git repository
build_version Omnibus::BuildVersion.semver + "-1rapid7"
build_iteration 1

Expand Down
Loading

0 comments on commit a7e39a6

Please sign in to comment.