Let recursive downloads skip over locked files

git-svn-id: file:///home/svn/framework3/trunk@10877 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2010-11-03 03:16:23 +00:00
parent fba2cb6d2d
commit 1e4eed0559
2 changed files with 14 additions and 5 deletions

View File

@ -192,7 +192,7 @@ class Dir < Rex::Post::Dir
# Downloads the contents of a remote directory a # Downloads the contents of a remote directory a
# local directory, optionally in a recursive fashion. # local directory, optionally in a recursive fashion.
# #
def Dir.download(dst, src, recursive = false, &stat) def Dir.download(dst, src, recursive = false, force = true, &stat)
self.entries(src).each { |src_sub| self.entries(src).each { |src_sub|
dst_item = dst + ::File::SEPARATOR + src_sub dst_item = dst + ::File::SEPARATOR + src_sub
src_item = src + File::SEPARATOR + src_sub src_item = src + File::SEPARATOR + src_sub
@ -205,8 +205,17 @@ class Dir < Rex::Post::Dir
if (src_stat.file?) if (src_stat.file?)
stat.call('downloading', src_item, dst_item) if (stat) stat.call('downloading', src_item, dst_item) if (stat)
begin
client.fs.file.download(dst_item, src_item) client.fs.file.download(dst_item, src_item)
stat.call('downloaded', src_item, dst_item) if (stat) stat.call('downloaded', src_item, dst_item) if (stat)
rescue ::Rex::Post::Meterpreter::RequestError => e
if force
stat.call('failed', src_item, dst_item) if (stat)
else
raise e
end
end
elsif (src_stat.directory?) elsif (src_stat.directory?)
if (recursive == false) if (recursive == false)
next next
@ -218,7 +227,7 @@ class Dir < Rex::Post::Dir
end end
stat.call('mirroring', src_item, dst_item) if (stat) stat.call('mirroring', src_item, dst_item) if (stat)
download(dst_item, src_item, recursive, &stat) download(dst_item, src_item, recursive, force, &stat)
stat.call('mirrored', src_item, dst_item) if (stat) stat.call('mirrored', src_item, dst_item) if (stat)
end end
} }

View File

@ -223,7 +223,7 @@ class Console::CommandDispatcher::Stdapi::Fs
stat = client.fs.file.stat(src) stat = client.fs.file.stat(src)
if (stat.directory?) if (stat.directory?)
client.fs.dir.download(dest, src, recursive) { |step, src, dst| client.fs.dir.download(dest, src, recursive, true) { |step, src, dst|
print_status("#{step.ljust(11)}: #{src} -> #{dst}") print_status("#{step.ljust(11)}: #{src} -> #{dst}")
} }
elsif (stat.file?) elsif (stat.file?)