A sophisticated honeypot application built for Cloudflare Workers that deceives attackers by serving realistic fake content for common attack vectors.
Want to see the honeypot in action? Try these live examples (if deployed):
Git Repository Files:
- /.git/config - Git configuration with fake repository info
- /.git/HEAD - Current branch reference
- /.git/refs/heads/main - Main branch commit hash
Admin Panels:
- /admin/ - Generic admin login page
- /phpmyadmin/ - Database administration interface
- /wp-admin/ - WordPress admin panel
Configuration Files:
- /.env - Environment variables with API keys
- /config.php - PHP application configuration
- /wp-config.php - WordPress database configuration
Backup & Database Files:
- /backup.sql - SQL database dump
- /database.bak - Database backup file
- /users.csv - User data export
Note: All data shown is completely fake and generated dynamically. Click any link to see realistic content that would fool attackers, but contains no real secrets!
📄 View Interactive Demo Page - Complete overview with all features and live examples
🔧 See Demo Examples & Testing Commands - cURL commands, scripts, and testing scenarios
A Honeypot is a security system that mimics vulnerable systems or files to attract and detect attackers. This project represents an intelligent trap that:
- Simulates Vulnerabilities: Creates realistic fake configuration files, admin panels, and other popular attack targets
- Detects Attacks: Automatically identifies scanning tools and malicious activity
- Logs Activity: Records all suspicious requests with detailed information about attackers
- Threat Notifications: Can send webhook notifications about attack attempts in real-time
- Slows Down Attackers: Returns realistic but useless data, forcing them to waste time
- Request Reception: Worker receives HTTP request to a suspicious path
- Analysis: System analyzes User-Agent, IP address, and requested path
- Response Generation: Creates realistic fake content (Git files, admin panels, databases)
- Logging: All attack information is saved in logs
- Notification: Optionally sends notification about attack attempt
- Git Files: Fake
.git/config,.git/HEAD, and other Git repository files - Admin Panels: Realistic admin login pages with multiple variations
- WordPress: Authentic-looking WordPress login pages
- Database Files: Fake SQL dumps and database files
- Backup Files: Realistic backup files with metadata
- Environment Files: Fake configuration files (.env, .ini, .conf)
- POST Request Honeypot: Returns random HTTP errors (400-561) for all POST requests
- Dynamic Content: Responses vary slightly each time to avoid detection
- Realistic Headers: Proper Content-Type and server headers
- Company Branding: Uses COMPANY_NAME environment variable when available
- Webhook Notifications: Optional webhook alerts for honeypot triggers
The honeypot uses a modular template generator system:
src/
├── index.ts # Main worker logic
├── config.ts # URL patterns and generator mappings
└── templateGenerators/
├── types.ts # Base interfaces and classes
├── randomData.ts # Data collections for generating realistic content
├── gitGenerator.ts # Git repository files
├── adminGenerator.ts # Admin panels and phpMyAdmin
├── wordpressGenerator.ts # WordPress login pages
└── fileGenerators.ts # Backup files, databases, configs
💡 Quick Start: Visit the interactive demo page to see all honeypot features in action before setting up!
-
Install dependencies:
npm install
-
Configure environment variables (optional):
# Set company name for branding wrangler secret put COMPANY_NAME -
Development:
npm run dev
-
Deploy:
npm run deploy
Edit src/config.ts to add new URL patterns:
{
pattern: 'your-pattern-regex$',
generatorClass: YourGeneratorClass,
description: 'Description of what this detects',
}- Create a new generator class extending
BaseTemplateGenerator - Implement required methods:
initializeVariables(),generate(),getContentType(),getDescription() - Add multiple template variations for realism
Example:
export class MyGenerator extends BaseTemplateGenerator {
protected initializeVariables(): void {
this.variables = {
customVar: 'custom value',
randomValue: getRandomItem(['option1', 'option2', 'option3']),
};
}
generate(): string {
const templates = [
'Template 1 with {{customVar}}',
'Template 2 with {{randomValue}}',
];
const selectedTemplate = getRandomItem(templates);
return this.replaceVariables(selectedTemplate);
}
getContentType(): string {
return 'text/plain; charset=utf-8';
}
getDescription(): string {
return 'My custom generator';
}
}The honeypot currently detects and responds to:
- All POST requests to any endpoint return random HTTP error codes (400-561)
- Includes realistic error messages and proper content-type handling
- Supports JSON, XML, and HTML error responses based on request headers
- Logs all POST attempts with client information
.git/config.git/HEAD.git/refs/heads/*.git/index
/admin/,/administrator//wp-admin//phpmyadmin//manage/,/control/,/panel/admin.php,login.php
wp-login.phpwp-config.php
.env,.config,.ini,.confconfig.php,settings.php,database.php.htaccess,web.config
.bak,.backup,.old,.orig,.tmp.sql,.db,.sqlite,.mdb.zip,.tar.gz,.rar
composer.json,package.jsoncomposer.lock,yarn.lock
phpinfo.php,info.php,test.php
.log,.debug,.traceerror_log,access_log
The honeypot logs all triggered requests with:
- Requested path
- HTTP method (GET/POST)
- Client IP address
- User agent
- Matched rule description
- For POST requests: error status code and message
Access logs through Cloudflare Workers dashboard or CLI:
wrangler tail- All responses are fake and contain no real sensitive data
- Random delays (100-600ms) make responses more realistic
- Proper security headers are included in responses
- Company name from environment variable is safely used
- No real system information is exposed
Set the COMPANY_NAME environment variable to customize company references in fake content:
wrangler secret put COMPANY_NAME
# Enter your company name when promptedEach generator includes multiple template variations. The system automatically:
- Randomly selects templates
- Generates random data (names, emails, hashes, dates)
- Varies response sizes and content
- Uses realistic server headers
Extend randomData.ts to add more realistic data:
export const RANDOM_DATA = {
// Add your custom data arrays
customField: ['value1', 'value2', 'value3'],
// ... existing data
};- Lightweight: No external dependencies
- Fast: Template generation is optimized
- Scalable: Runs on Cloudflare's edge network
- Efficient: Minimal memory usage
A comprehensive test script is included to verify honeypot functionality:
# Make sure your worker is running locally
npm run dev
# In another terminal, run the full test script
node test_honeypot.jsThe test script (test_honeypot.js) will:
- Test all configured GET honeypot patterns
- Test POST requests to various endpoints
- Verify random error generation for POST requests
- Verify response formats and headers
- Check that legitimate paths return 404
- Measure response times
- Provide detailed success/failure reports
For quick POST request testing:
# Test only POST endpoints
node test_post.jsThe POST test script will:
- Send POST requests with various content types (JSON, form data, XML)
- Verify random error status codes (400-561)
- Test different payload types including potential attack vectors
- Display response time statistics
- Show status code distribution
GET Requests:
- Green ✓: Honeypot triggered correctly (200 status)
- Yellow -: Legitimate 404 response
- Red ✗: Error or unexpected response
POST Requests:
- Red ✓: Random error generated correctly (400-561 status)
- Yellow ⚠: Unexpected response (not in 400-561 range)
- Red ✗: Request failed completely
Set the WORKER_URL environment variable to test deployed workers:
WORKER_URL=https://your-worker.your-subdomain.workers.dev node test_honeypot.jsAdd your own test URLs to the testUrls array in test_honeypot.js:
const testUrls = [
// Your custom attack vectors
'/your-custom-path',
'/another-test-path.php',
// ... existing paths
];Add custom POST test cases to test_post.js:
const postTests = [
{
url: '/your-api-endpoint',
data: { custom: 'payload' },
contentType: 'application/json'
},
// ... existing tests
];Monitor honeypot triggers in real-time:
wrangler tailLook for entries like:
GET Requests:
Honeypot triggered: /.git/config from 192.168.1.100 - Git configuration file
User Agent: Mozilla/5.0 (compatible; Baiduspider/2.0)
POST Requests:
POST request honeypot triggered: https://yoursite.com/api/login from 203.0.113.100
User Agent: curl/7.68.0
Returning error 429: Rate limit exceeded
Track honeypot effectiveness:
- Number of GET honeypot triggers per day
- Number of POST requests with random errors
- Most common attack vectors and endpoints
- Error status code distribution for POST requests
- Geographic distribution of attackers
- User agent patterns
- Response time patterns
MIT License - Feel free to use and modify as needed.