Skip to content

Instantly share code, notes, and snippets.

@vitorfhc
Created May 18, 2024 16:09
Show Gist options
  • Save vitorfhc/3050867d795772bd7465b284180c90bc to your computer and use it in GitHub Desktop.
Save vitorfhc/3050867d795772bd7465b284180c90bc to your computer and use it in GitHub Desktop.
Receives a list of domains from the stdin and add them to the Burp project settings passed in the arguments
import sys
import json
def escape_dots(line):
return line.replace(".", "\\.")
def main():
if len(sys.argv) != 2:
print("Usage: script.py <path_to_json_file>")
sys.exit(1)
json_file_path = sys.argv[1]
try:
with open(json_file_path, "r", encoding="utf-8") as json_file:
data = json.load(json_file)
except FileNotFoundError:
print(f"Error: File '{json_file_path}' not found.")
sys.exit(1)
except json.JSONDecodeError:
print(f"Error: File '{json_file_path}' is not a valid JSON file.")
sys.exit(1)
included_scope = data.get("target", {}).get("scope", {}).get("include", [])
for line in sys.stdin:
escaped_line = escape_dots(line.strip())
new_scope = {"enabled": True, "host": escaped_line, "protocol": "any"}
included = False
for scope in included_scope:
if scope.get("host") == escaped_line:
included = True
break
if not included:
included_scope.append(new_scope)
print(f"Added '{escaped_line}' to the scope.")
with open(json_file_path, "w", encoding="utf-8") as json_file:
json.dump(data, json_file, indent=4)
print(f"Successfully updated '{json_file_path}'.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment