A lightweight PHP malware & backdoor scanner.
Supports CLI usage, JSON/SARIF reports, entropy heuristics, quarantine mode, WordPress-specific rules, and pluggable notifiers (email, webhooks).
- CLI tool (
bin/malcode-scan) with excludes, size limits, and strict exit codes - Rule-based detection (core + WordPress signatures)
- Entropy heuristics for obfuscated strings (base64, gzdeflate, chr chains)
- Quarantine mode – isolate flagged files safely
- Notifiers – send results via SMTP email or webhook
- WordPress mode with WP-CLI command integration
- JSON/SARIF reports for CI integration
- GitHub Actions CI + PHAR release workflow
git clone https://github.com/makmour/Malicious-Code-Scanner.git
cd Malicious-Code-Scanner
composer install
chmod +x bin/malcode-scan- Download the latest
malcode-scan.pharfrom Releases. - Run it directly:
php malcode-scan.phar --path=/var/www/html --report=json --progress
- (Optional) Install globally:
chmod +x malcode-scan.phar sudo mv malcode-scan.phar /usr/local/bin/malcode-scan malcode-scan --help
bin/malcode-scan --path=/var/www/html --report=json --progressbin/malcode-scan \
--path=/var/www/html \
--report=json \
--email=alerts@example.com \
--smtp-host=smtp.example.com --smtp-user=alerts@example.com --smtp-pass=secret --smtp-port=587 \
--webhook=https://hooks.slack.com/services/XXX/YYY/ZZZbin/malcode-scan --path=/var/www/html --wp-mode --report=json --out=/tmp/report.json --quarantine=/tmp/quarantineFrom a WordPress install:
wp --require=bin/wp-malcode.php malcode scan --report=json --out=/tmp/report.json| Flag | Description |
|---|---|
--path |
Root directory to scan (default: current working dir) |
--ext |
File extensions to include (comma-separated, default: php,php5,phtml,inc) |
--exclude |
Paths to exclude (comma-separated) |
--size-limit |
Max file size in bytes (default: 10 MB) |
--report |
Output format: json or sarif |
--out |
Write report to file |
--progress |
Show progress dots while scanning |
--strict |
Exit code 1 if suspicious files found (0 otherwise) |
--wp-mode |
Enable WordPress-specific excludes + rules |
--quarantine |
Directory to copy suspicious files into and replace with stubs |
--email |
Send results to an email (requires --smtp-host etc.) |
--webhook |
Send results as JSON POST to a webhook URL |
0→ Clean (no findings)1→ Findings detected (when--strictis enabled)2→ Reserved for errors
Run tests:
composer testStatic analysis:
composer stanAuto-fix coding style:
composer cs--rules-extra=/path.jsonto load custom signatures--report=prettyfor human-friendly console output- Prebuilt Docker image for CI/CD pipelines
MIT