Agent: Modify hide files PBA to return PostBreachData

This commit is contained in:
Shreya Malviya 2022-03-28 17:15:06 +05:30 committed by vakarisz
parent 8418a5ce77
commit 28ff112872
2 changed files with 13 additions and 5 deletions

View File

@ -198,8 +198,14 @@ class AutomatedMaster(IMaster):
name = pba[0] name = pba[0]
options = pba[1] options = pba[1]
result = self._puppet.run_pba(name, options) # TEMPORARY; TO AVOID ERRORS SINCE THIS ISN'T IMPLEMENTED YET
self._telemetry_messenger.send_telemetry(PostBreachTelem(result)) if name == "Custom":
return
for pba_data in self._puppet.run_pba(name, options):
self._telemetry_messenger.send_telemetry(
PostBreachTelem(pba_data.display_name, pba_data.command, pba_data.result)
)
def _can_propagate(self) -> bool: def _can_propagate(self) -> bool:
return True return True

View File

@ -1,6 +1,6 @@
from common.common_consts.post_breach_consts import POST_BREACH_HIDDEN_FILES from common.common_consts.post_breach_consts import POST_BREACH_HIDDEN_FILES
from infection_monkey.i_puppet.i_puppet import PostBreachData
from infection_monkey.post_breach.pba import PBA from infection_monkey.post_breach.pba import PBA
from infection_monkey.telemetry.post_breach_telem import PostBreachTelem
from infection_monkey.utils.environment import is_windows_os from infection_monkey.utils.environment import is_windows_os
from infection_monkey.utils.hidden_files import ( from infection_monkey.utils.hidden_files import (
cleanup_hidden_files, cleanup_hidden_files,
@ -29,10 +29,12 @@ class HiddenFiles(PBA):
linux_cmd=" ".join(linux_cmds), linux_cmd=" ".join(linux_cmds),
windows_cmd=windows_cmds, windows_cmd=windows_cmds,
) )
super(HiddenFiles, self).run() yield super(HiddenFiles, self).run()
if is_windows_os(): # use winAPI if is_windows_os(): # use winAPI
result, status = get_winAPI_to_hide_files() result, status = get_winAPI_to_hide_files()
PostBreachTelem(self, (result, status)).send() # no command here, used WinAPI
yield PostBreachData(self.name, "", (result, status))
# cleanup hidden files and folders # cleanup hidden files and folders
cleanup_hidden_files(is_windows_os()) cleanup_hidden_files(is_windows_os())