Repository navigation
Bind evilginx on an unprivileged HTTPS port for local dry-runs - #21
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Starting a local dry-run failed with:
Nothing was holding 443. The problem is privileges:
configure_lure.pylaunches evilginx in ascreensession 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
8443and DNS on5354. SetPHISHKIT_HTTPS_PORT=443(andPHISHKIT_DNS_PORT=53) to use the privileged ports again.Changes
kit/evilginx/scripts/configure_lure.pyPHISHKIT_HTTPS_PORT(default8443) andPHISHKIT_DNS_PORT(default5354).https_portanddns_portintoconfig.json.https://host:8443/path).vendor/evilginx2/core/http_proxy.go,vendor/evilginx2/core/phishlet.gohost:8443, so theHostheader 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.crates/phishkit-core/src/{services,evilginx_ctl,readiness}.rsPHISHKIT_HTTPS_PORTand still checks 8443 and 443.docs/reference/data-and-network.mdTest
Full lure cycle on macOS, no sudo, user
adamsiwiec:The listener is owned by the normal user, no root:
The health probe returns a 302 whose
Locationcarries the port:(
TARGET_DOMAINis thegenericphishlet's placeholder origin, not part of this change.)cargo build -p phishkit-corepasses. The evilginx binary is gitignored and rebuilt from the vendored source withmake 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.