Skip to content

fix(aitm): make the cookie AiTM demo work end to end (audit C1) - #9

Merged
adamsiwiec1 merged 2 commits into
mainfrom
fix/aitm-demo-e2e
Oct 19, 2026
Merged

adamsiwiec1 merged 2 commits into
mainfrom
fix/aitm-demo-e2e

Conversation

@adamsiwiec1

Copy link
Copy Markdown
Contributor

What

Makes the bundled AiTM cookie demo work end to end and hardens the lure launcher
around it. This is the audit's C1 (Critical) finding: as shipped, the headline
evilginx capture flow could not complete out of the box.

Why

Following the README landed a new user in a dead end:

  1. The demo-cookie phishlet pointed its upstream (proxy_hosts.domain) at the
    same host as the lure, so evilginx dialed its own hostname and looped. No
    session was ever captured.
  2. ensure-destination scaffolded a second phishlet whose landing host collided
    with demo-cookie, so evilginx refused to load both.
  3. The launcher's bind poll shelled out to lsof only and reported "did not bind
    HTTPS port 443 in time" even when evilginx was up and listening.
  4. The launcher hard-coded :443/:53 with no unprivileged option and no
    teardown when a start failed.
  5. make setup never installed screen or pexpect, so the first start-lure
    died with FileNotFoundError: 'screen'.

How

  • Working demo phishlet + upstream. demo-cookie.yaml now proxies the lure
    host demo-cookie.local.phishkit to a distinct HTTPS upstream
    app.cookie-demo.test. demos/cookie/server.ts serves HTTPS when
    TLS_CERT/TLS_KEY are set, and make demo-cookie-tls stands that upstream up
    with a self-signed cert. evilginx proxies to it with verification off (goproxy
    default), so a self-signed cert is fine for the dry-run.
  • Bind poll fixed. configure_lure.py probes the configured HTTPS port with a
    socket connect (falling back to ss/lsof), re-checks once after the process
    is confirmed up, and reads the port from the config instead of a hard-coded 443.
  • Privileged-port story. EVILGINX_HTTPS_PORT / EVILGINX_DNS_PORT let the
    lure bind unprivileged high ports; the docs cover setcap/sudo for the full
    loop. No security default was weakened.
  • Teardown. A failed start now quits the screen session and clears the
    half-bound port (both the Python launcher and evilginx_ctl).
  • Collision fix. ensure-destination reuses an existing phishlet that already
    serves the same landing host instead of writing a colliding duplicate.
  • upstream_domain now handles single-label internal hosts and compound
    public suffixes (co.uk, github.io, and similar).
  • make setup installs pexpect into a managed venv/ and checks for
    screen.

How it was verified

Run on a headless Debian box (no root). All green:

  • cargo fmt --check, cargo clippy -D warnings, and
    cargo test -p phishkit-core -p phishkit-cli --all-targets — 15 core + 5
    integration tests pass, including new tests for upstream_domain (apex,
    single-label, compound suffixes), inline proxy-host parsing, and phishlet reuse.
  • python3 -m unittest discover -s tests/python — 16 tests covering port
    selection, the socket bind poll, config/port injection, and lure-path logic.
  • bash tests/smoke/demo_cookie_e2e.sh (make test-aitm) — stands up the HTTPS
    upstream and drives login → Set-Cookie: session → authenticated /dashboard.
  • Built evilginx and confirmed the new phishlet loads with no parse or collision
    errors (make validate-phishlet PHISHLET=demo-cookie).
  • Launched evilginx with EVILGINX_HTTPS_PORT=8443 and confirmed it binds
    127.0.0.1:8443 while the new socket probe detects it — the old lsof-only
    probe returns nothing here (no lsof installed), which is exactly the false
    negative this fixes.
  • A new CI job runs the Python unit tests and the smoke test on every PR.

Still needs root / manual

  • The full proxy loop through evilginx binds :443/:53 and the upstream binds
    127.0.0.2:443, so it needs root or setcap and /etc/hosts entries. That
    path is scripted in tests/smoke/aitm_e2e_sudo.sh (sudo bash ...) and
    documented in the walkthrough. CI runs the unprivileged surface test instead.

Files changed

Engine: engagement.rs, destination.rs, evilginx_ctl.rs. Launcher:
kit/evilginx/scripts/configure_lure.py. Demo: demos/cookie/server.ts,
kit/evilginx/phishlets/demo-cookie.yaml, scripts/gen_demo_tls_cert.sh,
Makefile. Tests: tests/python/test_configure_lure.py,
tests/smoke/demo_cookie_e2e.sh, tests/smoke/aitm_e2e_sudo.sh, CI job. Docs:
README.md, docs/guide/walkthrough.md, CHANGELOG.md.

The headline evilginx capture flow could not complete out of the box
(audit C1). This fixes the demo so a lure proxies to a real upstream and
captures a session, and hardens the launcher around it.

- demo-cookie phishlet now proxies to a reachable HTTPS upstream
  (app.cookie-demo.test) distinct from the lure host, instead of pointing
  its upstream at the lure and looping (C1.4).
- demos/cookie serves HTTPS when TLS_CERT/TLS_KEY are set; new
  'make demo-cookie-tls' stands it up as the upstream (C1.4).
- configure_lure.py: port-aware, socket-based bind poll with ss/lsof
  fallback and a re-check after the process is up, so it stops reporting a
  false negative on a successful bind (C1.3); honors EVILGINX_HTTPS_PORT /
  EVILGINX_DNS_PORT for unprivileged high ports (C1.2); tears down the
  screen session on failure (L1).
- evilginx_ctl: tear down a failed start; clearer privileged-port guidance.
- ensure-destination reuses an existing phishlet with the same landing host
  instead of scaffolding a colliding duplicate (C1.5).
- upstream_domain handles single-label and compound public suffixes (M1).
- make setup installs pexpect into venv and checks for screen (C1.1).

Tests: Rust unit tests for upstream_domain, host parsing, and phishlet
reuse; Python unit tests for the launcher; an unprivileged smoke test of
the HTTPS upstream + cookie capture surface; a sudo full-loop script; and a
CI job that runs the Python tests and smoke test.
@adamsiwiec1
adamsiwiec1 merged commit 155e6ba into main Oct 19, 2026
4 of 6 checks passed
@adamsiwiec1
adamsiwiec1 deleted the fix/aitm-demo-e2e branch October 19, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant