Skip to content

Commit

Permalink
Merge pull request #176 from Pennyw0rth/neff-error-handling
Browse files Browse the repository at this point in the history
Add error handling for protocol level
  • Loading branch information
Marshall-Hallenbeck authored Feb 22, 2024
2 parents a69f3e7 + 3c39b94 commit 49ca92d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nxc/netexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@


async def start_run(protocol_obj, args, db, targets):
futures = []
nxc_logger.debug("Creating ThreadPoolExecutor")
if args.no_progress or len(targets) == 1:
with ThreadPoolExecutor(max_workers=args.threads + 1) as executor:
nxc_logger.debug(f"Creating thread for {protocol_obj}")
_ = [executor.submit(protocol_obj, args, db, target) for target in targets]
futures = [executor.submit(protocol_obj, args, db, target) for target in targets]
else:
with Progress(console=nxc_console) as progress, ThreadPoolExecutor(max_workers=args.threads + 1) as executor:
current = 0
Expand All @@ -57,6 +58,11 @@ async def start_run(protocol_obj, args, db, targets):
for _ in as_completed(futures):
current += 1
progress.update(tasks, completed=current)
for future in as_completed(futures):
try:
future.result()
except Exception:
nxc_logger.exception(f"Exception for target {targets[futures.index(future)]}: {future.exception()}")


def main():
Expand Down

0 comments on commit 49ca92d

Please sign in to comment.