👽 Updated for "new" nuclei JSON
This commit is contained in:
parent
5b49ca21e3
commit
0e96de4a64
49
nukesort.py
49
nukesort.py
|
@ -1,4 +1,6 @@
|
||||||
# Author: perp
|
# Author: perp
|
||||||
|
# Description: Sort nuclei json into folders
|
||||||
|
# Usage: nukesort scan.json results
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -25,32 +27,33 @@ elif os.path.isdir(scan_folder):
|
||||||
|
|
||||||
# Open json file
|
# Open json file
|
||||||
with open(scan_json, "r") as f:
|
with open(scan_json, "r") as f:
|
||||||
# Go through each line
|
# Load JSON
|
||||||
for line in f.readlines():
|
lines = json.loads(f.read())
|
||||||
# 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
|
# Go through each line
|
||||||
|
for line in range(len(lines)):
|
||||||
|
# Get domain & vulnerability
|
||||||
|
domain = lines[line]["host"].replace("http://", "").replace("https://", "").replace("www", "")
|
||||||
|
vulnerability = lines[line]["template-id"]
|
||||||
|
|
||||||
|
# Create domain folder
|
||||||
if not os.path.exists(f"{scan_folder}/domains/{domain}"):
|
if not os.path.exists(f"{scan_folder}/domains/{domain}"):
|
||||||
os.mkdir(f"{scan_folder}/domains/{domain}")
|
os.mkdir(f"{scan_folder}/domains/{domain}")
|
||||||
|
|
||||||
# Domain on current line
|
# Create vulnerability folder
|
||||||
if domain in line["host"]:
|
if not os.path.exists(f"{scan_folder}/domains/{domain}/{vulnerability}"):
|
||||||
# Path doesn't exist, make
|
os.mkdir(f"{scan_folder}/domains/{domain}/{vulnerability}")
|
||||||
if not os.path.exists(f"{scan_folder}/domains/{domain}/{vulnerability}"):
|
|
||||||
os.mkdir(f"{scan_folder}/domains/{domain}/{vulnerability}")
|
|
||||||
|
|
||||||
# Text key to file
|
# Result found
|
||||||
if "extracted-results" in line:
|
if "extracted-results" in lines[line]:
|
||||||
# Open text file
|
# Open vulnerability text file
|
||||||
with open(f"{scan_folder}/domains/{domain}/{vulnerability}/{vulnerability}.txt", "a") as v:
|
with open(f"{scan_folder}/domains/{domain}/{vulnerability}/{vulnerability}.txt", "a") as vuln:
|
||||||
# Get each result & go through
|
# Write vulnerability
|
||||||
results = line["extracted-results"]
|
results = lines[line]["extracted-results"]
|
||||||
for extracted in results:
|
for result in results:
|
||||||
v.write(extracted+"\n")
|
vuln.write(result+"\n")
|
||||||
|
|
||||||
# Open json file
|
# Open vulnerability json file
|
||||||
with open(f"{scan_folder}/domains/{domain}/{vulnerability}/{vulnerability}.json", "a") as v:
|
with open(f"{scan_folder}/domains/{domain}/{vulnerability}/{vulnerability}.json", "a") as vulns:
|
||||||
json.dump(line, v, indent=4)
|
# Write json
|
||||||
|
json.dump(lines[line], vulns, indent=4)
|
||||||
|
|
Loading…
Reference in New Issue