Skip to content

Commit 4c25688

Browse files
committed
Add more flexibility to account for possible attacker time skew and delete task even when erroring
1 parent 5a756f1 commit 4c25688

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

nxc/protocols/smb/atexec.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def output_callback(self, data):
7474
self.__outputBuffer = data
7575

7676
def get_end_boundary(self):
77-
# Get current date and time + 5 minutes
78-
end_boundary = datetime.now() + timedelta(minutes=5)
77+
# Get current date and time + 1 day
78+
end_boundary = datetime.now() + timedelta(days=1)
7979

8080
# Format it to match the format in the XML: "YYYY-MM-DDTHH:MM:SS.ssssss"
8181
return end_boundary.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
@@ -196,14 +196,17 @@ def execute_handler(self, command):
196196
self.logger.fail(str(e))
197197
return
198198

199-
done = False
200-
while not done:
201-
self.logger.debug(f"Calling SchRpcGetLastRunInfo for \\{self.task_name}")
202-
resp = tsch.hSchRpcGetLastRunInfo(dce, f"\\{self.task_name}")
203-
if resp["pLastRuntime"]["wYear"] != 0:
204-
done = True
205-
else:
206-
sleep(2)
199+
try:
200+
done = False
201+
while not done:
202+
self.logger.debug(f"Calling SchRpcGetLastRunInfo for \\{self.task_name}")
203+
resp = tsch.hSchRpcGetLastRunInfo(dce, f"\\{self.task_name}")
204+
if resp["pLastRuntime"]["wYear"] != 0:
205+
done = True
206+
else:
207+
sleep(2)
208+
except tsch.DCERPCSessionError as e:
209+
self.logger.fail(f"Error retrieving task last run info: {e}")
207210

208211
self.logger.info(f"Deleting task \\{self.task_name}")
209212
tsch.hSchRpcDelete(dce, f"\\{self.task_name}")

0 commit comments

Comments
 (0)