Skip to content

Commit c1dfefd

Browse files
committed
Use build in exception traceback instead of traceback.format_exc
1 parent ed4e4a1 commit c1dfefd

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

nxc/protocols/smb.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -981,12 +981,12 @@ def taskkill(self):
981981
if self.args.taskkill.isdigit():
982982
pidList = [int(self.args.taskkill)]
983983
else:
984-
r = legacy.hRpcWinStationGetAllProcesses(handle)
985-
if not r:
984+
res = legacy.hRpcWinStationGetAllProcesses(handle)
985+
if not res:
986986
self.logger.error("Could not get process list")
987987
return
988988

989-
pidList = [i["UniqueProcessId"] for i in r if i["ImageName"].lower() == self.args.taskkill.lower()]
989+
pidList = [i["UniqueProcessId"] for i in res if i["ImageName"].lower() == self.args.taskkill.lower()]
990990
if not pidList:
991991
self.logger.fail(f"Could not find process named {self.args.taskkill}")
992992
return
@@ -997,9 +997,8 @@ def taskkill(self):
997997
self.logger.highlight(f"Terminated PID {pid} ({self.args.taskkill})")
998998
else:
999999
self.logger.fail(f"Failed terminating PID {pid}")
1000-
except Exception:
1001-
import traceback
1002-
self.logger.error(f"Error terminating PID {pid}: {traceback.format_exc()}")
1000+
except Exception as e:
1001+
self.logger.exception(f"Error terminating PID {pid}: {e}")
10031002

10041003
@requires_admin
10051004
def qwinsta(self):

0 commit comments

Comments
 (0)