Land #11342, Modify Post read_file to check if file is readable
commit
08817d9c7e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue