Skip to content

Commit 0442376

Browse files
committed
Add error handling for protocol level
1 parent 1645f67 commit 0442376

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nxc/netexec.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ def create_db_engine(db_path):
4444

4545

4646
async def start_run(protocol_obj, args, db, targets):
47+
futures = []
4748
nxc_logger.debug("Creating ThreadPoolExecutor")
4849
if args.no_progress or len(targets) == 1:
4950
with ThreadPoolExecutor(max_workers=args.threads + 1) as executor:
5051
nxc_logger.debug(f"Creating thread for {protocol_obj}")
51-
_ = [executor.submit(protocol_obj, args, db, target) for target in targets]
52+
futures = [executor.submit(protocol_obj, args, db, target) for target in targets]
5253
else:
5354
with Progress(console=nxc_console) as progress, ThreadPoolExecutor(max_workers=args.threads + 1) as executor:
5455
current = 0
@@ -62,6 +63,11 @@ async def start_run(protocol_obj, args, db, targets):
6263
for _ in as_completed(futures):
6364
current += 1
6465
progress.update(tasks, completed=current)
66+
for future in as_completed(futures):
67+
try:
68+
future.result()
69+
except Exception:
70+
nxc_logger.exception(f"Exception for target {targets[futures.index(future)]}: {future.exception()}")
6571

6672

6773
def main():

0 commit comments

Comments
 (0)