Skip to content

Commit 23a7d11

Browse files
fix: revert output for command execution and normalize it to what SMB was
1 parent e10e38f commit 23a7d11

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

nxc/protocols/mssql.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import random
33
import socket
44
import contextlib
5+
from io import StringIO
56

67
from nxc.config import process_secret
78
from nxc.connection import connection
@@ -317,8 +318,9 @@ def execute(self, payload=None, get_output=False):
317318
return False
318319
else:
319320
self.logger.success("Executed command via mssqlexec")
320-
if get_output:
321-
self.logger.highlight(output)
321+
output_lines = StringIO(output).readlines()
322+
for line in output_lines:
323+
self.logger.highlight(line.strip())
322324
return output
323325

324326
@requires_admin

nxc/protocols/smb.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import binascii
33
import os
44
import re
5+
from io import StringIO
56
from Cryptodome.Hash import MD4
67

78
from impacket.smbconnection import SMBConnection, SessionError
@@ -691,8 +692,9 @@ def execute(self, payload=None, get_output=False, methods=None):
691692

692693
if (self.args.execute or self.args.ps_execute) and output:
693694
self.logger.success(f"Executed command via {current_method}")
694-
if output:
695-
self.logger.highlight(output)
695+
output_lines = StringIO(output).readlines()
696+
for line in output_lines:
697+
self.logger.highlight(line.strip())
696698
return output
697699
else:
698700
self.logger.fail(f"Execute command failed with {current_method}")

0 commit comments

Comments
 (0)