Skip to content
Open
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
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ GEM
mutex_m
railties (~> 7.0)
zeitwerk
metasploit-credential (6.0.21)
metasploit-credential (6.0.23)
bigdecimal
csv
drb
Expand All @@ -353,17 +353,17 @@ GEM
mutex_m
railties (~> 7.0)
metasploit-payloads (2.0.245)
metasploit_data_models (6.0.15)
activerecord (~> 7.0)
activesupport (~> 7.0)
metasploit_data_models (6.0.18)
activerecord (>= 7.0, < 8.1)
activesupport (>= 7.0, < 8.1)
arel-helpers
bigdecimal
drb
metasploit-concern
metasploit-model (~> 5.0.4)
metasploit-model (>= 5.0.4)
mutex_m
pg
railties (~> 7.0)
railties (>= 7.0, < 8.1)
recog
webrick
metasploit_payloads-mettle (1.0.46)
Expand Down Expand Up @@ -498,7 +498,7 @@ GEM
rex-struct2
rex-text
rex-core (0.1.36)
rex-encoder (0.1.8)
rex-encoder (0.1.10)
metasm
rex-arch
rex-text
Expand Down Expand Up @@ -531,7 +531,7 @@ GEM
metasm
rex-core
rex-text
rex-socket (0.1.64)
rex-socket (0.1.65)
dnsruby
rex-core
rex-sslscan (0.1.13)
Expand Down
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2026_01_30_124052) do
ActiveRecord::Schema[7.2].define(version: 2026_04_11_000000) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -665,6 +665,8 @@
t.integer "session_id"
t.integer "loot_id"
t.text "fail_detail"
t.string "check_code"
t.text "check_detail"
end

create_table "vuln_details", id: :serial, force: :cascade do |t|
Expand Down
6 changes: 0 additions & 6 deletions lib/metasploit/framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
#

require 'active_support'
require 'bcrypt'
require 'json'
require 'msgpack'
require 'metasploit/credential'
require 'nokogiri'
# railties has not autorequire defined
# rkelly-remix is a fork of rkelly, so it's autorequire is 'rkelly' and not 'rkelly-remix'
require 'rkelly'
require 'robots'
require 'zip'
require 'msf'
#
# Project
Expand Down
1 change: 0 additions & 1 deletion lib/msf/core/db_manager/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'bcrypt'
require 'securerandom'

module Msf::DBManager::User
Expand Down
2 changes: 0 additions & 2 deletions lib/msf/core/exe/segment_appender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
module Msf
module Exe

require 'metasm'

class SegmentAppender < SegmentInjector

def payload_stub(prefix)
Expand Down
2 changes: 0 additions & 2 deletions lib/msf/core/exe/segment_injector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
module Msf
module Exe

require 'metasm'

class SegmentInjector

attr_accessor :payload
Expand Down
1 change: 0 additions & 1 deletion lib/msf/core/exploit/remote/smb/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: binary -*-
require 'rex/encoder/ndr'
require 'recog'

module Msf
module Exploit::Remote::SMB
Expand Down
1 change: 0 additions & 1 deletion lib/msf/core/payload.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: binary -*-
require 'metasm'

module Msf

Expand Down
3 changes: 2 additions & 1 deletion lib/msf/util/document_generator/pull_request_finder.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'octokit'
require 'nokogiri'
require 'net/http'

Expand Down Expand Up @@ -39,6 +38,8 @@ def initialize
raise PullRequestFinder::Exception, 'GITHUB_OAUTH_TOKEN environment variable not set.'
end

require 'octokit'

self.owner = 'rapid7'
self.repository = "#{owner}/metasploit-framework"
self.branch = 'master'
Expand Down
1 change: 0 additions & 1 deletion lib/msf/util/exe/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Msf::Util::EXE::Common
require 'rex/random_identifier'
require 'rex/zip'
require 'rex/powershell'
require 'metasm'
require 'digest/sha1'

def self.included(base)
Expand Down
5 changes: 5 additions & 0 deletions lib/msf_autoload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,16 @@ def finalize_loader(loader)
end

# global autoload of common gems
autoload :BCrypt, 'bcrypt'
autoload :Dnsruby, 'dnsruby'
autoload :Faker, 'faker'
autoload :BinData, 'bindata'
autoload :Metasm, 'metasm'
autoload :Recog, 'recog'
autoload :RubySMB, 'ruby_smb'
autoload :MetasploitPayloads, 'metasploit-payloads'
autoload :PacketFu, 'packetfu'
autoload :Zip, 'zip'
autoload :DidYouMean, 'did_you_mean'

require 'rexml/document'
Expand Down
32 changes: 20 additions & 12 deletions lib/rex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
module Rex
Root = File.join(File.expand_path(File.dirname(__FILE__)), 'rex')
LogSource = "rex"

# library for creating Powershell scripts for exploitation purposes
autoload :Powershell, 'rex/powershell'
# Library for working with OLE
autoload :OLE, 'rex/ole'
# Library for creating and/or parsing MIME messages
autoload :MIME, 'rex/mime'
# Exploit Helper Library
autoload :Exploitation, 'rex/exploitation'
# Binary parsing tools (PE, ELF, Mach-O)
autoload :BinTools, 'rex/bin_tools'
autoload :PeParsey, 'rex/peparsey'
autoload :PeScan, 'rex/pescan'
autoload :ElfParsey, 'rex/elfparsey'
autoload :ElfScan, 'rex/elfscan'
autoload :MachParsey, 'rex/machparsey'
autoload :MachScan, 'rex/machscan'
autoload :ImageSource, 'rex/image_source'
# SSLScan
autoload :SSLScan, 'rex/sslscan/scanner'
end

