commit bdca71c465c8a4bb4aabe598d16e155bab1c19ef Author: WLTBAgent Date: Thu Feb 26 22:47:32 2026 +0000 Add mysql-scanner: MySQL malware detection tool diff --git a/mysql-scanner/.env.example b/mysql-scanner/.env.example new file mode 100644 index 0000000..e5a054c --- /dev/null +++ b/mysql-scanner/.env.example @@ -0,0 +1,11 @@ +# MySQL Scanner - Environment Variables Example +# Copy this to .env and fill in your database credentials + +DB_HOST=localhost +DB_PORT=3306 +DB_USER=wp_user +DB_PASSWORD=your_password_here +DB_NAME=wordpress + +# Optional: Limit patterns (comma-separated) +# PATTERNS=eval,base64,script diff --git a/mysql-scanner/README.md b/mysql-scanner/README.md new file mode 100644 index 0000000..2d20c0f --- /dev/null +++ b/mysql-scanner/README.md @@ -0,0 +1,97 @@ +# mysql-scanner + +MySQL database malware scanner for WordPress and generic schemas. + +## Purpose + +Detect hacked content and malware in MySQL databases by scanning text columns for: +- Base64 encoded payloads +- PHP dangerous functions (eval, exec, system, etc.) +- HTML/JS injection (script tags, iframes, event handlers) +- Obfuscation patterns +- Suspicious comment signatures + +## Features + +- **Schema-agnostic**: Analyzes any database structure automatically +- **WordPress-aware**: Prioritizes common WordPress tables (wp_posts, wp_options, etc.) +- **Pattern library**: Extensible detection patterns +- **Contextual reports**: Shows table, column, row ID, and offending snippets +- **Risk levels**: High/Medium/Low classification + +## Installation + +```bash +cd tools/go/mysql-scanner +go build -o mysql-scanner +``` + +## Usage + +```bash +# Scan WordPress database +./mysql-scanner --host localhost --user wp_user --password secret --db wordpress + +# Scan with custom port and pattern filters +./mysql-scanner --host localhost --port 3307 --user user --db mydb --patterns eval,base64,script + +# Output JSON for automated processing +./mysql-scanner --host localhost --user user --db mydb --json --output scan-results.json +``` + +## Environment Variables + +```bash +DB_HOST=localhost +DB_PORT=3306 +DB_USER=username +DB_PASSWORD=secret +DB_NAME=database +``` + +## Detection Patterns + +### PHP Malware +- `eval()`, `assert()`, `create_function()` +- `exec()`, `system()`, `passthru()`, `shell_exec()` +- `base64_decode()`, `gzinflate()`, `str_rot13()` +- `preg_replace()` with `/e` modifier (deprecated but dangerous) + +### Web Shell Patterns +- `$_GET`, `$_POST`, `$_REQUEST` with eval +- `error_reporting(0)` followed by obfuscation +- Variable function calls (`$func()`, `$a($b)`) + +### HTML/JS Injection +- `` tags +- `