Skip to content

Commit ff6c8bd

Browse files
committed
Land rapid7#3479, broken sock.get fix
2 parents 25f74b7 + b6ded98 commit ff6c8bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+122
-108
lines changed

modules/auxiliary/admin/cisco/vpn_3000_ftp_bypass.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ def run
5050

5151
print_status("Attempting to create directory: MKD #{test}")
5252
sock.put("MKD #{test}\r\n")
53-
res = sock.get(-1,5)
53+
res = sock.get_once(-1,5)
5454

5555
if (res =~/257 MKD command successful\./)
5656
print_status("\tDirectory #{test} reportedly created. Verifying with SIZE #{test}")
5757
sock.put("SIZE #{test}\r\n")
58-
res = sock.get(-1,5)
58+
res = sock.get_once(-1,5)
5959
if (res =~ /550 Not a regular file/)
6060
print_status("\tServer reports \"not a regular file\". Directory verified.")
6161
print_status("\tAttempting to delete directory: RMD #{test}")
6262
sock.put("RMD #{test}\r\n")
63-
res = sock.get(-1,5)
63+
res = sock.get_once(-1,5)
6464
if (res =~ /250 RMD command successful\./)
6565
print_status("\tDirectory #{test} reportedly deleted. Verifying with SIZE #{test}")
6666
sock.put("SIZE #{test}\r\n")
67-
res = sock.get(-1,5)
67+
res = sock.get_once(-1,5)
6868
print_status("\tDirectory #{test} no longer exists!")
6969
print_status("Target is confirmed as vulnerable!")
7070
end

modules/auxiliary/admin/misc/sercomm_dump_config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def fingerprint_endian
116116
begin
117117
connect
118118
sock.put(Rex::Text.rand_text(5))
119-
res = sock.get_once
119+
res = sock.get_once(-1, 10)
120120
disconnect
121121
rescue Rex::ConnectionError => e
122122
print_error("Connection failed: #{e.class}: #{e}")
@@ -147,7 +147,7 @@ def dump_configuration
147147

148148
connect
149149
sock.put(pkt)
150-
res = sock.get
150+
res = sock.get_once(-1, 10)
151151

152152
disconnect
153153

modules/auxiliary/admin/oracle/sid_brute.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ def run
4141

4242
print_status("Starting brute force on #{rhost}, using sids from #{list}...")
4343

44-
fd = File.open(list, 'rb').each do |sid|
44+
fd = ::File.open(list, 'rb').each do |sid|
4545
login = "(DESCRIPTION=(CONNECT_DATA=(SID=#{sid})(CID=(PROGRAM=)(HOST=MSF)(USER=)))(ADDRESS=(PROTOCOL=tcp)(HOST=#{rhost})(PORT=#{rport})))"
4646
pkt = tns_packet(login)
4747

4848
begin
4949
connect
50+
rescue ::Interrupt
51+
raise $!
5052
rescue => e
5153
print_error(e.to_s)
5254
disconnect
@@ -55,12 +57,10 @@ def run
5557

5658
sock.put(pkt)
5759
select(nil,nil,nil,s.to_i)
58-
res = sock.get_once(-1,3)
60+
res = sock.get_once
5961
disconnect
6062

61-
if ( res and res =~ /ERROR_STACK/ )
62-
''
63-
else
63+
if res and res.to_s !~ /ERROR_STACK/
6464
report_note(
6565
:host => rhost,
6666
:port => rport,
@@ -70,6 +70,7 @@ def run
7070
)
7171
print_good("#{rhost}:#{rport} Found SID '#{sid.strip}'")
7272
end
73+
7374
end
7475

7576
print_status("Done with brute force...")

modules/auxiliary/fuzzers/ftp/ftp_pre_post.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def initialize
6464

6565

6666
def get_pkt
67-
buf = sock.get
67+
buf = sock.get_once(-1, 10)
6868
vprint_status("[in ] #{buf.inspect}")
6969
buf
7070
end

