Archived
scanning #18
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
@@ -0,0 +1 @@
|
||||
requests
|
||||
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import csv
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
|
||||
REL_PATH = "../"
|
||||
LOCAL_PATH = REL_PATH + "wordfence_vulnerabilities.json"
|
||||
RAW_URL = ""
|
||||
bad_plugins = []
|
||||
OUT_CSV = "matches.csv"
|
||||
OUT_JSON = "matches.json"
|
||||
|
||||
def load_json_local(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
def load_json_from_url(url):
|
||||
import requests
|
||||
r = requests.get(url, timeout=30)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def main():
|
||||
data = None
|
||||
if os.path.exists(LOCAL_PATH):
|
||||
print(f"Loading local file: {LOCAL_PATH}")
|
||||
data = load_json_local(LOCAL_PATH)
|
||||
elif RAW_URL:
|
||||
print(f"Local file not found, downloading from: {RAW_URL}")
|
||||
data = load_json_from_url(RAW_URL)
|
||||
else:
|
||||
raise SystemExit("Error: no local file and RAW_URL is empty.")
|
||||
|
||||
if isinstance(data, dict) and "vulnerabilities" in data:
|
||||
entries = data["vulnerabilities"]
|
||||
elif isinstance(data, list):
|
||||
entries = data
|
||||
else:
|
||||
entries = []
|
||||
if isinstance(data, dict):
|
||||
for v in data.values():
|
||||
if isinstance(v, list):
|
||||
entries = v
|
||||
break
|
||||
|
||||
bad_set = set(bad_plugins)
|
||||
matches = []
|
||||
for entry in entries:
|
||||
try:
|
||||
if entry.get("type") != "plugin":
|
||||
continue
|
||||
slug = entry.get("slug", "").strip()
|
||||
if not slug:
|
||||
continue
|
||||
if slug in bad_set:
|
||||
matches.append({
|
||||
"slug": slug,
|
||||
"title": entry.get("title"),
|
||||
"cve": entry.get("cve"),
|
||||
"severity": entry.get("severity"),
|
||||
"cvss_score": entry.get("cvss_score"),
|
||||
"cve_link": entry.get("cve_link"),
|
||||
"raw": entry
|
||||
})
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if not matches:
|
||||
print("No matches found for the bad_plugins list.")
|
||||
else:
|
||||
print(f"Found {len(matches)} matches:")
|
||||
for m in matches:
|
||||
print(f"- {m['slug']} | CVE: {m.get('cve')} | sev: {m.get('severity')} | CVSS: {m.get('cvss_score')}")
|
||||
print(f" link: {m.get('cve_link')}")
|
||||
|
||||
with open(OUT_CSV, "w", newline='', encoding="utf-8") as csvf:
|
||||
writer = csv.DictWriter(csvf, fieldnames=["slug", "title", "cve", "severity", "cvss_score", "cve_link"])
|
||||
writer.writeheader()
|
||||
for m in matches:
|
||||
writer.writerow({
|
||||
"slug": m["slug"],
|
||||
"title": m.get("title"),
|
||||
"cve": m.get("cve"),
|
||||
"severity": m.get("severity"),
|
||||
"cvss_score": m.get("cvss_score"),
|
||||
"cve_link": m.get("cve_link")
|
||||
})
|
||||
print(f"Saved CSV results to {OUT_CSV}")
|
||||
|
||||
with open(OUT_JSON, "w", encoding="utf-8") as jf:
|
||||
json.dump(matches, jf, ensure_ascii=False, indent=2)
|
||||
print(f"Saved JSON results to {OUT_JSON}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
|
||||
# vars
|
||||
JSON_FILE = "../wordfence_vulnerabilities.json"
|
||||
BAD_LIST = []
|
||||
|
||||
JSON_OUT = "matches.json"
|
||||
|
||||
|
||||
def load_local(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def get_entries(data):
|
||||
# try to find the main list of vulnerabilities
|
||||
if isinstance(data, dict):
|
||||
if "vulnerabilities" in data:
|
||||
return data["vulnerabilities"]
|
||||
for value in data.values():
|
||||
if isinstance(value, list):
|
||||
return value
|
||||
return []
|
||||
elif isinstance(data, list):
|
||||
return data
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def main():
|
||||
if os.path.exists(JSON_FILE):
|
||||
print("Loading ...", JSON_FILE)
|
||||
data = load_local(JSON_FILE)
|
||||
else:
|
||||
print("Error: JSON file not found:", JSON_FILE)
|
||||
return
|
||||
|
||||
entries = get_entries(data)
|
||||
|
||||
bad_set = set(BAD_LIST)
|
||||
hits = []
|
||||
|
||||
for item in entries:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
|
||||
if item.get("type") != "plugin":
|
||||
continue
|
||||
|
||||
slug = (item.get("slug") or "").strip()
|
||||
if not slug:
|
||||
continue
|
||||
|
||||
if slug in bad_set:
|
||||
hit = {
|
||||
"slug": slug,
|
||||
"title": item.get("title"),
|
||||
"cve": item.get("cve"),
|
||||
"severity": item.get("severity"),
|
||||
"cvss_score": item.get("cvss_score"),
|
||||
"cve_link": item.get("cve_link"),
|
||||
"raw": item
|
||||
}
|
||||
hits.append(hit)
|
||||
|
||||
if not hits:
|
||||
print("No matches at all")
|
||||
else:
|
||||
print("Found", len(hits), "matches:")
|
||||
for h in hits:
|
||||
print(
|
||||
"-",
|
||||
h["slug"],
|
||||
"| CVE:", h.get("cve"),
|
||||
"| sev:", h.get("severity"),
|
||||
"| CVSS:", h.get("cvss_score")
|
||||
)
|
||||
print(" link:", h.get("cve_link"))
|
||||
|
||||
# save
|
||||
with open(JSON_OUT, "w", encoding="utf-8") as f:
|
||||
json.dump(hits, f, ensure_ascii=False, indent=2)
|
||||
print("Saved to", JSON_OUT)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,40 @@
|
||||
import json
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# path to your vulnerability JSON file
|
||||
json_path = "wordfence_vulnerabilities.json"
|
||||
|
||||
def load_cvss_scores(path):
|
||||
"""Load JSON data and extract all CVSS scores into a list"""
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
scores = []
|
||||
for entry in data:
|
||||
# make sure cvss_score exists and is numeric
|
||||
if "cvss_score" in entry and isinstance(entry["cvss_score"], (int, float)):
|
||||
scores.append(entry["cvss_score"])
|
||||
return scores
|
||||
|
||||
|
||||
def plot_hist(scores):
|
||||
"""Plot a histogram of CVSS scores"""
|
||||
plt.figure(figsize=(8, 5))
|
||||
plt.hist(scores, bins=10, edgecolor="black", color="skyblue")
|
||||
plt.title("Distribution of CVSS Scores in Vulnerability Data")
|
||||
plt.xlabel("CVSS Score")
|
||||
plt.ylabel("Number of Vulnerabilities")
|
||||
plt.grid(alpha=0.4)
|
||||
plt.savefig("cvss_distribution.png")
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
scores = load_cvss_scores(json_path)
|
||||
print(f"Loaded {len(scores)} CVSS scores.")
|
||||
print("Sample:", scores[:10])
|
||||
|
||||
if scores:
|
||||
plot_hist(scores)
|
||||
else:
|
||||
print("⚠️ No CVSS scores found in the JSON file.")
|
||||
@@ -0,0 +1,2 @@
|
||||
get_CVE.py **MUST** be ran before better_cve_scanner can be ran since it runs using a list that is fetched daily.
|
||||
CVE_scanner.py runs on a static list called wordfence_vulnerabilities.json that is stored in the same directory, which is an old list of major vulnerabilities.
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
import os
|
||||
|
||||
URL = "https://www.wordfence.com/api/intelligence/v2/vulnerabilities/scanner"
|
||||
OUT_FILE = "wordfence_CVE.json"
|
||||
|
||||
def main():
|
||||
print("API request.....")
|
||||
r = requests.get(URL, timeout=60)
|
||||
r.raise_for_status()
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
out_path = os.path.join(script_dir, OUT_FILE)
|
||||
|
||||
with open(out_path, "w", encoding="utf-8") as f:
|
||||
f.write(r.text)
|
||||
|
||||
print("File Saved!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+1165623
File diff suppressed because it is too large
Load Diff
+520306
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user