create chmod helper function
parent
81d020f810
commit
4adca52103
|
@ -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
|
||||
#
|
||||
|
|
|
@ -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}"
|
||||
|
|
Loading…
Reference in New Issue