Skip to main content

Reusable Django app providing multi-CMS honeypot login traps with DB logging and email alerts.

Project description

django-honeyguard pypi version rtd

license python version django version build

📖 Documentation: https://django-honeyguard.readthedocs.io

HoneyGuard is a reusable Django app that provides fake admin login pages (honeypots) for Django and WordPress, logs suspicious requests, detects timing anomalies, and optionally sends alerts. Protect your real admin by wasting attackers’ time and gathering intelligence safely.

Features

  • Live timing detection (too-fast/too-slow submissions)
  • Hidden honeypot field detection
  • Fake login pages for Django Admin and WordPress
  • Comprehensive logging with risk scores
  • Pluggable signal to integrate custom handlers
  • Optional email alerts and console logging
  • URL include or drop-in views usage
  • Strict settings validation at startup

Preview

The package ships with templates for:

  • django_honeyguard/django_admin_login.html (fake Django admin)
  • django_honeyguard/wp_admin_login.html (fake WordPress admin)

Include the URLs and visit /admin/ or /wp-admin.php to see the honeypots in action.

Requirements

  • Django >= 5.0.0
  • Python >= 3.10

Installation

Install from PyPI:

pip install django-honeyguard

Add the app to INSTALLED_APPS:

# settings.py
INSTALLED_APPS = [
    # ...
    "django_honeyguard",
]

Include the URLs (Option A), or wire views directly (Option B):

# urls.py
from django.urls import include, path

urlpatterns = [
    # Option A: include both fake admin pages
    path("", include("django_honeyguard.urls")),

    # Option B: use individual views
    # from django_honeyguard.views import FakeDjangoAdminView, FakeWPAdminView
    # path("admin/", FakeDjangoAdminView.as_view()),
    # path("wp-admin.php", FakeWPAdminView.as_view()),
]

Run migrations (creates log table):

python manage.py migrate

Settings (settings.py)

You can configure HoneyGuard via a HONEYGUARD dictionary or individual HONEYGUARD_* settings. Defaults shown below:

HONEYGUARD = {
    # Email alerts
    "EMAIL_RECIPIENTS": [],
    "EMAIL_SUBJECT_PREFIX": "🚨 Honeypot Alert",
    "EMAIL_FROM": None,              # Uses Django DEFAULT_FROM_EMAIL if None
    "EMAIL_FAIL_SILENTLY": True,     # Do not crash on email errors

    # Timing detection (seconds)
    "TIMING_TOO_FAST_THRESHOLD": 2.0,
    "TIMING_TOO_SLOW_THRESHOLD": 600.0,

    # Logging
    "ENABLE_CONSOLE_LOGGING": True,
    "LOG_LEVEL": "WARNING",        # DEBUG, INFO, WARNING, ERROR, CRITICAL

    # Detection behavior
    "ENABLE_GET_METHOD_DETECTION": False,  # Detect on GET as well as POST

    # Field limits
    "MAX_USERNAME_LENGTH": 150,
    "MAX_PASSWORD_LENGTH": 128,
    "WORDPRESS_USERNAME_MAX_LENGTH": 60,
    "WORDPRESS_PASSWORD_MAX_LENGTH": 255,

    # Error messages (shown on fake pages)
    "DJANGO_ERROR_MESSAGE": (
        "Please enter a correct username and password. Note that both fields"
        " may be case-sensitive."
    ),
    "WORDPRESS_ERROR_MESSAGE": (
        "<strong>Error:</strong> The password you entered for the username is incorrect."
    ),
}

Usage

  • Visit /admin/ for the fake Django admin login page
  • Visit /wp-admin.php for the fake WordPress login page
  • Submissions and suspicious GETs will be logged via the honeypot_triggered signal

Listen to the honeypot_triggered signal to add custom behaviors:

from django_honeyguard.signals import honeypot_triggered
from django.dispatch import receiver

@receiver(honeypot_triggered)
def my_handler(sender, request, data, **kwargs):
    # data contains ip_address, path, username, timing info, risk_score, etc.
    pass

Documentation

Complete documentation is available at: https://django-honeyguard.readthedocs.io/

Running the docs locally:

git clone https://github.com/alihtt/django-honeyguard.git
cd django-honeyguard
python -m venv .venv && source .venv/bin/activate
pip install -r docs/requirements.txt
cd docs && make html
# open _build/html/index.html in your browser

Notes

  • This package does not replace Django’s real authentication; it provides decoy pages and logging.
  • Always secure your real admin at a non-obvious URL and behind proper authentication and rate limiting.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_honeyguard-0.1.3.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_honeyguard-0.1.3-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file django_honeyguard-0.1.3.tar.gz.

File metadata

  • Download URL: django_honeyguard-0.1.3.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_honeyguard-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4460895e9ca4202fa121ed39a57ce5929532449cf589dab34ed2bfe103beeffe
MD5 ecc049dbff87768ae3d95912bdda4a0b
BLAKE2b-256 a9c9484256d7fb709c3cb5975f09884d8b9861d2fbca81abd5091efd1460102d

See more details on using hashes here.

File details

Details for the file django_honeyguard-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_honeyguard-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bc89c4c4d0ee0ce52a4f9831269092c1631091366e0a60907c2f77e24d13c4b6
MD5 15462145300dfca11dd0cd7bd2dfaa67
BLAKE2b-256 39577296a63657ad86a5bc2feae8005bba1773753dc01262a8fc6c6e6e413460

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page