From 8dc24e9e26d28e00a892e68a81909bef8f235c69 Mon Sep 17 00:00:00 2001 From: Tib3rius <48113936+Tib3rius@users.noreply.github.com> Date: Thu, 7 Mar 2019 18:33:25 -0500 Subject: [PATCH] Fixed a bug where event loop would be closed before another host was scanned. --- autorecon.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/autorecon.py b/autorecon.py index f71983d..cb1f031 100644 --- a/autorecon.py +++ b/autorecon.py @@ -417,8 +417,6 @@ async def scan_services(loop, semaphore, target): pending.add(asyncio.ensure_future(run_cmd(semaphore, e(command), target, tag))) - loop.stop() - def scan_host(target, concurrent_scans): info('Scanning target {byellow}{target.address}{rst}') @@ -453,14 +451,10 @@ def scan_host(target, concurrent_scans): semaphore = asyncio.Semaphore(concurrent_scans) try: - loop.create_task(scan_services(loop, semaphore, target)) - loop.run_forever() - except KeyboardInterrupt: - pass - finally: - loop.close() + loop.run_until_complete(scan_services(loop, semaphore, target)) info('Finished scanning target {byellow}{target.address}{rst}') - return + except KeyboardInterrupt: + sys.exit(1) class Target: def __init__(self, address):