Skip to content

Instantly share code, notes, and snippets.

@ajxchapman
Created March 25, 2020 19:53
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ajxchapman/443c1673e0948f92e59452e3b5951c99 to your computer and use it in GitHub Desktop.
Save ajxchapman/443c1673e0948f92e59452e3b5951c99 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