From 2b7e5407b223efcc445d014bf605a6c98fc24410 Mon Sep 17 00:00:00 2001 From: liquidsec Date: Fri, 17 Jan 2025 17:05:03 -0500 Subject: [PATCH 1/3] adding -ua and -uas cli options --- bbot/scanner/preset/args.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bbot/scanner/preset/args.py b/bbot/scanner/preset/args.py index b5f1b1849..8c1818aea 100644 --- a/bbot/scanner/preset/args.py +++ b/bbot/scanner/preset/args.py @@ -168,6 +168,21 @@ def preset_from_args(self): {"modules": {"excavate": {"custom_yara_rules": self.parsed.custom_yara_rules}}} ) + # Check if both user_agent and user_agent_suffix are set. If so combine them and merge into the config + if self.parsed.user_agent and self.parsed.user_agent_suffix: + modified_user_agent = f"{self.parsed.user_agent} {self.parsed.user_agent_suffix}" + args_preset.core.merge_custom({"web": {"user_agent": modified_user_agent}}) + + # If only user_agent_suffix is set, retrieve the existing user_agent from the merged config and append the suffix + elif self.parsed.user_agent_suffix: + existing_user_agent = args_preset.core.config.get("web", {}).get("user_agent", "") + modified_user_agent = f"{existing_user_agent} {self.parsed.user_agent_suffix}" + args_preset.core.merge_custom({"web": {"user_agent": modified_user_agent}}) + + # If only user_agent is set, merge it directly + elif self.parsed.user_agent: + args_preset.core.merge_custom({"web": {"user_agent": self.parsed.user_agent}}) + # CLI config options (dot-syntax) for config_arg in self.parsed.config: try: @@ -348,6 +363,9 @@ def create_parser(self, *args, **kwargs): help="List of custom headers as key value pairs (header=value).", ) misc.add_argument("--custom-yara-rules", "-cy", help="Add custom yara rules to excavate") + + misc.add_argument("--user-agent", "-ua", help="Set the user-agent for all HTTP requests") + misc.add_argument("--user-agent-suffix", "-uas", help="Set a an optional user-agent suffix for all HTTP requests") return p def sanitize_args(self): From 407ad115e0886e9b6dfc99892e3c97c15593cd26 Mon Sep 17 00:00:00 2001 From: liquidsec Date: Tue, 21 Jan 2025 15:09:47 -0500 Subject: [PATCH 2/3] removing --user-agent-suffix from cli for now to keep clutter down --- bbot/scanner/preset/args.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbot/scanner/preset/args.py b/bbot/scanner/preset/args.py index 8c1818aea..46b66e030 100644 --- a/bbot/scanner/preset/args.py +++ b/bbot/scanner/preset/args.py @@ -365,7 +365,7 @@ def create_parser(self, *args, **kwargs): misc.add_argument("--custom-yara-rules", "-cy", help="Add custom yara rules to excavate") misc.add_argument("--user-agent", "-ua", help="Set the user-agent for all HTTP requests") - misc.add_argument("--user-agent-suffix", "-uas", help="Set a an optional user-agent suffix for all HTTP requests") + # misc.add_argument("--user-agent-suffix", "-uas", help="Set a an optional user-agent suffix for all HTTP requests") # Removed to declutter the CLI, maybe re-add in the future return p def sanitize_args(self): From ddb64c3dadc911370240c3f1eac7f3371e16dcbe Mon Sep 17 00:00:00 2001 From: liquidsec Date: Tue, 21 Jan 2025 15:43:27 -0500 Subject: [PATCH 3/3] adding back in while supressing it from help --- bbot/scanner/preset/args.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bbot/scanner/preset/args.py b/bbot/scanner/preset/args.py index 46b66e030..a458a996c 100644 --- a/bbot/scanner/preset/args.py +++ b/bbot/scanner/preset/args.py @@ -365,7 +365,13 @@ def create_parser(self, *args, **kwargs): misc.add_argument("--custom-yara-rules", "-cy", help="Add custom yara rules to excavate") misc.add_argument("--user-agent", "-ua", help="Set the user-agent for all HTTP requests") - # misc.add_argument("--user-agent-suffix", "-uas", help="Set a an optional user-agent suffix for all HTTP requests") # Removed to declutter the CLI, maybe re-add in the future + misc.add_argument( + "--user-agent-suffix", + "-uas", + help=argparse.SUPPRESS, + metavar="SUFFIX", + default=None + ) return p def sanitize_args(self):