Enterprise WordPress Threat Detection Engine
30 Modules β’ 158 Signatures β’ ML Classification β’ Real-Time Protection β’ Cross-File Correlation
ThemeGuard is a WordPress-focused static and behavioral malware scanner with recursive payload decoding, confidence scoring, cross-file correlation, cloud threat intelligence, and real-time watch mode.
Unlike generic security tools, ThemeGuard understands WordPress internals - hooks, cron persistence, REST API backdoors, nonce bypasses, option table poisoning, and more.
|
|
|
|
| Category | Signatures | Examples |
|---|---|---|
| π΄ PHP Backdoors | 48 | eval/base64 chains, command injection, RCE, file write |
| π Webshells | 23 | c99, r57, WSO, Alfa, b374k, China Chopper, reverse shells |
| π‘ Plugin Backdoors | 30 | AJAX exploits, REST API, license bypass, cron persistence |
| π΅ Crypto Miners | 13 | CoinHive, XMRig, CryptoLoot, mining pool URLs |
| π£ SEO Spam | 13 | Hidden links, pharma hacks, doorway pages, cloaking |
| βͺ Obfuscation | 16 | str_rot13, hex2bin, chr chains, strrev, error suppression |
| π€ File Anomalies | 15 | Double extensions, WP-VCD, .htaccess abuse, nulled markers |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SCAN PIPELINE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Phase A: Prefilter β
β file_walker β prefilter β file_classifier β
β β
β Phase B: Per-File Analysis (parallel) β
β signatures β obfuscation β network β integrity β
β β PHP deep β WP deep β threat engine β ML β
β β recursive decoder β cloud intel β
β β
β Phase C: Directory Scans β
β .htaccess β wp-config β polyglot β timeline β
β β
β Phase D: Post-Processing β
β dedup β correlate β score β suppress β filter β
β β
β Phase E: Output β
β evidence store β triage report β HTML/JSON/SARIF β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Python3 comes pre-installed on Kali
sudo apt update && sudo apt install -y python3 python3-pip git
# Clone the repository
git clone https://github.com/V3n0mSh3ll/themeguard.git
cd themeguard
# Install dependencies
pip3 install -r requirements.txt
# Make executable (optional)
chmod +x themeguard.py
# Verify installation
python3 -m unittest tests.test_scanner tests.test_enterprise -v# Initial setup
pkg update && pkg upgrade -y
pkg install -y python git
# Clone the repository
git clone https://github.com/V3n0mSh3ll/themeguard.git
cd themeguard
# Install dependencies
pip install -r requirements.txt
# Run ThemeGuard
python themeguard.py
# Scan files on device storage
# termux-setup-storage (grant storage access first time)
python themeguard.py --path /sdcard/Download/theme-folder/sudo apt update && sudo apt install -y python3 python3-pip git
git clone https://github.com/V3n0mSh3ll/themeguard.git
cd themeguard
pip3 install -r requirements.txt
python3 themeguard.py# Requires Python 3.8+ from python.org
git clone https://github.com/V3n0mSh3ll/themeguard.git
cd themeguard
pip install -r requirements.txt
python themeguard.pypython3 themeguard.pyThis launches the interactive menu - select an option and the scan starts:
ββββββββββββββββββββββββββββββββββββββββββββ
β THEMEGUARD v1.0 β
β WordPress Threat Detection Engine β
β βββββββββββββββββββββββββββββββββββββββββββ£
β [1] Scan Theme β
β [2] Scan Plugin β
β [3] Scan Full wp-content β
β [4] Watch Mode (Real-time) β
β [5] View Scan History β
β [6] Quarantine Management β
β [0] Exit β
ββββββββββββββββββββββββββββββββββββββββββββ
# Basic scan
python3 themeguard.py --path ~/Downloads/flavor/
# Deep scan (includes WP core integrity check)
python3 themeguard.py --path ~/Downloads/flavor/ --deep
# Show only high/critical findings
python3 themeguard.py --path ~/Downloads/flavor/ --severity highpython3 themeguard.py --path ~/Downloads/contact-form-7/ --type plugin# Scan everything - themes, plugins, uploads, mu-plugins
python3 themeguard.py --path ~/Downloads/wp-content/ --type full# Check URLs and hashes against URLhaus + WPScan API
python3 themeguard.py --path ~/Downloads/flavor/ --network
# Combine deep scan with network analysis
python3 themeguard.py --path ~/Downloads/flavor/ --deep --network# HTML report
python3 themeguard.py --path ~/Downloads/flavor/ --report html
# JSON report
python3 themeguard.py --path ~/Downloads/flavor/ --report json
# Both formats
python3 themeguard.py --path ~/Downloads/flavor/ --report both
# SARIF format (for CI/CD integration)
python3 themeguard.py --path ~/Downloads/flavor/ --report sarifReports are saved in the reports/ directory.
# Automatically scans any file changes in real time
python3 themeguard.py --path ~/Downloads/flavor/ --watchWatch mode features:
- Detects file changes (new, modified, deleted)
- 3-second debounce to prevent scan flooding
- Storm protection (throttles at 50+ changes per 10 seconds)
- Auto-recovery on errors
- Press
Ctrl+Cto stop
When critical or high-severity threats are found, quarantine the infected files:
# Quarantine after scan
python3 themeguard.py --path ~/Downloads/flavor/ --quarantine
# List quarantined files
python3 themeguard.py --list-quarantine
# Restore a quarantined file (SHA-256 integrity verified)
python3 themeguard.py --restore infected-file.php# View previous scans (stored in SQLite)
python3 themeguard.py --history
# Compare two scans (shows new vs resolved findings)
python3 themeguard.py --diff scan-id-1 scan-id-2# Run all 68 tests
python3 -m unittest tests.test_scanner tests.test_enterprise -v
# Enterprise module tests only
python3 -m unittest tests.test_enterprise -v
# Core scanner tests only
python3 -m unittest tests.test_scanner -v# Scenario 1: Check a downloaded theme
python3 themeguard.py --path ~/Downloads/flavor/ --deep --report html
# Scenario 2: Monitor a theme folder for changes
python3 themeguard.py --path ~/Downloads/flavor/ --watch
# Scenario 3: Quick plugin check (Termux)
python3 themeguard.py --path /sdcard/Download/flavor/ --type plugin
# Scenario 4: CI/CD pipeline integration
python3 themeguard.py --path ./flavor/ --report sarif --severity high
# Exit code 0 = clean, 1 = high, 2 = critical
# Scenario 5: Full wp-content audit with network intel
python3 themeguard.py --path ~/Downloads/wp-content/ --type full --deep --network --report bothThemeGuard produces triage-prioritized reports:
============================================================
THEMEGUARD TRIAGE REPORT
============================================================
Target: ~/Downloads/flavor
Scan time: 2.47s
Files: 847
Total finds: 12
[!] IMMEDIATE ACTION REQUIRED - QUARANTINE
----------------------------------------
functions.php:142
eval(base64_decode(...)) with network callback
Confidence: 95% | Severity: critical
[?] MANUAL REVIEW RECOMMENDED
----------------------------------------
includes/helper.php:89
Dynamic function dispatch with user input
Confidence: 62% | Severity: high
CORRELATED THREATS (CAMPAIGNS)
----------------------------------------
Same malicious URL in 3 files: http://evil.com/gate.php
Files: functions.php, footer.php, admin.php
RECOMMENDED NEXT STEPS
----------------------------------------
1. Quarantine the files listed above IMMEDIATELY
2. Check if the site has been compromised
3. Reset all passwords and API keys
============================================================
# Run all tests (68 tests)
python -m unittest tests.test_scanner tests.test_enterprise -v| Suite | Tests | Coverage |
|---|---|---|
| Core Scanner | 14 | Pattern engine, obfuscation, network, integrity |
| Enterprise | 54 | Dedup, scorer, decoder, classifier, correlation, evidence store, triage |
| Module | Purpose |
|---|---|
pattern_engine.py |
Aho-Corasick + regex signature matching |
threat_engine.py |
Custom .tgr rule engine |
ml_classifier.py |
26-feature statistical risk classifier |
decoder_recursive.py |
8-depth recursive payload decoder |
correlation.py |
Cross-file campaign detection |
scorer.py |
Confidence scoring with signal weights |
deduper.py |
Finding dedup with stable IDs |
evidence_store.py |
SQLite scan history & diff |
cloud_intel.py |
URLhaus + WPScan API |
wp_deep_scan.py |
WordPress hook/cron/REST analysis |
php_deep_scan.py |
Taint flow, call graph, dead code |
safe_io.py |
Robust I/O, regex DoS protection |
watcher.py |
Real-time watch with debounce |
quarantine.py |
SHA-256 verified quarantine/restore |
Full list: 30 modules - see
docs/architecture.md
- β
No
eval()in analysis pipeline - β Regex DoS protection (length + search limits)
- β Recursive decode depth limited (8 levels)
- β Decompression bomb protection
- β Symlink escape + path traversal protection
- β Quarantine hash verification on restore
- β Tamper detection in quarantine manifest
- β Atomic JSON writes (crash-safe)
| Document | Description |
|---|---|
architecture.md |
5-phase pipeline, 30-module map, data flow |
rule_format.md |
.tgr syntax, modifiers, conditions |
known_limitations.md |
Honest coverage of all gaps |
| Code | Meaning |
|---|---|
0 |
Clean - no critical/high findings |
1 |
High severity issues found |
2 |
Critical threats detected |
Muhammad Abid (V3n0mSh3ll) Offensive Security Researcher β’ AI Security β’ Full-Stack Developer
MIT
