Skip to content

Commit

Permalink
Land #18104, fix falsely caused empty file reads
Browse files Browse the repository at this point in the history
This issue was happening frequently with the java metepreter.
The issue has been fixed and tested with test/file post module.
  • Loading branch information
jheysel-r7 committed Jun 22, 2023
2 parents 5b9f221 + 552b76a commit 4c73067
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/msf/core/post/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,14 @@ def _write_file_meterpreter(file_name, data, mode = 'wb')
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
Expand Down

0 comments on commit 4c73067

Please sign in to comment.