From 2a25a9807d5a5cabd3d10ae5884166c87153678e Mon Sep 17 00:00:00 2001 From: Sudarshan Date: Tue, 24 Mar 2026 01:22:37 +0530 Subject: [PATCH 1/4] Enhance CLI error handling with argument suggestions --- nettacker/core/arg_parser.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/nettacker/core/arg_parser.py b/nettacker/core/arg_parser.py index 459d7c9b2..d264bce65 100644 --- a/nettacker/core/arg_parser.py +++ b/nettacker/core/arg_parser.py @@ -1,7 +1,7 @@ import json import sys from argparse import ArgumentParser - +import difflib import yaml from nettacker import all_module_severity_and_desc @@ -383,7 +383,7 @@ def add_arguments(self): method_options.add_argument( "--set-hardware-usage", action="store", - dest="set_hardware_usage", + deimport difflibst="set_hardware_usage", default=Config.settings.set_hardware_usage, help=_("set_hardware_usage"), ) @@ -518,7 +518,27 @@ def parse_arguments(self): all ARGS with applied rules """ # Checking Requirements - options = self.api_arguments or self.parse_args() + if self.api_arguments: + options = self.api_arguments + else: + known_args, unknown_args = self.parse_known_args() + + if unknown_args: + valid_flags = [] + for action in self._actions: + valid_flags.extend(action.option_strings) + + for arg in unknown_args: + if arg.startswith("-") and len(arg) > 1: + suggestion = difflib.get_close_matches(arg, valid_flags, n=1) + if suggestion: + print(f"Error: Unknown argument '{arg}'. Did you mean '{suggestion[0]}'?") + else: + print(f"Error: Unknown argument '{arg}'") + + sys.exit(1) + + options = known_args if options.language not in self.languages: die_failure("Please select one of these languages {0}".format(self.languages)) From ad5461b29c3afad3f886e0bded61dd271e18777a Mon Sep 17 00:00:00 2001 From: Sudarshan Date: Tue, 24 Mar 2026 01:43:26 +0530 Subject: [PATCH 2/4] Fix README formatting issue for feature list --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ef1ba629..da17cb350 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,14 @@ OWASP Nettacker OWASP Nettacker is an open-source, Python-based automated penetration testing and information-gathering framework designed to help cyber security professionals and ethical hackers perform reconnaissance, vulnerability assessments, and network security audits efficiently. Nettacker automates tasks like port scanning, service detection, subdomain enumeration, network mapping, vulnerability scanning, credential brute-force testing making it a powerful tool for identifying weaknesses in networks, web applications, IoT devices and APIs. ### Key Features - - **Modular architecture** - Each task — like port scanning, directory discovery, subdomain enumeration, vulnerability checks, or credential brute-forcing - is implemented as its own module, giving you control over what runs. - **Multi-protocol & multithreaded scanning** - Supports HTTP/HTTPS, FTP, SSH, SMB, SMTP, ICMP, TELNET, XML-RPC, and can run scans in parallel for speed. - **Comprehensive output** - Export reports in HTML, JSON, CSV, and plain text. - **Built-in database & drift detection** - Stores past scans in the database for easy search and comparison with current results: useful to detect new hosts, open ports, or vulnerabilities in CI/CD pipelines. - **CLI, REST API & Web UI** - Offers both programmatic integration and a user-friendly web interface for defining scans and viewing results. - **Evasion techniques** - Enables configurable delays, proxy support, and randomized user-agents to reduce detection by firewalls or IDS systems. -- **Flexible targets** - Accepts single IPv4s, IP ranges, CIDR blocks, domain names, and full HTTP/HTTPS URLs. Targets can be mixed in a single command or loaded from a file using the `-l/--targets-list` flag. +- **Flexible targets**: Accepts single IPv4s, IP ranges, CIDR blocks, domain names, and full HTTP/HTTPS URLs. +These methods ensure full compatibility and avoid runtime errors ### Use Cases From 249b8fcbc6b84b5f3578653532f78db20fce1deb Mon Sep 17 00:00:00 2001 From: Sudarshan Date: Tue, 24 Mar 2026 02:31:21 +0530 Subject: [PATCH 3/4] Fix syntax error and improve handling of unexpected positional arguments --- nettacker/core/arg_parser.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nettacker/core/arg_parser.py b/nettacker/core/arg_parser.py index d264bce65..e4dd252a6 100644 --- a/nettacker/core/arg_parser.py +++ b/nettacker/core/arg_parser.py @@ -383,7 +383,7 @@ def add_arguments(self): method_options.add_argument( "--set-hardware-usage", action="store", - deimport difflibst="set_hardware_usage", + dest="set_hardware_usage", default=Config.settings.set_hardware_usage, help=_("set_hardware_usage"), ) @@ -529,12 +529,17 @@ def parse_arguments(self): valid_flags.extend(action.option_strings) for arg in unknown_args: - if arg.startswith("-") and len(arg) > 1: + if arg.startswith("--") and len(arg) > 1: suggestion = difflib.get_close_matches(arg, valid_flags, n=1) if suggestion: - print(f"Error: Unknown argument '{arg}'. Did you mean '{suggestion[0]}'?") + print( + f"Error: Unknown argument '{arg}'. Did you mean '{suggestion[0]}'?", + file=sys.stderr, + ) else: - print(f"Error: Unknown argument '{arg}'") + print(f"Error: Unknown argument '{arg}'", file=sys.stderr) + else: + print(f"Error: Unexpected argument '{arg}'", file=sys.stderr) sys.exit(1) From 634964e9f23b5aa3e960d574b358ec246f326f66 Mon Sep 17 00:00:00 2001 From: Sudarshan Date: Tue, 24 Mar 2026 17:17:01 +0530 Subject: [PATCH 4/4] Fix import order and pre-commit issues --- nettacker/core/arg_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nettacker/core/arg_parser.py b/nettacker/core/arg_parser.py index e4dd252a6..4e8faa60a 100644 --- a/nettacker/core/arg_parser.py +++ b/nettacker/core/arg_parser.py @@ -1,7 +1,8 @@ +import difflib import json import sys from argparse import ArgumentParser -import difflib + import yaml from nettacker import all_module_severity_and_desc