Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --user-agent and -user-agent-suffix CLI options #2190

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bbot/scanner/preset/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -348,6 +363,15 @@ 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=argparse.SUPPRESS,
metavar="SUFFIX",
default=None
)
return p

def sanitize_args(self):
Expand Down
Loading