Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Ruby 3.3 #18668

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- '3.0'
- '3.1'
- '3.2'
- '3.3.0-preview3'
- '3.3'
os:
- ubuntu-20.04
- ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PATH
net-ssh
network_interface
nexpose
nokogiri (~> 1.14.0)
nokogiri
octokit (~> 4.0)
openssl-ccm
openvas-omp
Expand Down Expand Up @@ -295,7 +295,7 @@ GEM
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.1003)
mini_portile2 (2.8.4)
mini_portile2 (2.8.5)
minitest (5.20.0)
mqtt (0.6.0)
msgpack (1.6.1)
Expand All @@ -315,8 +315,8 @@ GEM
network_interface (0.0.4)
nexpose (7.3.0)
nio4r (2.5.9)
nokogiri (1.14.5)
mini_portile2 (~> 2.8.0)
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nori (2.6.0)
octokit (4.25.1)
Expand Down Expand Up @@ -349,7 +349,7 @@ GEM
public_suffix (5.0.3)
puma (6.4.0)
nio4r (~> 2.0)
racc (1.7.1)
racc (1.7.3)
rack (2.2.8)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
Expand Down Expand Up @@ -496,7 +496,7 @@ GEM
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.1.0)
tilt (~> 2.0)
sqlite3 (1.6.6)
sqlite3 (1.7.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mini_portile2 (~> 2.8.0)
sshkey (3.0.0)
strptime (0.2.5)
Expand Down
3 changes: 1 addition & 2 deletions metasploit-framework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ Gem::Specification.new do |spec|
# NTLM authentication
spec.add_runtime_dependency 'rubyntlm'
# Needed by anemone crawler
# Locked until build env can handle newer version due to native compile issue in 1.15.x
spec.add_runtime_dependency 'nokogiri', '~> 1.14.0'
spec.add_runtime_dependency 'nokogiri'
Copy link
Contributor Author

@adfoster-r7 adfoster-r7 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nokogiri v16 is required for Ruby 3.3 support

But it looks like this was pinned previously by #18103 when there were issues with compiling the nightly omnibus installers with older. Before we merge this, we'll need to manually rebuild the omnibus installer to see if the previous issues are resolved or not, as it looks like some changes have been made to how they handle libxml

# Needed by db.rb and Msf::Exploit::Capture
spec.add_runtime_dependency 'packetfu'
# For sniffer and raw socket modules
Expand Down
6 changes: 5 additions & 1 deletion modules/payloads/singles/linux/mipsbe/exec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: binary -*-

##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
Expand Down Expand Up @@ -70,7 +72,9 @@ def generate(_opts = {})
shellcode = shellcode + command_string + "\x00"

# we need to align our shellcode to 4 bytes
(shellcode = shellcode + "\x00") while shellcode.length%4 != 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a weird behaviour change here between ruby versions:

shellcode = ""

(shellcode = shellcode + "\x00") while shellcode.bytesize%4 != 0

puts RUBY_DESCRIPTION
puts shellcode.bytesize

Ruby 3.0:

$ ruby foo.rb       
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
0

Ruby 3.3:

$ ruby foo.rb
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is fixed in the head of Ruby now; Will leave it as-is

while shellcode.bytesize%4 != 0
shellcode = shellcode + "\x00"
end

return super + shellcode

Expand Down
6 changes: 5 additions & 1 deletion modules/payloads/singles/linux/mipsle/exec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: binary -*-

##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
Expand Down Expand Up @@ -71,7 +73,9 @@ def generate(_opts = {})
shellcode = shellcode + command_string + "\x00"

# we need to align our shellcode to 4 bytes
(shellcode = shellcode + "\x00") while shellcode.length%4 != 0
while shellcode.bytesize%4 != 0
shellcode = shellcode + "\x00"
end

return super + shellcode

Expand Down
Loading