Skip to content

Commit 50edae4

Browse files
committed
Fix command execution in modules with output but no line printing
1 parent e99e5c2 commit 50edae4

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

nxc/protocols/wmi.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,20 @@ def wmi(self, wql=None, namespace=None):
411411
@requires_admin
412412
def execute(self, command=None, get_output=False):
413413
output = ""
414-
if not command:
415-
command = self.args.execute
416414

417-
if not self.args.no_output:
418-
get_output = True
415+
# Execution via -x
416+
if not command and self.args.execute:
417+
command = self.args.execute
418+
if not self.args.no_output:
419+
get_output = True
419420

420421
if "systeminfo" in command and self.args.exec_timeout < 10:
421422
self.logger.fail("Execute 'systeminfo' must set the interval time higher than 10 seconds")
422-
return False
423+
return ""
423424

424425
if self.server_os is not None and "NT 5" in self.server_os:
425426
self.logger.fail("Execute command failed, not support current server os (version < NT 6)")
426-
return False
427+
return ""
427428

428429
if self.args.exec_method == "wmiexec":
429430
exec_method = wmiexec.WMIEXEC(self.remoteName, self.username, self.password, self.domain, self.lmhash, self.nthash, self.doKerberos, self.kdcHost, self.host, self.aesKey, self.logger, self.args.exec_timeout, self.args.codec)
@@ -436,10 +437,12 @@ def execute(self, command=None, get_output=False):
436437
self.conn.disconnect()
437438
if output == "" and get_output:
438439
self.logger.fail("Execute command failed, probabaly got detection by AV.")
439-
return False
440-
else:
440+
return ""
441+
elif self.args.execute and get_output:
441442
self.logger.success(f'Executed command: "{command}" via {self.args.exec_method}')
442443
buf = StringIO(output).readlines()
443444
for line in buf:
444445
self.logger.highlight(line.strip())
445446
return output
447+
elif get_output:
448+
return output

0 commit comments

Comments
 (0)