Skip to content

Instantly share code, notes, and snippets.

@emadshanab
Forked from ajxchapman/burp_scopes.py
Created June 27, 2023 14:30
Show Gist options
  • Select an option

  • Save emadshanab/35a181c2d2c1c15025a47324ebb06fec to your computer and use it in GitHub Desktop.

Select an option

Save emadshanab/35a181c2d2c1c15025a47324ebb06fec to your computer and use it in GitHub Desktop.
Turn a list of scopes into a Burpsuite target import JSON configuration file
import json
import re
import sys
scopes = []
f = sys.stdin
if len(sys.argv) == 2:
f = open(sys.argv[1])
scopes_defs = [x.strip().lower() for x in f.readlines() if len(x.strip())]
for scope_def in scopes_defs:
scope = {
"enabled" : True,
"host" : scope_def,
"protocol" : "any"
}
if scope["host"].startswith("http://") or scope["host"].startswith("https://"):
scope["protocol"], scope["host"] = scope["host"].split("//", 1)
scope["protocol"] = scope["protocol"].rstrip(":")
if scope["host"].startswith("*"):
scope["host"] = ".*{}$".format(re.escape(scope["host"].lstrip("*")))
if "/" in scope["host"]:
scope["host"], scope["file"] = scope["host"].split("/", 1)
if not len(scope["file"]):
del scope["file"]
else:
scope["file"] = "^/{}.*".format(re.escape(scope["file"].rstrip("*")))
if ":" in scope["host"]:
scope["host"], scope["port"] = scope["host"].split(":", 1)
scopes.append(scope)
print(json.dumps({
"target": {
"scope": {
"advanced_mode": True,
"exclude": [],
"include": scopes
}
}
}, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment