Land #18104, fix falsely caused empty file reads

This issue was happening frequently with the java metepreter.
The issue has been fixed and tested with test/file post module.
This commit is contained in:
Jack Heysel 2023-06-22 13:07:19 -04:00
commit 4c73067dfe
No known key found for this signature in database
GPG Key ID: D373F2C24A2A1E70
1 changed files with 3 additions and 2 deletions

View File

@ -831,13 +831,14 @@ protected
def _read_file_meterpreter(file_name)
fd = session.fs.file.new(file_name, 'rb')
data = fd.read
data = ''.b
data << fd.read
data << fd.read until fd.eof?
data
rescue EOFError
# Sometimes fd isn't marked EOF in time?
''
data
rescue ::Rex::Post::Meterpreter::RequestError => e
print_error("Failed to open file: #{file_name}: #{e}")
return nil