From ea2e544a7672f93cff5a0219f5fb993eebbf2f90 Mon Sep 17 00:00:00 2001 From: arvindrai Date: Tue, 2 Dec 2025 03:21:11 +0000 Subject: [PATCH] Add scripts/CVE_scanner_new.py updated with a new and better script --- scripts/CVE_scanner_new.py | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 scripts/CVE_scanner_new.py diff --git a/scripts/CVE_scanner_new.py b/scripts/CVE_scanner_new.py new file mode 100644 index 0000000..a689f65 --- /dev/null +++ b/scripts/CVE_scanner_new.py @@ -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()