From ef115eb3da57d175506703686ae7f2ab711008f9 Mon Sep 17 00:00:00 2001 From: acidvegas Date: Tue, 11 Feb 2025 21:21:45 -0500 Subject: [PATCH] fuck --- httpz_scanner/__init__.py | 2 +- httpz_scanner/cli.py | 9 +++++++-- httpz_scanner/scanner.py | 32 +++++--------------------------- setup.py | 2 +- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/httpz_scanner/__init__.py b/httpz_scanner/__init__.py index 5e70c67..9e49387 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.3' \ No newline at end of file +__version__ = '2.0.4' \ No newline at end of file diff --git a/httpz_scanner/cli.py b/httpz_scanner/cli.py index 25430c4..735157d 100644 --- a/httpz_scanner/cli.py +++ b/httpz_scanner/cli.py @@ -132,7 +132,6 @@ async def main(): show_fields = {k: True for k in show_fields} try: - # Create scanner instance scanner = HTTPZScanner( concurrent_limit=args.concurrent, timeout=args.timeout, @@ -149,8 +148,14 @@ async def main(): shard=args.shard ) - # Run the scanner and process results + # Run the scanner and handle output in ONE place 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)) else: diff --git a/httpz_scanner/scanner.py b/httpz_scanner/scanner.py index 6220510..f07f101 100644 --- a/httpz_scanner/scanner.py +++ b/httpz_scanner/scanner.py @@ -74,6 +74,7 @@ class HTTPZScanner: self.exclude_codes = exclude_codes self.resolvers = None self.processed_domains = 0 + self.progress_count = 0 async def init(self): @@ -179,33 +180,10 @@ class HTTPZScanner: async def process_result(self, result): - ''' - Process and output a single result - - :param result: result to process - ''' - - formatted = format_console_output(result, self.debug_mode, self.show_fields, self.match_codes, self.exclude_codes) - - if formatted: - # Write to file if specified - if self.output_file: - if (not self.match_codes or result['status'] in self.match_codes) and \ - (not self.exclude_codes or result['status'] not in self.exclude_codes): - async with aiohttp.ClientSession() as session: - with open(self.output_file, 'a') as f: - json.dump(result, f, ensure_ascii=False) - f.write('\n') - - # Console output - if self.jsonl_output: - print(json.dumps(result)) - else: - self.processed_domains += 1 - if self.show_progress: - info(f"{Colors.GRAY}[{self.processed_domains:,}]{Colors.RESET} {formatted}") - else: - info(formatted) + '''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): diff --git a/setup.py b/setup.py index 424e1d1..7d591d1 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.3', + version='2.0.4', author='acidvegas', author_email='acid.vegas@acid.vegas', description='Hyper-fast HTTP Scraping Tool',