modules/auxiliary/scanner/http/open_proxy.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def initialize(info = {})
3737
OptBool.new('VERIFY_CONNECT', [ false, 'Enable test for CONNECT method', false ]),
3838
OptBool.new('VERIFY_HEAD', [ false, 'Enable test for HEAD method', false ]),
3939
OptBool.new('LOOKUP_PUBLIC_ADDRESS', [ false, 'Enable test for retrieve public IP address via RIPE.net', false ]),
40-
OptString.new('SITE', [ true, 'The web site to test via alleged web proxy (default is www.google.com)', '209.85.148.147' ]),
40+
OptString.new('SITE', [ true, 'The web site to test via alleged web proxy (default is www.google.com)', 'www.google.com' ]),
4141
OptString.new('ValidCode', [ false, "Valid HTTP code for a successfully request", '200,302' ]),
4242
OptString.new('ValidPattern', [ false, "Valid HTTP server header for a successfully request", 'server: gws' ]),
4343
OptString.new('UserAgent', [ true, 'The HTTP User-Agent sent in the request', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)' ]),
@@ -60,14 +60,16 @@ def run_host(target_host)
6060

6161
if datastore['MULTIPORTS']
6262
target_ports = [ 80, 1080, 3128, 8080, 8123 ]
63-
else
64-
target_ports.push(datastore['RPORT'].to_i)
6563
end
6664

65+
target_ports.push(datastore['RPORT'].to_i)
66+
6767
if datastore['RANDOMIZE_PORTS']
6868
target_ports = target_ports.sort_by { rand }
6969
end
7070

71+
target_ports = target_ports.uniq
72+
7173
site = datastore['SITE']
7274
user_agent = datastore['UserAgent']
7375

@@ -97,7 +99,7 @@ def write_request(method,site,user_agent)
9799
request = method + " http://" + site + "/ HTTP/1.1" + "\r\n" +
98100
"Host: " + site + "\r\n" +
99101
"Connection: close" + "\r\n" +
100-
"User-Agent: user_agent" + "\r\n" +
102+
"User-Agent: #{user_agent}" + "\r\n" +
101103
"Accept-Encoding: *" + "\r\n" +
102104
"Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7" + "\r\n" +
103105
"Cache-Control: no" + "\r\n" +
@@ -115,7 +117,7 @@ def send_request(site,user_agent)
115117

116118
request = write_request('GET',site,user_agent)
117119
sock.put(request)
118-
res = sock.get
120+
res = sock.get_once(-1, 10)
119121

120122
disconnect
121123

@@ -167,7 +169,7 @@ def send_request_ripe(user_agent)
167169

168170
request = write_request('GET',ripe_address,user_agent)
169171
sock.put(request)
170-
res = sock.get
172+
res = sock.get_once(-1, 10)
171173

172174
disconnect
173175

modules/auxiliary/scanner/portscan/ftpbounce.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def run_host(ip)
5959
# on the response codes. We need to do this between every
6060
# port scan attempt unfortunately.
6161
while true
62-
r = self.sock.get(0.25)
62+
r = sock.get_once(-1, 0.25)
6363
break if not r or r.empty?
6464
end
6565

modules/auxiliary/scanner/scada/modbusclient.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def initialize(info = {})
4747
def send_frame(payload)
4848
sock.put(payload)
4949
@modbus_counter += 1
50-
r = sock.get(sock.def_read_timeout)
51-
return r
50+
sock.get_once(-1, sock.def_read_timeout)
5251
end
5352

5453
def make_payload(payload)
@@ -65,10 +64,7 @@ def make_read_payload
6564
payload += [@function_code].pack("c")
6665
payload += [datastore['DATA_ADDRESS']].pack("n")
6766
payload += [1].pack("n")
68-
69-
packet_data = make_payload(payload)
70-
71-
packet_data
67+
make_payload(payload)
7268
end
7369

7470
def make_write_coil_payload(data)
@@ -89,9 +85,7 @@ def make_write_register_payload(data)
8985
payload += [datastore['DATA_ADDRESS']].pack("n")
9086
payload += [data].pack("n")
9187

92-
packet_data = make_payload(payload)
93-
94-
packet_data
88+
make_payload(payload)
9589
end
9690

9791
def handle_error(response)

modules/auxiliary/scanner/ssl/openssl_ccs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def establish_connect
187187

188188
vprint_status("#{peer} - Sending Client Hello...")
189189
sock.put(client_hello)
190-
server_hello = sock.get(response_timeout)
190+
server_hello = sock.get_once(-1, response_timeout)
191191

192192
unless server_hello
193193
vprint_error("#{peer} - No Server Hello after #{response_timeout} seconds...")

modules/auxiliary/scanner/ssl/openssl_heartbleed.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ def jabber_connect_msg(hostname)
339339

340340
def tls_jabber
341341
sock.put(jabber_connect_msg(xmpp_domain))
342-
res = sock.get(response_timeout)
342+
res = sock.get_once(-1, response_timeout)
343343
if res && res.include?('host-unknown')
344344
jabber_host = res.match(/ from='([\w.]*)' /)
345345
if jabber_host && jabber_host[1]
346346
disconnect
347347
establish_connect
348348
vprint_status("#{peer} - Connecting with autodetected remote XMPP hostname: #{jabber_host[1]}...")
349349
sock.put(jabber_connect_msg(jabber_host[1]))
350-
res = sock.get(response_timeout)
350+
res = sock.get_once(-1, response_timeout)
351351
end
352352
end
353353
if res.nil? || res.include?('stream:error') || res !~ /<starttls xmlns=['"]urn:ietf:params:xml:ns:xmpp-tls['"]/
@@ -356,14 +356,14 @@ def tls_jabber
356356
end
357357
msg = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
358358
sock.put(msg)
359-
res = sock.get(response_timeout)
359+
res = sock.get_once(-1, response_timeout)
360360
return nil if res.nil? || !res.include?('<proceed')
361361
res
362362
end
363363

364364
def tls_ftp
365365
# http://tools.ietf.org/html/rfc4217
366-
res = sock.get(response_timeout)
366+
res = sock.get_once(-1, response_timeout)
367367
return nil if res.nil?
368368
sock.put("AUTH TLS\r\n")
369369
res = get_data
@@ -418,7 +418,7 @@ def establish_connect
418418
vprint_status("#{peer} - Sending Client Hello...")
419419
sock.put(client_hello)
420420

421-
server_hello = sock.get(response_timeout)
421+
server_hello = sock.get_once(-1, response_timeout)
422422
unless server_hello
423423
vprint_error("#{peer} - No Server Hello after #{response_timeout} seconds...")
424424
return nil

modules/auxiliary/scanner/tftp/tftpbrute.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_host(ip)
5050
filename.strip!
5151
pkt = "\x00\x01" + filename + "\x00" + "netascii" + "\x00"
5252
udp_sock.sendto(pkt, ip, datastore['RPORT'])
53-
resp = udp_sock.get(1)
53+
resp = udp_sock.get(3)
5454
if resp and resp.length >= 2 and resp[0, 2] == "\x00\x03"
5555
print_status("Found #{filename} on #{ip}")
5656
#Add Report

0 commit comments

Comments
 (0)