wpchecker 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wpchecker/__init__.py +6 -0
- wpchecker/__main__.py +104 -0
- wpchecker/advisories.py +93 -0
- wpchecker/data/wp_advisories.json +1297 -0
- wpchecker/fetch.py +268 -0
- wpchecker/scan.py +614 -0
- wpchecker/versions.py +81 -0
- wpchecker-0.2.2.dist-info/METADATA +290 -0
- wpchecker-0.2.2.dist-info/RECORD +13 -0
- wpchecker-0.2.2.dist-info/WHEEL +5 -0
- wpchecker-0.2.2.dist-info/entry_points.txt +2 -0
- wpchecker-0.2.2.dist-info/licenses/LICENSE +23 -0
- wpchecker-0.2.2.dist-info/top_level.txt +1 -0
wpchecker/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""wpchecker — free external WordPress plugin/theme vulnerability
|
|
2
|
+
scanner. Passive fingerprinting plus read-only fetches of files
|
|
3
|
+
WordPress sites serve publicly (plugin readme.txt, theme
|
|
4
|
+
style.css, readme.html). No exploit probes, ever."""
|
|
5
|
+
|
|
6
|
+
__version__ = "0.2.2"
|
wpchecker/__main__.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""CLI: wpchecker scan <url> [more urls...] [--text]
|
|
2
|
+
wpchecker scan --snapshot <dir> [--text]
|
|
3
|
+
wpchecker save-snapshot <url> <dir>
|
|
4
|
+
|
|
5
|
+
Prints one JSON verdict object per target (or a
|
|
6
|
+
human-readable report with --text).
|
|
7
|
+
|
|
8
|
+
The scan is passive: it reads the homepage, plugin
|
|
9
|
+
readme.txt files, the active theme's style.css and
|
|
10
|
+
/readme.html — files WordPress sites serve publicly — and
|
|
11
|
+
matches the versions the site discloses against the bundled
|
|
12
|
+
advisory dataset (NVD + CVE.org ranges, CISA KEV flags). No
|
|
13
|
+
exploit probes, no username enumeration, no password
|
|
14
|
+
attempts.
|
|
15
|
+
|
|
16
|
+
Snapshot replay (--snapshot) produces the identical verdict
|
|
17
|
+
from a directory of saved captures (see save-snapshot and
|
|
18
|
+
the README's snapshot-format section) with zero network
|
|
19
|
+
requests — the scanner that doesn't need to touch your site.
|
|
20
|
+
|
|
21
|
+
Exit codes: 0 — scanned, no findings; 1 — at least one
|
|
22
|
+
finding (a vulnerable component or a hygiene exposure);
|
|
23
|
+
2 — usage error, or a target could not be judged at all:
|
|
24
|
+
unreachable, not a WordPress site, or an unreadable
|
|
25
|
+
snapshot. When several targets are scanned, the worst code
|
|
26
|
+
wins.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
import argparse
|
|
30
|
+
import json
|
|
31
|
+
import sys
|
|
32
|
+
|
|
33
|
+
from . import __version__
|
|
34
|
+
from .scan import (exit_code, render_text, save_snapshot,
|
|
35
|
+
scan, scan_snapshot)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _parser():
|
|
39
|
+
p = argparse.ArgumentParser(
|
|
40
|
+
prog="wpchecker",
|
|
41
|
+
description="External WordPress plugin/theme "
|
|
42
|
+
"vulnerability scanner — passive, "
|
|
43
|
+
"evidence-only, no exploit probes.")
|
|
44
|
+
p.add_argument("--version", action="version",
|
|
45
|
+
version=f"wpchecker {__version__}")
|
|
46
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
47
|
+
s = sub.add_parser(
|
|
48
|
+
"scan", help="scan one or more live sites, or replay "
|
|
49
|
+
"a snapshot with --snapshot")
|
|
50
|
+
s.add_argument("urls", nargs="*",
|
|
51
|
+
help="site URLs (not used with --snapshot)")
|
|
52
|
+
s.add_argument("--snapshot", metavar="DIR",
|
|
53
|
+
help="replay a snapshot directory offline "
|
|
54
|
+
"(zero network requests)")
|
|
55
|
+
s.add_argument("--text", action="store_true",
|
|
56
|
+
help="human-readable report instead of JSON")
|
|
57
|
+
c = sub.add_parser(
|
|
58
|
+
"save-snapshot",
|
|
59
|
+
help="capture a site's disclosed evidence into a "
|
|
60
|
+
"snapshot directory for offline replay")
|
|
61
|
+
c.add_argument("url", help="site URL to capture")
|
|
62
|
+
c.add_argument("dir", help="snapshot directory to write")
|
|
63
|
+
return p
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def main(argv=None):
|
|
67
|
+
args = _parser().parse_args(argv)
|
|
68
|
+
if args.cmd == "save-snapshot":
|
|
69
|
+
summary = save_snapshot(args.url, args.dir)
|
|
70
|
+
print(json.dumps(summary, indent=1))
|
|
71
|
+
return 0 if summary["status"] == "ok" else 2
|
|
72
|
+
results = []
|
|
73
|
+
if args.snapshot:
|
|
74
|
+
if args.urls:
|
|
75
|
+
print("error: --snapshot takes no URLs",
|
|
76
|
+
file=sys.stderr)
|
|
77
|
+
return 2
|
|
78
|
+
try:
|
|
79
|
+
results = [scan_snapshot(args.snapshot)]
|
|
80
|
+
except ValueError as e:
|
|
81
|
+
print(f"error: {e}", file=sys.stderr)
|
|
82
|
+
return 2
|
|
83
|
+
else:
|
|
84
|
+
if not args.urls:
|
|
85
|
+
print("error: scan needs at least one URL (or "
|
|
86
|
+
"--snapshot DIR)", file=sys.stderr)
|
|
87
|
+
return 2
|
|
88
|
+
results = [scan(u) for u in args.urls]
|
|
89
|
+
worst = 0
|
|
90
|
+
for r in results:
|
|
91
|
+
if args.text:
|
|
92
|
+
print(render_text(r))
|
|
93
|
+
else:
|
|
94
|
+
print(json.dumps(r, indent=1))
|
|
95
|
+
worst = max(worst, exit_code(r))
|
|
96
|
+
return worst
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def cli():
|
|
100
|
+
sys.exit(main())
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
cli()
|
wpchecker/advisories.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Assessment of disclosed components against the vendored
|
|
2
|
+
advisory dataset (wpchecker/data/wp_advisories.json — built
|
|
3
|
+
from NVD + CVE.org ranges, CISA KEV flags; see
|
|
4
|
+
tools/refresh_advisories.py).
|
|
5
|
+
|
|
6
|
+
Doctrine, mirrored from phpscan:
|
|
7
|
+
* a component whose version the site does not disclose is
|
|
8
|
+
reported "version_hidden" and is NOT assessed — a hidden
|
|
9
|
+
version is never treated as evidence of a vulnerability;
|
|
10
|
+
* a component absent from the starter dataset is reported
|
|
11
|
+
"not_in_dataset" — absence is not a clean bill of health;
|
|
12
|
+
* every finding carries a remediation string; where no source
|
|
13
|
+
publishes a fixed version, the finding says so ("no fixed
|
|
14
|
+
version published") instead of inventing one.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import os
|
|
19
|
+
|
|
20
|
+
from .versions import in_range
|
|
21
|
+
|
|
22
|
+
_DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
|
23
|
+
"data", "wp_advisories.json")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def load_db(path=None):
|
|
27
|
+
with open(path or _DATA, encoding="utf-8") as f:
|
|
28
|
+
return json.load(f)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _entry(db, slug):
|
|
32
|
+
plugins = db.get("plugins", {})
|
|
33
|
+
if slug in plugins:
|
|
34
|
+
return plugins[slug]
|
|
35
|
+
low = slug.lower()
|
|
36
|
+
for key, val in plugins.items():
|
|
37
|
+
if key.lower() == low:
|
|
38
|
+
return val
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def assess(db, slug, kind, version, version_source=None):
|
|
43
|
+
"""Assess one component. Returns a report dict with the
|
|
44
|
+
component's status and zero or more findings; every finding
|
|
45
|
+
has a remediation."""
|
|
46
|
+
entry = _entry(db, slug)
|
|
47
|
+
name = entry["name"] if entry else slug
|
|
48
|
+
base = {"slug": slug, "name": name, "kind": kind,
|
|
49
|
+
"version": version, "version_source": version_source}
|
|
50
|
+
if version is None:
|
|
51
|
+
return {**base, "status": "version_hidden", "findings": [],
|
|
52
|
+
"note": "Detected, but the site does not disclose "
|
|
53
|
+
"its version, so it was not assessed. A "
|
|
54
|
+
"hidden version is not evidence of a "
|
|
55
|
+
"vulnerability."}
|
|
56
|
+
if entry is None:
|
|
57
|
+
return {**base, "status": "not_in_dataset", "findings": [],
|
|
58
|
+
"note": "Not covered by the starter advisory "
|
|
59
|
+
"dataset; absence is not a clean bill of "
|
|
60
|
+
"health."}
|
|
61
|
+
findings = []
|
|
62
|
+
for vuln in entry.get("vulnerabilities", []):
|
|
63
|
+
for clause in vuln.get("clauses", []):
|
|
64
|
+
if not in_range(version, clause.get("range", "")):
|
|
65
|
+
continue
|
|
66
|
+
fixed = clause.get("fixed")
|
|
67
|
+
if fixed:
|
|
68
|
+
remediation = (f"Update {name} to {fixed} or "
|
|
69
|
+
f"later (installed: {version}).")
|
|
70
|
+
else:
|
|
71
|
+
remediation = (
|
|
72
|
+
f"No fixed version has been published for "
|
|
73
|
+
f"{vuln['cve']}; disable or remove {name} "
|
|
74
|
+
f"until the vendor ships a fix, and watch "
|
|
75
|
+
f"the advisory feed for the fix.")
|
|
76
|
+
findings.append({
|
|
77
|
+
"cve": vuln["cve"],
|
|
78
|
+
"title": vuln.get("title", ""),
|
|
79
|
+
"severity": vuln.get("severity"),
|
|
80
|
+
"cvss": vuln.get("cvss"),
|
|
81
|
+
"kev": bool(vuln.get("kev")),
|
|
82
|
+
"published": vuln.get("published", ""),
|
|
83
|
+
"installed_version": version,
|
|
84
|
+
"affected_range": clause["range"],
|
|
85
|
+
"range_source": clause.get("via"),
|
|
86
|
+
"fixed_version": fixed,
|
|
87
|
+
"fixed_version_note": None if fixed else
|
|
88
|
+
"no fixed version published",
|
|
89
|
+
"remediation": remediation,
|
|
90
|
+
})
|
|
91
|
+
break # one finding per advisory, first matching clause
|
|
92
|
+
status = "vulnerable" if findings else "no_known_vulnerabilities"
|
|
93
|
+
return {**base, "status": status, "findings": findings}
|