Fixed schedule_jobs bug, where scheduled job is never deleted and monkey freezes indefinitelly.

This commit is contained in:
VakarisZ 2020-10-12 16:25:30 +03:00
parent 53f3625172
commit 1cbcb69697
4 changed files with 9 additions and 6 deletions

View File

@ -81,7 +81,7 @@ class ControlClient(object):
if ControlClient.proxies:
debug_message += " through proxies: %s" % ControlClient.proxies
LOG.debug(debug_message)
requests.get("https://%s/api?action=is-up" % (server,), # noqa: DUO123
requests.get(f"https://{server}/api?action=is-up", # noqa: DUO123
verify=False,
proxies=ControlClient.proxies,
timeout=TIMEOUT_IN_SECONDS)

View File

@ -15,5 +15,7 @@ class ScheduleJobs(PBA):
super(ScheduleJobs, self).__init__(name=POST_BREACH_JOB_SCHEDULING,
linux_cmd=' '.join(linux_cmds),
windows_cmd=windows_cmds)
def run(self):
super(ScheduleJobs, self).run()
remove_scheduled_jobs()

View File

@ -5,7 +5,7 @@ SCHEDULED_TASK_COMMAND = r'C:\windows\system32\cmd.exe'
def get_windows_commands_to_schedule_jobs():
return f'schtasks /Create /SC monthly /TN {SCHEDULED_TASK_NAME} /TR {SCHEDULED_TASK_COMMAND}'
return f'schtasks /Create /SC monthly /F /TN {SCHEDULED_TASK_NAME} /TR {SCHEDULED_TASK_COMMAND}'
def get_windows_commands_to_remove_scheduled_jobs():

View File

@ -25,9 +25,9 @@ class PostBreach(object):
"""
Executes all post breach actions.
"""
pool = Pool(5)
pool.map(self.run_pba, self.pba_list)
LOG.info("All PBAs executed. Total {} executed.".format(len(self.pba_list)))
with Pool(5) as pool:
pool.map(self.run_pba, self.pba_list)
LOG.info("All PBAs executed. Total {} executed.".format(len(self.pba_list)))
@staticmethod
def config_to_pba_list() -> Sequence[PBA]:
@ -40,5 +40,6 @@ class PostBreach(object):
try:
LOG.debug("Executing PBA: '{}'".format(pba.name))
pba.run()
LOG.debug(f"Execution of {pba.name} finished")
except Exception as e:
LOG.error("PBA {} failed. Error info: {}".format(pba.name, e))