@@ -24,7 +24,8 @@ class Console::CommandDispatcher::Stdapi::Fs
24
24
#
25
25
@@download_opts = Rex ::Parser ::Arguments . new (
26
26
"-h" => [ false , "Help banner." ] ,
27
- "-r" => [ false , "Download recursively." ] )
27
+ "-r" => [ false , "Download recursively." ] ,
28
+ "-t" => [ false , "Timestamp downloaded files." ] )
28
29
#
29
30
# Options for the upload command.
30
31
#
@@ -332,6 +333,7 @@ def cmd_download(*args)
332
333
end
333
334
334
335
recursive = false
336
+ timestamp = false
335
337
src_items = [ ]
336
338
last = nil
337
339
dest = nil
@@ -340,6 +342,8 @@ def cmd_download(*args)
340
342
case opt
341
343
when "-r"
342
344
recursive = true
345
+ when "-t"
346
+ timestamp = true
343
347
when nil
344
348
src_items << last if ( last )
345
349
last = val
@@ -367,6 +371,10 @@ def cmd_download(*args)
367
371
dest = ::File . dirname ( dest )
368
372
end
369
373
374
+ if timestamp
375
+ ts = '_' + Time . now . iso8601
376
+ end
377
+
370
378
# Go through each source item and download them
371
379
src_items . each { |src |
372
380
glob = nil
@@ -389,8 +397,7 @@ def cmd_download(*args)
389
397
src_path = file [ 'path' ] + client . fs . file . separator + file [ 'name' ]
390
398
dest_path = src_path . tr ( src_separator , ::File ::SEPARATOR )
391
399
392
- client . fs . file . download ( dest_path , src_path ) do |step , src , dst |
393
- puts step
400
+ client . fs . file . download ( dest_path , src_path , ts ) do |step , src , dst |
394
401
print_status ( "#{ step . ljust ( 11 ) } : #{ src } -> #{ dst } " )
395
402
client . framework . events . on_session_download ( client , src , dest ) if msf_loaded?
396
403
end
@@ -404,12 +411,12 @@ def cmd_download(*args)
404
411
# Perform direct matching
405
412
stat = client . fs . file . stat ( src )
406
413
if ( stat . directory? )
407
- client . fs . dir . download ( dest , src , recursive , true , glob ) do |step , src , dst |
414
+ client . fs . dir . download ( dest , src , recursive , true , glob , ts ) do |step , src , dst |
408
415
print_status ( "#{ step . ljust ( 11 ) } : #{ src } -> #{ dst } " )
409
416
client . framework . events . on_session_download ( client , src , dest ) if msf_loaded?
410
417
end
411
418
elsif ( stat . file? )
412
- client . fs . file . download ( dest , src ) do |step , src , dst |
419
+ client . fs . file . download ( dest , src , ts ) do |step , src , dst |
413
420
print_status ( "#{ step . ljust ( 11 ) } : #{ src } -> #{ dst } " )
414
421
client . framework . events . on_session_download ( client , src , dest ) if msf_loaded?
415
422
end
0 commit comments