A WordPress security plugin with GeoIP-based access control, AI-powered bot detection, Cloudflare Turnstile integration, and advanced fingerprinting.
- π‘οΈ AI-Powered Bot Detection - Classification of bots vs. humans with configurable thresholds
- π GeoIP Access Control - Block or allow traffic by country (whitelist/blacklist)
- π Browser Fingerprinting - Advanced client-side fingerprinting with Canvas, WebGL, Audio
- βοΈ Cloudflare Turnstile - CAPTCHA challenge for borderline bot scores with precision analytics
- π― Honeypot Detection - Hidden links to catch AI crawlers
- π Traffic Analytics - Real-time statistics, live feed, and Turnstile precision metrics
- β‘ Performance Optimized - Minimal overhead (~1ms with page cache, ~30-50ms without)
- π IP Whitelist - Bypass firewall for trusted IPs
- π Caching - APCu + file-based caching for GeoIP lookups
- π¨ Under Attack Mode - Emergency mode to challenge all visitors
Run from the parent directory of the plugin folder:
cd .. # from baskerville/ go to parent directory
zip -r9 baskerville.zip baskerville/ \
-x "*.DS_Store" \
-x "baskerville/.git/*" \
-x "baskerville/.gitignore" \
-x "baskerville/.idea/*" \
-x "baskerville/.claude/*" \
-x "baskerville/vendor/*" \
-x "*.log" \
-x "*.txt" \
-x "*.sh" \
-x "*.html" \
-x "baskerville/test-*.php" \
-x "baskerville/composer.json" \
-x "baskerville/deployment.md" \
-x "baskerville/bot-detector*.js" \
-x "baskerville/ab" \
-x "baskerville/done" \
-x "baskerville/sleep"Note: The vendor/ folder is excluded. After plugin installation, go to Settings β Baskerville β Settings and click "Install MaxMind Library" to enable GeoIP features.
- Upload
baskerville.zipin WordPress Admin β Plugins β Add New β Upload Plugin - Activate the plugin
- Go to Settings β Baskerville to configure
- Go to Settings β Baskerville β Settings
- Install MaxMind GeoLite2 database (one-click installer)
- Configure access mode:
- Allow All (default) - No country restrictions
- Blacklist - Block specific countries
- Whitelist - Allow only specific countries
- Go to Settings β Baskerville β IP Whitelist
- Click "Add My IP" to whitelist your current IP
- Or manually add IPs (one per line or comma-separated)
Use cases:
- Load testing with Apache Bench
- Whitelisting office network
- Development environments
- Monitoring services
Turnstile provides a CAPTCHA-like challenge for visitors with borderline bot scores, allowing legitimate users to prove they're human instead of being blocked outright.
- Go to Settings β Baskerville β Turnstile
- Get your Site Key and Secret Key from Cloudflare Dashboard
- Enter the keys and enable Turnstile
- Configure the borderline score range (default: 40-70)
Settings:
- Bot Score Challenge - Show Turnstile to visitors with scores in the borderline range
- Score Range - Define min/max bot score for challenge (e.g., 40-70)
- Under Attack Mode - Emergency mode that challenges ALL visitors (use during attacks)
- Form Protection - Protect login, registration, and comment forms
Score interpretation:
- 0-39: Likely human (allowed)
- 40-70: Borderline (show Turnstile challenge)
- 71-100: Likely bot (blocked)
Precision Analytics: The Analytics tab shows Turnstile effectiveness:
- Redirects - Number of challenges shown
- Passed - Visitors who completed the challenge
- Failed - Visitors who failed or abandoned (likely bots)
- Precision - % of challenges that caught bots:
(redirects - passes) / redirects
Configure how bots are detected and banned.
- Go to Settings β Baskerville β Bot Control
Settings:
- Ban All Detected Bots - Ban all
botclassifications, not justbad_bot - Instant Ban Threshold - Score threshold (0-100) for immediate ban without waiting for burst protection. Visitors with scores >= threshold are banned instantly if they don't look like a browser and aren't verified crawlers.
Example: With threshold set to 70, a visitor with score 75 and suspicious headers will be banned immediately.
Impact: -95% response time
# Install one of:
- WP Super Cache (free)
- W3 Total Cache (free)
- LiteSpeed Cache (free)
- WP Rocket (paid)Why it helps:
- Cached pages bypass WordPress PHP execution
- Baskerville firewall is not executed for cached pages
- Overhead drops from 50ms β 0ms
Impact: 10x faster cache operations
# Ubuntu/Debian
sudo apt install php-apcu
sudo systemctl restart php-fpm
# Verify
php -m | grep apcuWhy it helps:
- GeoIP lookups cached in memory (not disk)
- Ban cache uses RAM (faster than file I/O)
- APCu: 0.05ms, File: 0.5ms per operation
Impact: 10x faster GeoIP lookups
# /etc/nginx/nginx.conf
load_module modules/ngx_http_geoip2_module.so;
http {
geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb {
auto_reload 5m;
$geoip2_data_country_code country iso_code;
}
fastcgi_param GEOIP2_COUNTRY_CODE $geoip2_data_country_code;
}Why it helps:
- NGINX does GeoIP lookup (not PHP)
- Result passed via
$_SERVER['GEOIP2_COUNTRY_CODE'] - Baskerville uses NGINX result (no MaxMind DB lookup needed)
Impact: 30-50% faster PHP execution
# Check if enabled
php -i | grep opcache.enable
# Enable in php.ini
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.validate_timestamps=0 # Production only| Mode | Overhead | Analytics | Shared Hosting | Recommended For |
|---|---|---|---|---|
| File | ~50-70ms (5%) | β Full (5min delay) | β Perfect | Production |
| Disabled | ~0ms (0%) | β None | β Perfect | Testing/Dev |
| Database | ~500ms (36%) | β Instant | β Slow | VPS only |
Baskerville with File Logging adds 5% overhead while providing:
- β GeoIP-based access control
- β AI-powered bot detection with configurable thresholds
- β Cloudflare Turnstile for borderline cases
- β Honeypot detection for AI crawlers
- β Advanced fingerprinting
- β Real-time traffic analytics with precision metrics
- β Rate limiting & ban management
Recommendations:
- β Use File Logging mode for production (default)
- β Enable page caching (WP Super Cache, etc.)
- β Install APCu if available (10x faster cache)
- β Whitelist monitoring/testing IPs
- β Configure Turnstile for borderline scores (40-70)
- β Set Instant Ban Threshold for high-risk visitors (e.g., 85)
Symptom: Page loads take >5 seconds
Solutions:
- β Enable page caching (WP Super Cache)
- β
Install APCu:
apt install php-apcu - β Enable PHP OPcache
- β Use NGINX GeoIP2 module (optional)
Symptom: GeoIP shows wrong country after VPN change
Solution: Clear GeoIP cache
- Go to Settings β Baskerville β GeoIP Test
- Click "Clear GeoIP Cache" button
- Page will reload with updated country
Symptom: Apache Bench gets 403 errors
Solution: Whitelist your IP
- Go to Settings β Baskerville β IP Whitelist
- Click "Add My IP" button
- Run tests again
baskerville/
βββ admin/
β βββ class-baskerville-admin.php # Admin UI, settings, analytics
βββ includes/
β βββ class-baskerville-core.php # Core functions, caching, GeoIP
β βββ class-baskerville-firewall.php # Firewall logic, blocking rules
β βββ class-baskerville-ai-ua.php # AI bot detection & classification
β βββ class-baskerville-stats.php # Analytics & database logging
β βββ class-baskerville-rest.php # REST API for fingerprinting
β βββ class-baskerville-turnstile.php # Cloudflare Turnstile integration
β βββ class-baskerville-honeypot.php # Honeypot for AI crawler detection
βββ assets/
β βββ js/baskerville.js # Frontend fingerprinting script
β βββ css/ # Styles
βββ vendor/ # MaxMind GeoIP2 library (auto-installed)
βββ baskerville.php # Main plugin file
CREATE TABLE wp_baskerville_stats (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
visit_key VARCHAR(64),
ip VARCHAR(45),
country_code VARCHAR(2), -- Added in v1.0.0
baskerville_id VARCHAR(32),
timestamp_utc DATETIME,
score INT,
classification VARCHAR(32),
user_agent TEXT,
evaluation_json LONGTEXT,
score_reasons TEXT,
classification_reason TEXT,
block_reason VARCHAR(120),
event_type VARCHAR(16),
had_fp TINYINT(1),
INDEX idx_timestamp (timestamp_utc),
INDEX idx_ip (ip),
INDEX idx_country_code (country_code), -- Added in v1.0.0
INDEX idx_event_type (event_type)
);GPL v3 or later - Compatible with WordPress.org plugin directory requirements.
For issues and feature requests, please open an issue on GitHub.