Land #11342, Modify Post read_file to check if file is readable

GSoC/Meterpreter_Web_Console
Brent Cook 2019-02-06 22:48:13 -06:00
commit 08817d9c7e
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
1 changed files with 15 additions and 0 deletions

View File

@ -166,6 +166,19 @@ module Msf::Post::File
cmd_exec("test -w '#{path}' && echo true").to_s.include? 'true'
end
#
# See if +path+ on the remote system exists and is readable
#
# @param path [String] Remote path to check
#
# @return [Boolean] true if +path+ exists and is readable
#
def readable?(path)
raise "`readable?' method does not support Windows systems" if session.platform == 'windows'
cmd_exec("test -r '#{path}' && echo true").to_s.include? 'true'
end
#
# Check for existence of +path+ on the remote file system
#
@ -318,6 +331,8 @@ module Msf::Post::File
return session.shell_command_token("type \"#{file_name}\"")
end
return nil unless readable?(file_name)
if command_exists?('cat')
return session.shell_command_token("cat \"#{file_name}\"")
end