Skip to content

Commit 94c2884

Browse files
committed
Update atexec.py to prevent detectino with hardcoded timestamp
1 parent ab579b3 commit 94c2884

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

nxc/modules/schtask_as.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def output_callback(self, data):
166166
self.__outputBuffer = data
167167

168168
def get_end_boundary(self):
169-
# Get current date and time
169+
# Get current date and time + 5 minutes
170170
end_boundary = datetime.now() + timedelta(minutes=5)
171171

172172
# Format it to match the format in the XML: "YYYY-MM-DDTHH:MM:SS.ssssss"

nxc/protocols/smb/atexec.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_GSS_NEGOTIATE, RPC_C_AUTHN_LEVEL_PKT_PRIVACY
55
from nxc.helpers.misc import gen_random_string
66
from time import sleep
7+
from datetime import datetime, timedelta
78

89

910
class TSCH_EXEC:
@@ -60,17 +61,20 @@ def execute(self, command, output=False):
6061
def output_callback(self, data):
6162
self.__outputBuffer = data
6263

64+
def get_end_boundary(self):
65+
# Get current date and time + 5 minutes
66+
end_boundary = datetime.now() + timedelta(minutes=5)
67+
68+
# Format it to match the format in the XML: "YYYY-MM-DDTHH:MM:SS.ssssss"
69+
return end_boundary.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
70+
6371
def gen_xml(self, command, fileless=False):
64-
xml = """<?xml version="1.0" encoding="UTF-16"?>
72+
xml = f"""<?xml version="1.0" encoding="UTF-16"?>
6573
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
6674
<Triggers>
67-
<CalendarTrigger>
68-
<StartBoundary>2015-07-15T20:35:13.2757294</StartBoundary>
69-
<Enabled>true</Enabled>
70-
<ScheduleByDay>
71-
<DaysInterval>1</DaysInterval>
72-
</ScheduleByDay>
73-
</CalendarTrigger>
75+
<RegistrationTrigger>
76+
<EndBoundary>{self.get_end_boundary()}</EndBoundary>
77+
</RegistrationTrigger>
7478
</Triggers>
7579
<Principals>
7680
<Principal id="LocalSystem">

0 commit comments

Comments
 (0)