forked from p15670423/monkey
parent
1d952a4781
commit
2b9d54408a
|
@ -7,8 +7,7 @@ from infection_monkey.utils.windows.hidden_files import\
|
|||
get_windows_commands_to_hide_files,\
|
||||
get_windows_commands_to_hide_folders,\
|
||||
get_winAPI_to_hide_files,\
|
||||
get_windows_commands_to_delete,\
|
||||
get_winAPI_to_delete_files
|
||||
get_windows_commands_to_delete
|
||||
from infection_monkey.utils.environment import is_windows_os
|
||||
|
||||
|
||||
|
@ -29,7 +28,5 @@ def get_winAPI_to_hide_files():
|
|||
|
||||
|
||||
def cleanup_hidden_files(is_windows=is_windows_os()):
|
||||
if is_windows:
|
||||
get_winAPI_to_delete_files()
|
||||
subprocess.run(get_windows_commands_to_delete() if is_windows
|
||||
else get_linux_commands_to_delete())
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import win32file
|
||||
|
||||
|
||||
HIDDEN_FILE = 'C:\\monkey-hidden-file'
|
||||
HIDDEN_FILE_WINAPI = 'C:\\monkey-hidden-file-winAPI'
|
||||
HIDDEN_FOLDER = 'C:\\monkey-hidden-folder'
|
||||
|
@ -29,6 +26,7 @@ def get_windows_commands_to_hide_folders():
|
|||
|
||||
|
||||
def get_winAPI_to_hide_files():
|
||||
import win32file
|
||||
try:
|
||||
fileAccess = win32file.GENERIC_READ | win32file.GENERIC_WRITE # read-write access
|
||||
fileCreation = win32file.CREATE_ALWAYS # overwrite existing file
|
||||
|
@ -43,20 +41,16 @@ def get_winAPI_to_hide_files():
|
|||
0)
|
||||
|
||||
return "Created hidden file: {}".format(HIDDEN_FILE_WINAPI), True
|
||||
|
||||
except Exception as err:
|
||||
return str(err), False
|
||||
|
||||
|
||||
def get_winAPI_to_delete_files():
|
||||
win32file.DeleteFile(HIDDEN_FILE_WINAPI)
|
||||
|
||||
|
||||
def get_windows_commands_to_delete():
|
||||
return [
|
||||
'del', # delete file
|
||||
'/f', # force delete
|
||||
HIDDEN_FILE,
|
||||
HIDDEN_FILE_WINAPI,
|
||||
'&& rmdir', # delete folder
|
||||
HIDDEN_FOLDER
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue