Land #9976, Store non-nil linux enum_network loot

GSoC/Meterpreter_Web_Console
Adam Cammack 2018-05-30 15:33:39 -05:00
commit 5e968529bf
No known key found for this signature in database
GPG Key ID: C9378BA088092D66
2 changed files with 16 additions and 12 deletions

View File

@ -421,22 +421,22 @@ protected
#
# @return [String]
def _read_file_meterpreter(file_name)
begin
fd = session.fs.file.new(file_name, "rb")
rescue ::Rex::Post::Meterpreter::RequestError => e
print_error("Failed to open file: #{file_name}: #{e}")
return nil
end
fd = session.fs.file.new(file_name, "rb")
data = fd.read
begin
until fd.eof?
data << fd.read
end
ensure
fd.close
until fd.eof?
data << fd.read
end
data
rescue EOFError
# Sometimes fd isn't marked EOF in time?
''
rescue ::Rex::Post::Meterpreter::RequestError => e
print_error("Failed to open file: #{file_name}: #{e}")
return nil
ensure
fd.close if fd
end
#

View File

@ -74,6 +74,10 @@ class MetasploitModule < Msf::Post
# Save enumerated data
def save(msg, data, ctype="text/plain")
if data.nil? || data.include?('not found') || data.include?('cannot access')
print_bad("Unable to get data for #{msg}")
return
end
ltype = "linux.enum.network"
loot = store_loot(ltype, ctype, session, data, nil, msg)
print_good("#{msg} stored in #{loot.to_s}")