Skip to content

Commit 136b45c

Browse files
authored
Merge pull request Pennyw0rth#957 from Pennyw0rth/neff-fix-winrm-errors
Add stderr printing to winrm execution
2 parents f981215 + 4d637bc commit 136b45c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

nxc/protocols/winrm.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import logging
66
import xml.etree.ElementTree as ET
77

8-
from io import StringIO
98
from datetime import datetime
109
from pypsrp.wsman import NAMESPACES
1110
from pypsrp.client import Client
@@ -261,8 +260,12 @@ def execute(self, payload=None, get_output=False, shell_type="cmd"):
261260
return result[0]
262261
self.logger.success(f"Executed command (shell type: {shell_type})")
263262
if not self.args.no_output:
264-
for line in StringIO(result[0]).readlines():
265-
self.logger.highlight(line.strip())
263+
if result[2] == 0:
264+
for line in result[0].replace("\r", "").splitlines():
265+
self.logger.highlight(line.strip())
266+
else:
267+
for line in result[1].replace("\r", "").splitlines():
268+
self.logger.fail(line.strip())
266269

267270
def ps_execute(self, payload=None, get_output=False):
268271
command = payload if payload else self.args.ps_execute

0 commit comments

Comments
 (0)