Skip to content

Commit 64f0f78

Browse files
committed
Remove useless code and formating
1 parent 94c2884 commit 64f0f78

2 files changed

Lines changed: 5 additions & 16 deletions

File tree

nxc/modules/schtask_as.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def on_admin_login(self, context, connection):
9595
else:
9696
self.logger.fail(f"Failed to execute command: {e}")
9797

98+
9899
class TSCH_EXEC:
99100
def __init__(self, target, share_name, username, password, domain, user, cmd, file, task, location, doKerberos=False, aesKey=None, remoteHost=None, kdcHost=None, hashes=None, logger=None, tries=None, share=None):
100101
self.__target = target
@@ -156,7 +157,7 @@ def deleteartifact(self):
156157
self.logger.display(f"Deleting task \\{tmpName}")
157158
tsch.hSchRpcDelete(dce, f"\\{tmpName}")
158159
dce.disconnect()
159-
160+
160161
def execute(self, command, output=False):
161162
self.__retOutput = output
162163
self.execute_handler(command)
@@ -245,7 +246,6 @@ def execute_handler(self, command, fileless=False):
245246
xml = self.gen_xml(command, fileless)
246247

247248
self.logger.info(f"Task XML: {xml}")
248-
taskCreated = False
249249
self.logger.info(f"Creating task \\{tmpName}")
250250
try:
251251
# windows server 2003 has no MSRPC_UUID_TSCHS, if it bind, it will return abstract_syntax_not_supported
@@ -270,10 +270,10 @@ def execute_handler(self, command, fileless=False):
270270
self.logger.fail(f"Schtask_as: Create schedule task failed: {e}")
271271
tsch.hSchRpcDelete(dce, f"\\{tmpName}")
272272
return
273-
else:
274-
taskCreated = True
273+
275274
self.logger.info(f"Running task \\{tmpName}")
276-
tsch.hSchRpcRun(dce, f"\\{tmpName}")
275+
tsch.hSchRpcRun(dce, f"\\{tmpName}")
276+
277277
done = False
278278
while not done:
279279
self.logger.debug(f"Calling SchRpcGetLastRunInfo for \\{tmpName}")
@@ -285,10 +285,6 @@ def execute_handler(self, command, fileless=False):
285285

286286
self.logger.info(f"Deleting task \\{tmpName}")
287287
tsch.hSchRpcDelete(dce, f"\\{tmpName}")
288-
taskCreated = False
289-
290-
if taskCreated is True:
291-
tsch.hSchRpcDelete(dce, f"\\{tmpName}")
292288

293289
if self.__retOutput:
294290
if fileless:

nxc/protocols/smb/atexec.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def execute_handler(self, command, fileless=False):
138138
xml = self.gen_xml(command, fileless)
139139

140140
self.logger.debug(f"Task XML: {xml}")
141-
taskCreated = False
142141
self.logger.info(f"Creating task \\{tmpName}")
143142
try:
144143
# windows server 2003 has no MSRPC_UUID_TSCHS, if it bind, it will return abstract_syntax_not_supported
@@ -151,8 +150,6 @@ def execute_handler(self, command, fileless=False):
151150
else:
152151
self.logger.fail(str(e))
153152
return
154-
else:
155-
taskCreated = True
156153

157154
self.logger.info(f"Running task \\{tmpName}")
158155
tsch.hSchRpcRun(dce, f"\\{tmpName}")
@@ -168,10 +165,6 @@ def execute_handler(self, command, fileless=False):
168165

169166
self.logger.info(f"Deleting task \\{tmpName}")
170167
tsch.hSchRpcDelete(dce, f"\\{tmpName}")
171-
taskCreated = False
172-
173-
if taskCreated is True:
174-
tsch.hSchRpcDelete(dce, f"\\{tmpName}")
175168

176169
if self.__retOutput:
177170
if fileless:

0 commit comments

Comments
 (0)