Skip to content

Commit 74e029f

Browse files
author
Brent Cook
committed
2 parents 522c6dc + 68a5d30 commit 74e029f

File tree

1 file changed

+11
-3
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi

1 file changed

+11
-3
lines changed

lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/clipboard.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ def cmd_clipboard_monitor_stop(*args)
373373
def download_file( dest_folder, source )
374374
stat = client.fs.file.stat( source )
375375
base = ::Rex::Post::Meterpreter::Extensions::Stdapi::Fs::File.basename( source )
376+
377+
# Basename ends up with a single name/folder. This is the only point where it
378+
# may be possible to do a dir trav up one folder. We need to check to make sure
379+
# that the basename doesn't result in a traversal
380+
return false if base == '..'
381+
376382
dest = File.join( dest_folder, base )
377383

378384
if stat.directory?
@@ -386,6 +392,8 @@ def download_file( dest_folder, source )
386392
client.framework.events.on_session_download( client, src, dest ) if msf_loaded?
387393
}
388394
end
395+
396+
return true
389397
end
390398

391399
def parse_dump(dump, get_images, get_files, download_path)
@@ -406,15 +414,15 @@ def parse_dump(dump, get_images, get_files, download_path)
406414
print_line(v)
407415

408416
when 'Files'
409-
total = 0
410417
v.each do |f|
411418
print_line("Remote Path : #{f[:name]}")
412419
print_line("File size : #{f[:size]} bytes")
413420
if get_files
414-
download_file( loot_dir, f[:name] )
421+
unless download_file(loot_dir, f[:name])
422+
print_error("Download of #{f:name]} failed.")
423+
end
415424
end
416425
print_line
417-
total += f[:size]
418426
end
419427

420428
when 'Image'

0 commit comments

Comments
 (0)