Archived
Upload files to "scripts"
added the better one
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
|
||||
JSON_FILE = "wordfence_vulnerabilities.json"
|
||||
JSON_OUT = "malware.json"
|
||||
BAD_PLUGINS = []
|
||||
|
||||
|
||||
def load_file(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def main():
|
||||
if not os.path.exists(JSON_FILE):
|
||||
print("json file not found:", JSON_FILE)
|
||||
return
|
||||
|
||||
data = load_file(JSON_FILE)
|
||||
|
||||
bad_set = set()
|
||||
for n in BAD_PLUGINS:
|
||||
if isinstance(n, str):
|
||||
n = n.strip()
|
||||
if n:
|
||||
bad_set.add(n)
|
||||
|
||||
hits = []
|
||||
|
||||
for key, item in data.items():
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
|
||||
software_list = item.get("software") or []
|
||||
for s in software_list:
|
||||
if not isinstance(s, dict):
|
||||
continue
|
||||
if s.get("type") != "plugin":
|
||||
continue
|
||||
|
||||
name = (s.get("name") or "").strip()
|
||||
if name not in bad_set:
|
||||
continue
|
||||
|
||||
affected = s.get("affected_versions") or {}
|
||||
if not affected:
|
||||
continue
|
||||
|
||||
refs = item.get("references") or []
|
||||
ref = refs[0] if refs else None
|
||||
|
||||
hit = {
|
||||
"id": item.get("id"),
|
||||
"title": item.get("title"),
|
||||
"name": name,
|
||||
"slug": s.get("slug"),
|
||||
"affected_versions": list(affected.keys()),
|
||||
"link": ref,
|
||||
"raw": item
|
||||
}
|
||||
hits.append(hit)
|
||||
|
||||
if not hits:
|
||||
print("no matches found")
|
||||
else:
|
||||
print("found", len(hits), "matches")
|
||||
for h in hits:
|
||||
print("-", h["name"], "|", ", ".join(h["affected_versions"]))
|
||||
|
||||
with open(JSON_OUT, "w", encoding="utf-8") as f:
|
||||
json.dump(hits, f, ensure_ascii=False, indent=2)
|
||||
print("saved json to", JSON_OUT)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user