=== Simple Bot Tracker ===
Contributors: flo-murnig
Tags: security, bots, ai crawler, brute force, htaccess
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.2
Stable tag: 1.6.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See which bots and attacks hit your site, get a security check with clear recommendations and export ready-made blocklists.

== Description ==

Simple Bot Tracker shows what is really happening on your site: search engine crawlers, AI bots, scanners and attacks – and whether an attack got through. It analyses and recommends; blocking stays with your security plugin or server.

= What it detects =

* **Good crawlers** (Google, Bing, Yandex, Facebook, Applebot …), verified via reverse DNS – fake crawlers are flagged
* **AI bots** (GPTBot, ChatGPT-User, ClaudeBot, PerplexityBot, CCBot, Bytespider, meta-externalagent, Amazonbot …), split into training, AI search and fetch on user request
* **Attack tools** (sqlmap, Nikto, WPScan, masscan, nuclei …)
* **What was attempted**: sensitive files (wp-config.php, .env, .git), SQL injection, path traversal, XSS, code execution, login attempts (including XML-RPC multicall and whether the username exists), user enumeration, plugin/theme probing, file scans
* **Outcome of every request**: blocked, not found, successful, redirected – so you can see what your security plugin stopped and what got through
* **Follow attackers**: after an attack, all further requests of that IP are logged for 15 minutes

= Security check =

A traffic-light overview based on the last 30 days and your current configuration:

* Attack requests answered with HTTP 200 – the only ones that may have found something, marked "check!" in the log
* Login attacks with real usernames, XML-RPC active and under attack, user enumeration
* Pending updates, inactive plugins, a user named "admin", file editor enabled, debug.log in wp-content (with a delete button)
* No security plugin or several at once, AI training crawlers

= Blocklist export =

Top attacking IPs, attack tools and typical scan targets as a ready-made snippet for .htaccess, nginx, a Cloudflare custom rule, an IP list for Wordfence / Solid Security / All In One WP Security, or CSV. On Apache and LiteSpeed the rules can be written to .htaccess with one click (opt-in): in their own block, with a backup and automatic restore if the site responds with an error afterwards. The rules also block user enumeration (?author=N and REST /wp/v2/users for visitors who are not logged in). Verified crawlers, your server's IP, your own IP and private networks are never included.

= Files this plugin writes =

The plugin only touches files when you trigger it. "Write to .htaccess" adds its own block at the top of .htaccess; the previous content is saved in the database first and restored automatically if the home page then responds with a server error (5xx). The optional early loading mode creates wp-content/mu-plugins/0-simple-bot-tracker-early.php, and the "Delete debug.log" button in the security check deletes wp-content/debug.log. Deactivating the plugin (in the admin or via WP-CLI) removes the .htaccess block and the MU loader, and uninstalling removes any that are left; apart from these, the plugin writes nothing outside the database. The .htaccess is written with direct file functions and LOCK_EX instead of WP_Filesystem, because it has to be backed up and restored within the same request.

= Performance =

* Only bots and attacks are logged – normal visits cause no extra database query.
* Detection is plain string matching; the database write happens on shutdown, after the page has been sent.
* Identical requests are counted instead of creating new rows; per-IP and global limits protect against log flooding.
* No external requests during page loads. Crawler verification (reverse DNS) runs hourly via WP-Cron.

= Compatible with security plugins =

Detects Wordfence, All In One WP Security, Solid Security, WP Cerber, Shield, NinjaFirewall, BBQ, Defender, MalCare, Patchstack, Jetpack Protect, Sucuri, BulletProof and the Cloudflare plugin. Optional early loading mode (MU plugin) captures requests that other plugins block while loading, and the visitor IP can be taken from your security plugin's proxy settings.

= Privacy =

Per hit the plugin stores time (UTC), IP address, user agent, method, URI, HTTP status and classification in its own database table. For failed logins it records whether the user exists; the attempted username is only stored if you enable "Log usernames". Passwords are never stored. Logged-in editors and administrators are not logged. Entries are deleted automatically after the retention period (default 30 days). IP addresses are personal data – please mention the logging in your privacy policy.

Crawler verification runs hourly via WP-Cron: for visitors whose user agent claims to be a known search engine crawler (Googlebot, Bingbot …), the plugin looks up the IP address via reverse DNS and confirms the host name with a forward lookup (gethostbyaddr, gethostbynamel / dns_get_record). These lookups go to your server's DNS resolver. You can switch this off with the "Verify crawlers" option in the settings.

The IP detail view links to AbuseIPDB and ipinfo.io. These links are only opened when you click them; the plugin itself does not contact any external service.

== Installation ==

1. Install the plugin via Plugins → Add New, or upload the `simple-bot-tracker` folder to `/wp-content/plugins/`.
2. Activate it.
3. Open "Bot Tracker" in the admin menu. Check the "Settings" tab – especially the visitor IP source if your site runs behind Cloudflare or a reverse proxy.

== Frequently Asked Questions ==

= Does Simple Bot Tracker block attacks? =

No, not on its own. It shows what happens and recommends what to change. The only exception is the "Write to .htaccess" button, which you trigger yourself and can undo at any time. For login limits, two-factor authentication and a firewall, use a security plugin.

= Does it slow down my site? =

Normal visits are not logged and cause no extra database query. Bot and attack hits are written after the page has been delivered.

= Why are some blocked requests missing? =

Firewalls running before WordPress (auto_prepend_file, .htaccess rules, Cloudflare, Sucuri) stop requests before any WordPress plugin can see them. The plugin shows a notice when such a firewall is active. Enable the early loading mode if a security plugin loads before Simple Bot Tracker.

= My site runs behind Cloudflare – all hits show the same IP. =

Set the visitor IP source to "Cloudflare (CF-Connecting-IP)" in the settings.

= What happens when I deactivate the plugin? =

The MU loader and the .htaccess block are removed. The log stays until you delete the plugin; uninstalling removes the table and all options.

= Is there a German translation? =

Yes, German is included. All German variants (de_AT, de_CH, de_DE_formal) use it automatically.

== Changelog ==

= 1.6.1 =
* First release on WordPress.org.
* Bot and attack tracking with live statistics, filters and IP timeline.
* AI bots by purpose, crawler verification via reverse DNS.
* Security check with traffic lights, "check!" marker for attacks answered with HTTP 200.
* Blocklist export (.htaccess, nginx, Cloudflare, IP list, CSV) and optional one-click .htaccess rules, including user enumeration protection.
* Delete debug.log from the security check.

== Upgrade Notice ==

= 1.6.1 =
First release on WordPress.org.
