Skip to content

Commit 0a42ac9

Browse files
author
Tod Beardsley
committed
Land rapid7#4737, fix Socket Context usages
2 parents 6e8b2e4 + 4014f19 commit 0a42ac9

33 files changed

+110
-30
lines changed

lib/metasploit/framework/ftp/client.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ def data_connect(mode = nil, nsock = self.sock)
4444
# convert port to FTP syntax
4545
datahost = "#{$1}.#{$2}.#{$3}.#{$4}"
4646
dataport = ($5.to_i * 256) + $6.to_i
47-
self.datasocket = Rex::Socket::Tcp.create('PeerHost' => datahost, 'PeerPort' => dataport)
47+
self.datasocket = Rex::Socket::Tcp.create(
48+
'PeerHost' => datahost,
49+
'PeerPort' => dataport,
50+
'Context' => { 'Msf' => framework, 'MsfExploit' => framework_module }
51+
)
4852
end
4953
self.datasocket
5054
end

lib/metasploit/framework/login_scanner/base.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ module Base
1212
include ActiveModel::Validations
1313

1414
included do
15+
# @!attribute framework
16+
# @return [Object] The framework instance object
17+
attr_accessor :framework
18+
# @!attribute framework_module
19+
# @return [Object] The framework module caller, if availale
20+
attr_accessor :framework_module
1521
# @!attribute connection_timeout
1622
# @return [Fixnum] The timeout in seconds for a single SSH connection
1723
attr_accessor :connection_timeout

lib/metasploit/framework/login_scanner/snmp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def attempt_login(credential)
3838
:Timeout => connection_timeout,
3939
:Retries => 2,
4040
:Transport => ::SNMP::RexUDPTransport,
41-
:Socket => ::Rex::Socket::Udp.create
41+
:Socket => ::Rex::Socket::Udp.create('Context' => { 'Msf' => framework, 'MsfExploit' => framework_module })
4242
)
4343

4444
result_options[:proof] = test_read_access(snmp_client)

lib/metasploit/framework/tcp/client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def connect(global = true, opts={})
8989
'SSL' => dossl,
9090
'SSLVersion' => opts['SSLVersion'] || ssl_version,
9191
'Proxies' => proxies,
92-
'Timeout' => (opts['ConnectTimeout'] || connection_timeout || 10).to_i
92+
'Timeout' => (opts['ConnectTimeout'] || connection_timeout || 10).to_i,
93+
'Context' => { 'Msf' => framework, 'MsfExploit' => framework_module }
9394
)
9495
# enable evasions on this socket
9596
set_tcp_evasions(nsock)

lib/msf/core/exploit/ftp.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def data_connect(mode = nil, nsock = self.sock)
8383
# convert port to FTP syntax
8484
datahost = "#{$1}.#{$2}.#{$3}.#{$4}"
8585
dataport = ($5.to_i * 256) + $6.to_i
86-
self.datasocket = Rex::Socket::Tcp.create('PeerHost' => datahost, 'PeerPort' => dataport)
86+
self.datasocket = Rex::Socket::Tcp.create(
87+
'PeerHost' => datahost,
88+
'PeerPort' => dataport,
89+
'Context' => { 'Msf' => framework, 'MsfExploit' => self }
90+
)
8791
end
8892
self.datasocket
8993
end

modules/auxiliary/scanner/acpp/login.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def run_host(ip)
7171
bruteforce_speed: datastore['BRUTEFORCE_SPEED'],
7272
connection_timeout: datastore['ConnectTimeout'],
7373
max_send_size: datastore['TCP::max_send_size'],
74-
send_delay: datastore['TCP::send_delay']
74+
send_delay: datastore['TCP::send_delay'],
75+
framework: framework,
76+
framework_module: self,
7577
)
7678

7779
scanner.scan! do |result|

modules/auxiliary/scanner/afp/afp_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def run_host(ip)
6767
connection_timeout: 30,
6868
max_send_size: datastore['TCP::max_send_size'],
6969
send_delay: datastore['TCP::send_delay'],
70+
framework: framework,
71+
framework_module: self,
7072
)
7173

7274
scanner.scan! do |result|

modules/auxiliary/scanner/db2/db2_auth.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def run_host(ip)
6565
connection_timeout: 30,
6666
max_send_size: datastore['TCP::max_send_size'],
6767
send_delay: datastore['TCP::send_delay'],
68+
framework: framework,
69+
framework_module: self,
6870
)
6971

7072
scanner.scan! do |result|

modules/auxiliary/scanner/ftp/ftp_login.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def run_host(ip)
7878
bruteforce_speed: datastore['BRUTEFORCE_SPEED'],
7979
max_send_size: datastore['TCP::max_send_size'],
8080
send_delay: datastore['TCP::send_delay'],
81-
connection_timeout: 30
81+
connection_timeout: 30,
82+
framework: framework,
83+
framework_module: self,
8284
)
8385

8486
scanner.scan! do |result|

modules/auxiliary/scanner/http/appletv_login.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def run_host(ip)
8383
stop_on_success: datastore['STOP_ON_SUCCESS'],
8484
bruteforce_speed: datastore['BRUTEFORCE_SPEED'],
8585
connection_timeout: 5,
86+
framework: framework,
87+
framework_module: self,
8688
)
8789

8890
scanner.scan! do |result|

0 commit comments

Comments
 (0)