Skip to content

Commit f369584

Browse files
rootroot
authored andcommitted
Timeout added
1 parent d086407 commit f369584

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/post/windows/gather/forensics/recovery_files.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def initialize(info={})
2020
register_options(
2121
[
2222
OptString.new('FILES',[false,'ID or extensions of the files to recover in a comma separated way.',""]),
23-
OptString.new('DRIVE',[true,'Drive you want to recover files from',"C:"]),
23+
OptString.new('DRIVE',[true,'Drive you want to recover files from.',"C:"]),
24+
OptInt.new('TIMEOUT', [true,'Search timeout. If 0 the module will go through the entire $MFT.', 3600])
2425
], self.class)
2526
end
2627

@@ -53,7 +54,14 @@ def run
5354
if handle != nil
5455
data_runs = mft_data_runs(handle)
5556
print_status("It seems that MFT is fragmented (#{data_runs.size-1} data runs)") if (data_runs.count > 2)
56-
deleted_files(data_runs[1..-1], handle,files)
57+
to = (datastore['TIMEOUT'].zero?) ? nil : datastore['TIMEOUT']
58+
begin
59+
::Timeout.timeout(to) do
60+
deleted_files(data_runs[1..-1], handle,files)
61+
end
62+
rescue ::Timeout::Error
63+
print_error("Server timed out after #{to} seconds. Skipping...")
64+
end
5765
end
5866
end
5967
else

0 commit comments

Comments
 (0)