Skip to content

Bind evilginx on an unprivileged HTTPS port for local dry-runs - #21

Merged
adamsiwiec1 merged 2 commits into
mainfrom
fix/evilginx-unprivileged-https-port
Oct 24, 2026
Merged

adamsiwiec1 merged 2 commits into
mainfrom
fix/evilginx-unprivileged-https-port

Conversation

@adamsiwiec1

Copy link
Copy Markdown
Contributor

What this fixes

Starting a local dry-run failed with:

evilginx did not bind HTTPS port 443 in time — check evilginx.log (port in use or need elevated privileges).

Nothing was holding 443. The problem is privileges: configure_lure.py launches evilginx in a screen session as the normal user, and evilginx binds 443 directly, which macOS does not allow below port 1024 without root. The HTTPS wait timed out on every start.

Approach

The dry-run binds unprivileged ports by default now, so no sudo is needed: HTTPS on 8443 and DNS on 5354. Set PHISHKIT_HTTPS_PORT=443 (and PHISHKIT_DNS_PORT=53) to use the privileged ports again.

Changes

kit/evilginx/scripts/configure_lure.py

  • Reads PHISHKIT_HTTPS_PORT (default 8443) and PHISHKIT_DNS_PORT (default 5354).
  • Writes https_port and dns_port into config.json.
  • Probes the chosen port instead of a hard-coded 443.
  • Prints the lure URL with the port when it is not 443 (https://host:8443/path).

vendor/evilginx2/core/http_proxy.go, vendor/evilginx2/core/phishlet.go

  • A victim reaches the lure on host:8443, so the Host header carries the port. The request handler strips the port before phishlet and lure host matching, which expect a bare hostname. Without this the TLS request never matches a phishlet off port 443.
  • Generated login and lure URLs include the port when it is not 443, so the 302 to the login page stays on the right port.

crates/phishkit-core/src/{services,evilginx_ctl,readiness}.rs

  • Running-proxy detection honors PHISHKIT_HTTPS_PORT and still checks 8443 and 443.
  • Messages no longer assume 443.

docs/reference/data-and-network.md

  • Documents the default ports, the lure URL format, and the env overrides.

Test

Full lure cycle on macOS, no sudo, user adamsiwiec:

$ python3 kit/evilginx/scripts/configure_lure.py --phishlet generic --dryrun-domain app.bluewire.phishkit --regenerate-path
[configure-lure] lure path=/5aKAKFGt on portal.app.bluewire.phishkit (login path=/login)
[configure-lure] starting background screen session 'phishkit-evilginx'
[configure-lure] evilginx is running in screen (port 8443 listening)
[configure-lure] lure ready: https://portal.app.bluewire.phishkit:8443/5aKAKFGt
https://portal.app.bluewire.phishkit:8443/5aKAKFGt

The listener is owned by the normal user, no root:

$ lsof -nP -iTCP:8443 -sTCP:LISTEN
COMMAND    PID       USER   FD   TYPE  ... NAME
evilginx 65162 adamsiwiec    8u  IPv6  ... TCP *:8443 (LISTEN)

The health probe returns a 302 whose Location carries the port:

$ curl -sk --resolve portal.app.bluewire.phishkit:8443:127.0.0.1 -D - -o /dev/null \
    -H "X-Phishkit-Healthcheck: 1" "https://portal.app.bluewire.phishkit:8443/5aKAKFGt"
HTTP/1.1 302 Found
Location: https://portal.TARGET_DOMAIN:8443/login

(TARGET_DOMAIN is the generic phishlet's placeholder origin, not part of this change.)

cargo build -p phishkit-core passes. The evilginx binary is gitignored and rebuilt from the vendored source with make build-evilginx.

Still needs 443 / root

Nothing for the local dry-run. Production with a real external IP still uses 443 and 53, which require privileges; that path is unchanged and opt-in through the env vars.

Local dry-runs configured evilginx to bind port 443 for the HTTPS lure.
macOS blocks binding ports below 1024 without root, so the launcher timed
out with "evilginx did not bind HTTPS port 443 in time" even when nothing
else held the port. The failure was privileges, not a port conflict.

The dry-run now binds unprivileged ports by default: HTTPS on 8443 and DNS
on 5354. Neither needs sudo. Set PHISHKIT_HTTPS_PORT=443 (and
PHISHKIT_DNS_PORT=53) to restore the privileged ports for production use.

configure_lure.py writes https_port and dns_port into config.json, probes
the chosen port instead of a hard-coded 443, and prints the lure URL with
the port when it is not 443 (https://host:8443/path).

The vendored evilginx needed two changes to actually work off 443. Victims
reach the lure on host:8443, so the Host header carries the port; the
request handler now strips it before phishlet and lure host matching, which
expect a bare hostname. Generated login and lure URLs now include the port
when it is not 443, so redirects stay on the right port.

The Rust engine honors PHISHKIT_HTTPS_PORT when it looks for a running
proxy, and its user-facing messages no longer assume 443.

Tested a full lure cycle on macOS with no sudo: configure, start in screen,
and probe all pass with evilginx bound on 8443.
Reconcile the unprivileged-port fix with the port/probe refactor that landed
on main (audit C1):

- Keep main's robust readiness probing (_socket_listening, https_port_listening,
  non-raising _wait_https_port, _evilginx_process_up, late-bind recheck).
- Keep the branch's intent that local dry-runs default to unprivileged ports so
  evilginx never needs root/sudo: desired_https_port/desired_dns_port now default
  to 8443/5354 and honor both PHISHKIT_* (preferred, matching the Rust engine in
  services.rs) and EVILGINX_* overrides. Set them to 443/53 for privileged prod.
- Keep _port_suffix so the lure URL carries :8443 when not on 443.
- Merge the Rust start-failure tip to mention the unprivileged default and both
  env var names.
- Update tests/python/test_configure_lure.py to expect the new unprivileged
  defaults and cover PHISHKIT_* precedence.
@adamsiwiec1
adamsiwiec1 merged commit bd02563 into main Oct 24, 2026
7 checks passed
@adamsiwiec1
adamsiwiec1 deleted the fix/evilginx-unprivileged-https-port branch October 24, 2026 08:15
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