create chmod helper function

GSoC/Meterpreter_Web_Console
Tim W 2018-09-24 15:23:44 +08:00 committed by William Vu
parent 81d020f810
commit 4adca52103
2 changed files with 13 additions and 7 deletions

View File

@ -361,6 +361,18 @@ module Msf::Post::File
write_file(remote, ::File.read(local))
end
#
# Sets the executable permissions on a remote file
#
# @param remote [String] Destination file name on the remote filesystem
def chmod_x_file(remote)
if session.type == "meterpreter" and session.commands.include?('stdapi_fs_chmod')
session.fs.file.chmod(remote, 0700)
else
cmd_exec("chmod 700 \"#{remote}\"")
end
end
#
# Delete remote files
#

View File

@ -31,13 +31,7 @@ class MetasploitModule < Msf::Post
# Don't use cmd.exe /c start so we can fetch output
cmd = rpath
else
begin
# client is an alias for session
client.fs.file.chmod(rpath, 0700)
rescue
# Fall back if unimplemented or unavailable
cmd_exec("chmod 700 #{rpath}")
end
chmod_x_file(rpath)
# Handle absolute paths
cmd = rpath.start_with?('/') ? rpath : "./#{rpath}"