# Author: perp import json import os import shutil import sys # Check arguments if len(sys.argv) < 3: print("You are missing an argument! (Requires: json & folder)") exit() # Json & folder scan_json = str(sys.argv[1]) scan_folder = str(sys.argv[2]) # Path doesn't exist, make if not os.path.isdir(scan_folder): os.makedirs(f"{scan_folder}/domains") # Path exists, remove, remake elif os.path.isdir(scan_folder): shutil.rmtree(f"{scan_folder}/domains", ignore_errors=True) os.makedirs(f"{scan_folder}/domains") # Open json file with open(scan_json, "r") as f: # Go through each line for line in f.readlines(): # Load json, get domain & vulnerability line = json.loads(line) domain = str(line["host"]).replace("http://", "").replace("https://", "").replace("www.", "").split("/")[0] vulnerability = line["template-id"] # Path doesn't exist, make if not os.path.exists(f"{scan_folder}/domains/{domain}"): os.mkdir(f"{scan_folder}/domains/{domain}") # Domain on current line if domain in line["host"]: # Path doesn't exist, make if not os.path.exists(f"{scan_folder}/domains/{domain}/{vulnerability}"): os.mkdir(f"{scan_folder}/domains/{domain}/{vulnerability}") # Text key to file if "extracted-results" in line: # Open text file with open(f"{scan_folder}/domains/{domain}/{vulnerability}/{vulnerability}.txt", "a") as v: # Get each result & go through results = line["extracted-results"] for extracted in results: v.write(extracted+"\n") # Open json file with open(f"{scan_folder}/domains/{domain}/{vulnerability}/{vulnerability}.json", "a") as v: json.dump(line, v, indent=4)