Add warning to FileDropper for deleting CWD

MS-2855/keylogger-mettle-extension
William Vu 2018-01-16 22:13:47 -06:00
parent 8be2b1f59e
commit 15ff70fbda
1 changed files with 24 additions and 0 deletions

View File

@ -201,6 +201,10 @@ module Exploit::FileDropper
# @param [String] dir The directory to delete
# @return [Boolean] True if the delete command has been executed in the remote machine, otherwise false.
def file_dropper_delete_dir(session, dir)
if file_dropper_check_cwd?(dir)
print_warning("Attempting to delete working directory #{dir}")
end
win_dir = file_dropper_win_path(dir)
if session.type == 'meterpreter'
@ -250,6 +254,26 @@ module Exploit::FileDropper
end
end
# Check if the path being removed is the same as the working directory
#
# @param [String] path The path to check
# @return [Boolean] true if the path is the same, otherwise false
def file_dropper_check_cwd?(path)
if session.type == 'meterpreter'
return true if path == session.fs.dir.pwd
else
pwd = if session.platform == 'windows'
session.shell_command_token('echo %cd%').strip
else
session.shell_command_token('pwd').strip
end
return true if path == pwd
end
false
end
# Converts a path to use the windows separator '\'
#
# @param [String] path The path to convert