How pwnlandia/mhn works
Project Type and Purpose
• This is a full-stack, server-centric honeypot management and data-collection platform (“Modern Honey Network” or MHN).
High-Level Architectural Components
a. Sensor Layer (“Honeypots”)
• Deployed sensors (Dionaea, Cowrie, Snort, etc.) run remote scripts (in scripts/deploy_*.sh).
• They register with the MHN server via the HTTP API and/or hpfeeds protocol to send events/logs.
b. Ingress/API Layer
• Nginx (or another web proxy) sits at the front, routing requests to:
• uWSGI-hosted Flask app (the main server/mhn code).
• Raw collector endpoints (collector.py, collector_v2.py).
c. Application Layer
• Flask application exposes RESTful endpoints (mhn/api/views.py) and renders the UI (mhn/ui/views.py).
• Background workers:
• Celery (tasks in mhn/tasks) handles periodic jobs (e.g., rule updates, geolocation).
• Supervisor orchestrates processes: hpfeeds-broker, honeymap, geoloc, mhn-collector, mhn-uwsgi, Celery beat/worker, mnemosyne.
d. Data Layer
• Primary datastore: MongoDB (configured via initdatabase.py, requirements.txt).
• hpfeeds message broker stores incoming honeypot events in-memory and feeds them into the collector.
e. External Integrations
• Splunk/ArcSight loggers (install_hpfeeds-logger-*.sh) subscribe to hpfeeds and forward to SIEMs.
• Honeymap visualization service (runs on port 3000).
• Optional email provider (SMTP) for password resets and alerts.
Relationships and Data Flows
• Deployment: Admin UI → Flask API → Deploy script URL → Sensor
• Registration & Logs: Sensor → HTTP or hpfeeds → hpfeeds-broker → mhn-collector → MongoDB
• Rule Distribution: Flask API → Sensor (on request)
• Background Processing: Celery workers process raw events, update rule sets, perform geolocation, and write enriched data back to MongoDB.
• UI Requests: Browser → Nginx → uWSGI Flask → MongoDB → JSON/views → Browser
• External SIEM: hpfeeds-logger → Splunk/ArcSight
Key Architectural Patterns and Principles
• Layered architecture (Ingress/API → Application logic → Persistence → External integrations)
• Asynchronous processing via message queue (hpfeeds) and task queue (Celery)
• Process supervision (Supervisor, Docker entrypoint)
• Configuration via templates (config.py.template, environment variables for Docker)