How scr34m/php-malware-scanner works
This is a command-line and embeddable PHP malware scanner. Its main workflow accepts a directory and scan options, traverses eligible files, checks them against signature rules (or the alternative base64 rules), consults hash whitelists, and formats findings and scan statistics. Additional documented capabilities include WordPress checksum whitelisting, a combined whitelist, and optional AST-based checks. The scanner is largely implemented in scan.php; the excerpts omit some internals, so uncertain call wiring is not shown.
Main entry points: scan.php Scanner runtime · ast_visitor.php AST checks · definitions Text and regex rules · base64_patterns Base64 rules
Components 17
Scan workflow
- Scanner runtime
scan.php - Directory traversal
scan.php - File scanning
scan.php
Detection sources
- Text and regex rules
definitions - Base64 rules
base64_patterns - AST checks
ast_visitor.php
Whitelist sources
- Hash allowlisting
scan.php - Default hashes
whitelist.txt - Custom whitelist
scan.php - Combined whitelist
scan.php - WordPress checksums
scan.php
Results
- Finding output
scan.php - Run statistics
scan.php
Other components
- Operator
- PHP Parser
- Combined database service
- WordPress API
Connections 16
- Operator → Scanner runtime: starts scan
- Scanner runtime → Directory traversal: traverses paths
- Directory traversal → File scanning: selects files
- File scanning → Text and regex rules: matches patterns
- File scanning → Base64 rules: matches encoded patterns
- File scanning → AST checks: checks syntax
- AST checks → PHP Parser: parses with
- Scanner runtime → Hash allowlisting: checks hashes
- Hash allowlisting → Default hashes: reads hashes
- Hash allowlisting → Custom whitelist: reads configured list
- Scanner runtime → Combined whitelist: updates when enabled
- Combined whitelist → Combined database service: fetches database
- Scanner runtime → WordPress checksums: loads version hashes
- WordPress checksums → WordPress API: fetches checksums
- File scanning → Finding output: reports findings
- Scanner runtime → Run statistics: reports totals