Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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"]
scope["file"] = "^/{}.*".format(re.escape(scope["file"].rstrip("*")))
if ":" in scope["host"]:
scope["host"], scope["port"] = scope["host"].split(":", 1)
"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