From 1b040dc874d1ed614b7bb6eb9cda39da312b2ce1 Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 15 Jun 2020 17:44:28 +0530 Subject: [PATCH] Add windows PBA --- .../windows/shell_startup_files_modification.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/utils/windows/shell_startup_files_modification.py b/monkey/infection_monkey/utils/windows/shell_startup_files_modification.py index efc9480d8..15e44b832 100644 --- a/monkey/infection_monkey/utils/windows/shell_startup_files_modification.py +++ b/monkey/infection_monkey/utils/windows/shell_startup_files_modification.py @@ -1,3 +1,12 @@ +SHELL_STARTUP_FILE = '$Profile' + + def get_windows_commands_to_modify_shell_startup_files(): - # TODO: add for powershell - return 'dir' + return [ + 'powershell.exe', # run with powershell + 'Add-Content {0} '.format(SHELL_STARTUP_FILE), + '\"# Successfully modified {0}\" ;'.format(SHELL_STARTUP_FILE), # add line to $profile + 'cat {0} | Select -last 1 ;'.format(SHELL_STARTUP_FILE), # print last line of $profile + '$OldProfile = cat {0} | Select -skiplast 1 ;'.format(SHELL_STARTUP_FILE), + 'Set-Content {0} -Value $OldProfile ;'.format(SHELL_STARTUP_FILE) # remove last line of $profile +]