# Django Admin Pentest

> Use when a Django admin panel is reachable: loot it.

- Skill: `yufeifeio/django-admin-pentest` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add yufeifeio/django-admin-pentest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yufeifeio/django-admin-pentest/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Yufeifeio (https://skillmd.com/u/yufeifeio)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/yufeifeio/django-admin-pentest

---


# Django Admin / Backoffice — post-exploit toolkit

Class of work: the unified Django admin behind a login (your creds, leaked creds, or a bypass). SSO-gated variants → also load `corporate-sso-admin-pentest`; the secret store it points to → `infisical-pentest`. Validated hauling full platform backends (250+ models, live data pipelines) — case: `references/betmaster-alpha-admin-case.md`.

## Entry & site topology
- **Double doors are common**: nginx basic-auth THEN the Django form. Flow: `GET /admin/login/` (with basic) → parse `csrfmiddlewaretoken` (order-insensitive regex: `name="csrfmiddlewaretoken"[^>]*value="([^"]+)"`) → `POST` with `Referer` → success = 302 to `/admin/` (302 back to login = wrong creds).
- **One host can serve several admin SITES**: `/admin/`, `/messaging-admin/`, `/promo-admin/` = separate django-admin sites with different model sets/perms — enumerate every header link; a superuser on site A can still hit "Permission Denied" on site B's add form.
- Fleet pattern `admin.<env>.<corp-domain>` (alpha/beta/gamma/qa/preprod-*): the same creds often clear several; 404 = env down (DNS may still resolve — park for revival watch), 401-after-basic = different auth stack (skip).

## Enumerate like a loot map (first 5 minutes)
- Scrape ALL model links from the index: `href="(/admin/[a-z0-9_]+/[a-z0-9_]+/)"`. Prioritize: `constance`, event-bus/audit models, extraction/report models, payment, messaging, user/contact-ish apps.
- **django-constance** (`/admin/constance/config/` on every site) = runtime settings dump — the single best page. Parse every `<textarea>` (JSON values live there). Seen in the wild: social-auth email whitelist/map, payment-system routing rules + card-BIN tables, support-chat configs (provider app_ids), messaging send-routing, market/currency configs, monitoring rules.
- **Event/audit models** ("Eventbus events"): listview renders payload inline (`<code>{...}</code>`, 100/page); filters are plain GET params (`?event_type=X`, `?user_uuid=Y`; checkbox families like `event_type-options`). Payloads expose internal schemes (dedupe-hash family names, service uuids, license/market structure) and give per-user timelines without touching the DB. The event-type list itself is a platform feature map (100+ types: payments, RG limits, KYC, claims…).
- **Hidden raw JSON in change pages**: grep each detail page for `<textarea` + `jsonview` — e.g. `field_render_context_code` holds the full render context (complete user/object JSON beyond the form), `raw_data` holds full third-party provider responses (validated: a real Twilio account SID leaked from a message's raw_data while the UI masked the phone).

## Masks are display-layer — hunt exports, not pixels
- Repeatedly validated across this target family: list/detail views mask PII (`+519****5678`) while the value is intact underneath (search indexes, exports, sibling views, logs). Never conclude "protected" from a mask.
- **Object actions**: detail pages list action endpoints (`/admin/<app>/<model>/<id>/actions/<action>/` — export_obj, clone, emergency_cancel, resend…); changelists have bulk action dropdowns. Some are side-effecting (resend/cancel/clone) — read-only first. Export actions may 400/500 without params — read the JSON error body.
- **data_extraction / GDPR-export models**: rows carry DOWNLOAD links to generated zips, frequently on public CDN/storage with NO auth (validated: `https://<cdn>/<bucket>/data_extraction_reports/report_<uid>_<rid>_<rand>.zip`). Harvest every row's link, download all, inspect: exports contained mail HTML (OTP codes), SMS bodies, support-chat transcripts, payment/bet CSVs. The same codebase runs in every env — the pipeline shape transfers even when the data is a dev copy.
- django admin **history** pages = per-change actor trail (rosters, rotation cadence); import-export style list actions (`export/`) 302 to login when absent — don't chase.

## Scripting writes: actions, formsets & the encrypted-field oracle test
- **Custom action endpoints**: detail pages render custom actions as `…/actions/<action>/` links (some carry `hx-get` for htmx modals — a plain GET returns the fragment). Bulk actions need the action field + `_selected_action` in the POST, else you bounce back to the changelist.
- **POSTs need the confirmation checkbox**: custom views add a required `admin_confirmed_changes` («I confirm the changes») — omit it and the form re-renders with *This field is required* and **nothing saves** (first read looks like a silent no-op; always parse `errorlist` blocks). Formsets additionally want `form-TOTAL_FORMS / INITIAL_FORMS / MIN_NUM_FORMS / MAX_NUM_FORMS` + `form-<i>-id` + per-row fields; `disabled` checkboxes are intentionally unsubmitted — don't force them.
- **Validation wall**: phone/email-typed fields reject non-conforming strings (a pasted cipher into a phone contact silently reverts to the old value); free-text fields (city/address/name) accept anything — use those for experiments, and **restore original values afterward**.
- **Encrypted-field 'paste-a-cipher' oracle test** (can this admin decode *foreign* ciphertexts?): control-write a normal value first to prove the write path; then paste a real cipher from the target's data layer into an encrypted field, save, re-read:
  - idempotent field + shared key → re-display shows the **decoded plaintext** → admin = decryption machine for that key set;
  - non-idempotent field (stores enc(any input)) → display shows the **literal pasted string** → oracle dead; don't per-field retry (validated: contact/name/city all re-encrypt).
- **Verify by raw bytes, not rendered value**: display layers (terminal/chat) can mask PII strings and fake 'server-side masking'. Compare `value.encode().hex()` from the HTML source (or hash-check) before concluding masked vs plain.
- **Login error strings leak the identifier format**: «Please enter the correct **uuid** and password for a staff account» → usernames are user-UUIDs, not emails (uuid+pw+OTP triple gate); wrong-password vs wrong-OTP often share one message (no enumeration). TOTP device models (e.g. `challenges/totpdevice`) may be listable as superuser — seeds typically not rendered (staff roster only), throttling counters mean no TOTP brute.

## Before treating a haul as prod data
- Cross-check known-real values (phones/uids from other loot) against the instance's search — 0 hits = separate env. Validated: a dev instance with live Twilio traffic and real-looking profiles contained NO prod phones.
- Read the site title: "… (DEV)" vs prod. Report provenance explicitly.

## Pitfalls
- Paginated result counts can render as `999999999` artifacts — count actual row links instead.
- Change pages may be POST-only/CSRF-guarded for add forms (Permission Denied on add = normal for a viewer role); don't burn time re-authing.
- Long inline commands with many quotes/UTF-8 can hit the agent's command parser block — write a script file and `bash` it instead.

## Files
- `references/betmaster-alpha-admin-case.md` — full case: host patterns, model map, exact paths that paid (constance fields, eventbus, extraction zips, messaging-admin, fleet sweep results).