#
Expand All @@ -13,8 +33,6 @@ module Rex
require 'rex/text'
# Library for Generating Randomized strings valid as Identifiers such as variable names
require 'rex/random_identifier'
# library for creating Powershell scripts for exploitation purposes
require 'rex/powershell'
# Library for processing and creating Zip compatible archives
require 'rex/zip'
# Library for parsing offline Windows Registry files
Expand All @@ -23,16 +41,10 @@ module Rex
require 'rex/java'
# Library for creating C-style Structs
require 'rex/struct2'
# Library for working with OLE
require 'rex/ole'
# Library for creating and/or parsing MIME messages
require 'rex/mime'
# Library for polymorphic encoders
require 'rex/encoder'
# Architecture subsystem
require 'rex/arch'
# Exploit Helper Library
require 'rex/exploitation'

# Generic classes
require 'rex/file'
Expand All @@ -57,10 +69,6 @@ module Rex
# Compatibility
require 'rex/compat'

# SSLScan
require 'rex/sslscan/scanner'
require 'rex/sslscan/result'

# Versions
require 'rex/version'

Expand Down
1 change: 0 additions & 1 deletion lib/rex/proto/dns/packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'net/dns'
require 'resolv'
require 'dnsruby'

module Rex
module Proto
Expand Down
1 change: 0 additions & 1 deletion lib/rex/proto/dns/resolver.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: binary -*-

require 'net/dns/resolver'
require 'dnsruby'

module Rex
module Proto
Expand Down
17 changes: 11 additions & 6 deletions lib/rex/proto/dns/static_hostnames.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ module DNS
class StaticHostnames
extend Forwardable

# DNS record type constants (matching Dnsruby::Types::A and Dnsruby::Types::AAAA)
# Defined locally to avoid loading dnsruby during boot
TYPE_A = 1
TYPE_AAAA = 28

def_delegators :@hostnames, :each, :each_with_index, :length, :empty?, :sort_by

# @param [Hash<String, IPAddr>] hostnames The hostnames to IP address mappings to initialize with.
Expand Down Expand Up @@ -57,7 +62,7 @@ def parse_hosts_file
# @param [Integer] type The family of address to return represented as a DNS type (either A or AAAA).
# @return Returns the IP address if it was found, otherwise nil.
# @rtype [IPAddr, nil]
def get1(hostname, type = Dnsruby::Types::A)
def get1(hostname, type = TYPE_A)
get(hostname, type).first
end

Expand All @@ -67,7 +72,7 @@ def get1(hostname, type = Dnsruby::Types::A)
# @param [Integer] type The family of address to return represented as a DNS type (either A or AAAA).
# @return Returns an array of IP addresses.
# @rtype [Array<IPAddr>]
def get(hostname, type = Dnsruby::Types::A)
def get(hostname, type = TYPE_A)
hostname = hostname.downcase
@hostnames.fetch(hostname, {}).fetch(type, []).dup
end
Expand All @@ -89,9 +94,9 @@ def add(hostname, ip_address)
hostname = hostname.downcase.delete_suffix('.')
this_host = @hostnames.fetch(hostname, {})
if ip_address.family == ::Socket::AF_INET
type = Dnsruby::Types::A
type = TYPE_A
else
type = Dnsruby::Types::AAAA
type = TYPE_AAAA
end
this_type = this_host.fetch(type, [])
this_type << ip_address unless this_type.include?(ip_address)
Expand All @@ -108,9 +113,9 @@ def add(hostname, ip_address)
def delete(hostname, ip_address)
ip_address = IPAddr.new(ip_address) if ip_address.is_a?(String) && Rex::Socket.is_ip_addr?(ip_address)
if ip_address.family == ::Socket::AF_INET
type = Dnsruby::Types::A
type = TYPE_A
else
type = Dnsruby::Types::AAAA
type = TYPE_AAAA
end

hostname = hostname.downcase
Expand Down
5 changes: 3 additions & 2 deletions lib/rex/proto/http/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'uri'

require 'nokogiri'
require 'rkelly'

module Rex
module Proto
Expand Down Expand Up @@ -121,7 +120,7 @@ def gzip_decode!
end

def gzip_decode
gz = Zlib::GzipReader.new(StringIO.new(self.body.to_s))
gz = Zlib::GzipReader.new(StringIO.new(self.body.to_s))

gz.read
end
Expand Down Expand Up @@ -158,6 +157,8 @@ def get_html_meta_elements
# @see https://github.com/tenderlove/rkelly
# @return [Array<RKelly::Nodes::SourceElementsNode>]
def get_html_scripts
require 'rkelly'

n = get_html_document
rkelly = RKelly::Parser.new
n.search('//script').map { |s| rkelly.parse(s.text) }
Expand Down
2 changes: 0 additions & 2 deletions modules/payloads/stagers/netware/reverse_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'metasm'

module MetasploitModule
CachedSize = 281

Expand Down
2 changes: 0 additions & 2 deletions modules/payloads/stages/netware/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'metasm'

module MetasploitModule
include Msf::Sessions::CommandShellOptions

Expand Down
12 changes: 12 additions & 0 deletions spec/lib/rex/proto/dns/static_hostnames_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
require 'spec_helper'

RSpec.describe Rex::Proto::DNS::StaticHostnames do
describe '::TYPE_A' do
it 'matches Dnsruby::Types::A' do
expect(described_class::TYPE_A).to eq Dnsruby::Types::A
end
end

describe '::TYPE_AAAA' do
it 'matches Dnsruby::Types::AAAA' do
expect(described_class::TYPE_AAAA).to eq Dnsruby::Types::AAAA
end
end

describe '#parse_hosts_file' do
context 'when parsing a file' do
let(:subject) { described_class.new }
Expand Down
Loading