Threat Hunting III: HTTP Honeypot
- Introduction
- Architecture Overview
- Containerizing with Docker
- Configuration
- Code Improvements
- Advantages Over the Original
- Testing
- Next Steps
- Summary
Introduction
I set out to build a honeypot that captures HTTP attack traffic and forwards it directly to Elasticsearch for analysis. Instead of reinventing the wheel, I built on top of honeyhttpd by bocajspear1 and added structured logging, credential extraction, and proper sanitization.
The result is a production-ready honeypot that simulates an Apache server protected by HTTP Basic Authentication, capturing attacker credentials and request metadata in queryable Elasticsearch documents.
Architecture Overview
The honeypot works in three layers:
ApachePasswordServer— Demands Basic Auth on every request, parses HTTP headers, and collects metadataElasticSearchLogger— Sanitizes logs and indexes them into Elasticsearch- Docker Container — Runs the entire stack in an isolated environment
Containerizing with Docker
I packaged the honeypot as a Docker container for easy deployment:
Build and run:
Configuration
Point the honeypot at your Elasticsearch instance via config.json:
Code Improvements
ApachePasswordServer.py
The server now properly simulates HTTP Basic Authentication and captures credentials in a structured way.
Key features:
on_request()— Enforces Basic Auth on every request. Returns 401 if Authorization header is missingon_POST()— Stashes POST bodies for logging (critical for capturing login attempts)on_complete()— Parses HTTP metadata: method, URL, request/response headers, and decodes Basic Auth credentials
Helper functions:
The on_complete() method collects:
- HTTP method and URL
- Request/response headers (User-Agent, Accept, Content-Type, etc.)
- HTTP status code
- Decoded credentials (username:password)
- POST body (for form submissions)
ElasticSearchLogger.py
The logger sanitizes all input before indexing to prevent injection attacks and ensure clean Elasticsearch documents.
Sanitization functions:
Elasticsearch indexing:
These fields are compatible with Elasticsearch’s ECS (Elastic Common Schema), making queries and alerts straightforward.
Advantages Over the Original
| Feature | Original | Improved |
|---|---|---|
| Credential Capture | Basic string parsing | Base64 decoding + validation |
| POST Body Handling | Not captured | Properly extracted and logged |
| Input Sanitization | None | Removes control chars, truncates |
| Error Handling | Minimal | Comprehensive logging |
| Elasticsearch Integration | Manual logging | Direct indexing with ECS schema |
Testing
Once deployed, test the honeypot:
This should trigger a Basic Auth challenge. When credentials are provided, they get captured and indexed in Elasticsearch.
Query Elasticsearch:
Next Steps
- TODO: Automated testing with OWASP ZAP or similar tools
- TODO: Deploy to production honeypot server for live monitoring
- TODO: Submit improvements as pull request to original honeyhttpd project
- TODO: ELK Stack setup guide for visualization and alerting
Summary
This enhanced honeypot transforms a simple HTTP challenge responder into a structured threat hunting tool. By capturing credentials, request metadata, and response data in Elasticsearch, you gain visibility into attack patterns and attacker behavior.
The honeypot is production-ready: it handles edge cases, sanitizes malicious input, and integrates seamlessly with existing SIEM infrastructure.