@@ -25,12 +25,16 @@ def options(self, context, module_options):
2525 TASK OPTIONAL: Set a name for the scheduled task name
2626 FILE OPTIONAL: Set a name for the command output file
2727 LOCATION OPTIONAL: Set a location for the command output file (e.g. '\tmp\')
28- """
2928
29+ Example:
30+ -------
31+ nxc smb <ip> -u <user> -p <password> -M schtask_as -o USER=Administrator CMD=whoami
32+ nxc smb <ip> -u <user> -p <password> -M schtask_as -o USER=Administrator CMD='bin.exe --option' BINARY=bin.exe
33+ """
3034 self .cmd = self .binary = self .user = self .task = self .file = self .location = self .time = None
3135 self .share = "C$"
3236 self .tmp_dir = "C:\\ Windows\\ Temp\\ "
33- self .tmp_share = self .tmp_dir .split (":" )[1 ]
37+ self .tmp_share = self .tmp_dir .split (":" )[1 ]
3438
3539 if "CMD" in module_options :
3640 self .cmd = module_options ["CMD" ]
@@ -62,11 +66,11 @@ def on_admin_login(self, context, connection):
6266 if self .cmd is None :
6367 self .logger .fail ("You need to specify a CMD to run" )
6468 return 1
65-
69+
6670 if self .user is None :
6771 self .logger .fail ("You need to specify a USER to run the command as" )
6872 return 1
69-
73+
7074 if self .binary :
7175 if not os .path .isfile (self .binary ):
7276 self .logger .fail (f"Cannot find { self .binary } " )
@@ -75,13 +79,13 @@ def on_admin_login(self, context, connection):
7579 self .logger .display (f"Uploading { self .binary } " )
7680 with open (self .binary , "rb" ) as binary_to_upload :
7781 try :
78- self .binary_name = os .path .basename (self .binary )
82+ self .binary_name = os .path .basename (self .binary )
7983 connection .conn .putFile (self .share , f"{ self .tmp_share } { self .binary_name } " , binary_to_upload .read )
8084 self .logger .success (f"Binary { self .binary_name } successfully uploaded in { self .tmp_share } { self .binary_name } " )
8185 except Exception as e :
8286 self .logger .fail (f"Error writing file to share { self .tmp_share } : { e } " )
8387 return 1
84-
88+
8589 # Returnes self.cmd or \Windows\temp\BinToExecute.exe depending if BINARY=BinToExecute.exe
8690 self .cmd = self .cmd if not self .binary else f"{ self .tmp_share } { self .cmd } "
8791 self .logger .display ("Connecting to the remote Service control endpoint" )
0 commit comments