Update cleanup method to check CWD
parent
e60aeca2db
commit
da23432745
|
@ -61,13 +61,19 @@ module Exploit::FileDropper
|
|||
|
||||
@dropped_files.delete_if do |file|
|
||||
exists_before = file_dropper_exist?(session, file)
|
||||
|
||||
if file_dropper_delete_file(session, file)
|
||||
file_dropper_deleted?(session, file, exists_before)
|
||||
end
|
||||
end
|
||||
|
||||
@dropped_dirs.delete_if do |dir|
|
||||
if file_dropper_check_cwd?(session, dir)
|
||||
print_warning("Attempting to delete working directory #{dir}")
|
||||
end
|
||||
|
||||
exists_before = file_dropper_exist?(session, dir)
|
||||
|
||||
if file_dropper_delete_dir(session, dir)
|
||||
file_dropper_deleted?(session, dir, exists_before)
|
||||
end
|
||||
|
@ -110,6 +116,10 @@ module Exploit::FileDropper
|
|||
# Check if dir_rm method is available (local exploit, mixin support, module support)
|
||||
if respond_to?(:dir_rm)
|
||||
@dropped_dirs.delete_if do |dir|
|
||||
if respond_to?(:pwd) && pwd.include?(dir)
|
||||
print_warning("Attempting to delete working directory #{dir}")
|
||||
end
|
||||
|
||||
begin
|
||||
dir_rm(dir)
|
||||
rescue ::Exception => e
|
||||
|
@ -201,10 +211,6 @@ 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?(session, dir)
|
||||
print_warning("Attempting to delete working directory #{dir}")
|
||||
end
|
||||
|
||||
win_dir = file_dropper_win_path(dir)
|
||||
|
||||
if session.type == 'meterpreter'
|
||||
|
@ -264,9 +270,9 @@ module Exploit::FileDropper
|
|||
else
|
||||
pwd =
|
||||
if session.platform == 'windows'
|
||||
session.shell_command_token('echo %cd%').strip
|
||||
session.shell_command_token('echo %cd%')
|
||||
else
|
||||
session.shell_command_token('pwd').strip
|
||||
session.shell_command_token('pwd')
|
||||
end
|
||||
|
||||
# Check for subdirectories and relative paths
|
||||
|
|
Loading…
Reference in New Issue