diff --git a/httpz_scanner/__init__.py b/httpz_scanner/__init__.py index 9e49387..99c8c3d 100644 --- a/httpz_scanner/__init__.py +++ b/httpz_scanner/__init__.py @@ -6,4 +6,4 @@ from .scanner import HTTPZScanner from .colors import Colors -__version__ = '2.0.4' \ No newline at end of file +__version__ = '2.0.5' \ No newline at end of file diff --git a/httpz_scanner/cli.py b/httpz_scanner/cli.py index 735157d..93b24d3 100644 --- a/httpz_scanner/cli.py +++ b/httpz_scanner/cli.py @@ -148,18 +148,23 @@ async def main(): shard=args.shard ) - # Run the scanner and handle output in ONE place + # Run the scanner and handle ALL output here + count = 0 async for result in scanner.scan(args.file): # Write to output file if specified if args.output: with open(args.output, 'a') as f: f.write(json.dumps(result) + '\n') - # Print to console based on format - if args.jsonl: - print(json.dumps(result)) + # Console output + if args.progress: + count += 1 + info(f"[{count}] {format_console_output(result, args.debug, show_fields, args.match_codes, args.exclude_codes)}") else: - print(format_console_output(result, args.debug, show_fields, args.match_codes, args.exclude_codes)) + if args.jsonl: + print(json.dumps(result)) + else: + print(format_console_output(result, args.debug, show_fields, args.match_codes, args.exclude_codes)) except KeyboardInterrupt: logging.warning('Process interrupted by user') diff --git a/httpz_scanner/scanner.py b/httpz_scanner/scanner.py index f07f101..553d27c 100644 --- a/httpz_scanner/scanner.py +++ b/httpz_scanner/scanner.py @@ -179,13 +179,6 @@ class HTTPZScanner: return result - async def process_result(self, result): - '''Process a scan result''' - if self.show_progress: - self.progress_count += 1 - info(f'[{self.progress_count}] {format_console_output(result, self.debug_mode, self.show_fields, self.match_codes, self.exclude_codes)}') - - async def scan(self, input_source): ''' Scan domains from a file, stdin, or async generator @@ -203,6 +196,7 @@ class HTTPZScanner: async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session: tasks = set() + count = 0 # Move counter here since that's all process_result was doing # Handle different input types if isinstance(input_source, str): @@ -215,7 +209,8 @@ class HTTPZScanner: ) for task in done: result = await task - await self.process_result(result) + if self.show_progress: + count += 1 # Increment counter here yield result task = asyncio.create_task(self.check_domain(session, domain)) @@ -231,7 +226,8 @@ class HTTPZScanner: ) for task in done: result = await task - await self.process_result(result) + if self.show_progress: + count += 1 yield result task = asyncio.create_task(self.check_domain(session, domain)) @@ -252,7 +248,8 @@ class HTTPZScanner: ) for task in done: result = await task - await self.process_result(result) + if self.show_progress: + count += 1 yield result task = asyncio.create_task(self.check_domain(session, domain)) @@ -264,5 +261,6 @@ class HTTPZScanner: done, _ = await asyncio.wait(tasks) for task in done: result = await task - await self.process_result(result) + if self.show_progress: + count += 1 yield result \ No newline at end of file diff --git a/setup.py b/setup.py index 7d591d1..073e9f4 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open('README.md', 'r', encoding='utf-8') as f: setup( name='httpz_scanner', - version='2.0.4', + version='2.0.5', author='acidvegas', author_email='acid.vegas@acid.vegas', description='Hyper-fast HTTP Scraping Tool',