Honeypots¶
Overview¶
Honeypots are invisible trap endpoints that only bots reach. Any client that hits a honeypot is instantly classified as a bot and auto-banned.
Usage¶
from drogue.defense.randomizer import HoneypotManager
honeypots = HoneypotManager()
# Register honeypot paths
honeypots.register("/admin/backup.sql", auto_ban=True)
honeypots.register("/honeypot/hidden-link", auto_ban=True)
# Check if request hit a honeypot
if honeypots.is_honeypot("/admin/backup.sql"):
config = honeypots.record_hit("/admin/backup.sql", client_id)
if config["auto_ban"]:
ban_manager.record_violation(client_id)
Registration¶
honeypots.register(
path="/admin/backup.sql",
auto_ban=True, # Auto-ban on hit
ban_duration=86400.0, # 24 hours
response_code=404, # Return 404
)
How It Works¶
- Register honeypot paths
- Honeypots are invisible to real users (hidden in HTML, not linked)
- Bots that crawl the site hit honeypots
- Client is instantly classified as bot
- Auto-ban is applied
- All traffic from that client is re-evaluated
Honeypot Types¶
Hidden Links¶
<!-- Invisible to real users, visible to bots -->
<a href="/honeypot/hidden-link" style="display: none">Click here</a>
Hidden Form Fields¶
<!-- Bots auto-fill hidden fields -->
<input type="text" name="website" style="position: absolute; left: -9999px;">
robots.txt Traps¶
Zero-Size Iframes¶
<!-- Invisible iframe that only bots request -->
<iframe src="/honeypot/monitoring" width="0" height="0" style="display: none"></iframe>
Integration with drogue¶
class DrogueLimiter:
async def _check(self, context):
# Check if request hit a honeypot
if self._honeypot_manager and context:
path = context.get("path", "")
if self._honeypot_manager.is_honeypot(path):
config = self._honeypot_manager.record_hit(path, key)
if config and config["auto_ban"]:
await self._ban_manager.record_violation(key)
# Continue with rate limit check
...
Statistics¶
stats = honeypots.get_stats()
# {
# "registered_honeypots": 5,
# "clients_botted": 25,
# "total_hits": 150,
# }
Use Cases¶
- Bot detection: Instantly classify automated traffic
- Zero false positives: Legitimate users never see honeypots
- Auto-banning: Ban bots without manual intervention
- Threat intelligence: Collect data on attack patterns