Skip to content

Commit 5d70195

Browse files
committed
Fix "Too many files" error from discord
1 parent 9359ac2 commit 5d70195

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

nxc/connection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from impacket.dcerpc.v5 import transport
1616
import sys
17+
import contextlib
1718

1819
sem = BoundedSemaphore(1)
1920
global_failed_logins = 0
@@ -125,6 +126,10 @@ def __init__(self, args, db, host):
125126
self.logger.error(f"Exception while calling proto_flow() on target {self.host}: {e}")
126127
else:
127128
self.logger.exception(f"Exception while calling proto_flow() on target {self.host}: {e}")
129+
finally:
130+
self.logger.debug(f"Closing connection to: {host}")
131+
with contextlib.suppress(Exception):
132+
self.conn.close()
128133

129134
@staticmethod
130135
def proto_args(std_parser, module_parser):

0 commit comments

Comments
 (0)