Skip to content

Commit 0175be7

Browse files
committed
Added example path and os.path.join for flexibility
1 parent 755113d commit 0175be7

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

nxc/modules/schtask_as.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ class NXCModule:
1515
"""
1616

1717
def options(self, context, module_options):
18-
"""
18+
r"""
1919
CMD Command to execute
2020
USER User to execute command as
2121
TASK OPTIONAL: Set a name for the scheduled task name
2222
FILE OPTIONAL: Set a name for the command output file
23-
LOCATION OPTIONAL: Set a location for the command output file
23+
LOCATION OPTIONAL: Set a location for the command output file (e.g. '\tmp\')
2424
"""
2525
self.cmd = self.user = self.task = self.file = self.location = self.time = None
2626
if "CMD" in module_options:
2727
self.cmd = module_options["CMD"]
2828

2929
if "USER" in module_options:
3030
self.user = module_options["USER"]
31-
31+
3232
if "TASK" in module_options:
3333
self.task = module_options["TASK"]
34-
34+
3535
if "FILE" in module_options:
3636
self.file = module_options["FILE"]
37-
37+
3838
if "LOCATION" in module_options:
3939
self.location = module_options["LOCATION"]
40-
40+
4141
name = "schtask_as"
4242
description = "Remotely execute a scheduled task as a logged on user"
4343
supported_protocols = ["smb"]
@@ -117,7 +117,6 @@ def __init__(self, target, share_name, username, password, domain, user, cmd, fi
117117
self.file = file
118118
self.task = task
119119
self.location = location
120-
121120

122121
if hashes is not None:
123122
if hashes.find(":") != -1:
@@ -202,9 +201,9 @@ def gen_xml(self, command, fileless=False):
202201
if self.__retOutput:
203202
fileLocation = "\\Windows\\Temp\\" if self.location is None else self.location
204203
if self.file is None:
205-
self.__output_filename = f"{fileLocation}{gen_random_string(6)}"
206-
else:
207-
self.__output_filename = f"{fileLocation}{self.file}"
204+
self.__output_filename = os.path.join(fileLocation, gen_random_string(6))
205+
else:
206+
self.__output_filename = os.path.join(fileLocation, self.file)
208207
if fileless:
209208
local_ip = self.__rpctransport.get_socket().getsockname()[0]
210209
argument_xml = f" <Arguments>/C {command} &gt; \\\\{local_ip}\\{self.__share_name}\\{self.__output_filename} 2&gt;&amp;1</Arguments>"

0 commit comments

Comments
 (0)