Skip to content

Commit 806c889

Browse files
committed
php_include: Tweak check()
1 parent 92c068d commit 806c889

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

modules/exploits/unix/webapp/php_include.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,32 @@ def initialize(info = {})
7171
)
7272
end
7373

74+
# TODO: Would be nice if datastore['PHPURI'] is set, to use on_request_uri() to see if a connection happens, then would be able to return Exploit::CheckCode::Vulnerable
7475
def check
7576
method = datastore['FORMDATA'] ? 'POST' : 'GET'
76-
uri = normalize_uri(datastore['ROOTDIR'], datastore['PHPURI']).gsub(/\?.*/, '')
77+
uri = normalize_uri(datastore['ROOTDIR'], datastore['PHPURI']).gsub('!INJECT!', '')
7778
print_status("Checking URI via #{method}: #{uri}")
7879

79-
response = send_request_raw({
80+
response = {
81+
'global' => true,
8082
'uri' => uri,
8183
'method' => method,
8284
'headers' => datastore_headers.merge(
8385
'Connection' => 'close'
8486
)
85-
})
87+
}
88+
unless method.casecmp?('get')
89+
data = method.casecmp?('get') ? nil : encoded_url(datastore['FORMDATA'].gsub('!INJECT!', ''))
90+
response['headers']['Content-Type'] = 'application/x-www-form-urlencoded'
91+
response['headers']['Content-Length'] = data.length
92+
response['data'] = data
93+
end
94+
response = send_request_raw(response)
8695
return Exploit::CheckCode::Unknown unless response
8796
return Exploit::CheckCode::Detected if response.code == 200
8897

89-
vprint_error("Server responded with: HTTP #{response.code}")
90-
return Exploit::CheckCode::Safe
98+
vprint_warning("Server responded with: HTTP #{response.code}")
99+
return Exploit::CheckCode::Unknown
91100
end
92101

93102
def datastore_headers

0 commit comments

Comments
 (0)