Skip to content

Commit 9662ef6

Browse files
authored
Merge pull request Pennyw0rth#257 from Pennyw0rth/neff-fix-too-many-files
Fix "Too many open files"
2 parents 7d44b11 + 5d70195 commit 9662ef6

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)