Skip to content

fix(core): export all three evilginx token maps, stop pruning cookie-only captures - #18

Merged
adamsiwiec1 merged 1 commit into
mainfrom
fix/export-all-token-maps
Oct 26, 2026
Merged

adamsiwiec1 merged 1 commit into
mainfrom
fix/export-all-token-maps

Conversation

@adamsiwiec1

Copy link
Copy Markdown
Contributor

Fixes #17

What was wrong

Captured session cookies were not making it out of PhishKit. Two spots in crates/phishkit-core (the shared core used by both the CLI in apps/cli and the desktop UI in apps/desktop) only looked at a subset of evilginx's token maps:

  • export_capture_cookies in src/sessions.rs read only the tokens map and ignored body_tokens and http_tokens, so material captured in those maps never showed up in an export.
  • prune_empty_captures in src/db.rs decided a capture was empty by checking body_tokens alone. A cookie-only capture (material in tokens) looked empty to prune and got removed.

Because both live in the shared core, this affected the CLI and the desktop UI, not one surface.

Changes

  1. export_capture_cookies now reads all three maps (tokens, body_tokens, http_tokens). JSON output returns { "cookies": ..., "body_tokens": ..., "http_tokens": ... }. Netscape output still emits browser-importable cookie lines from tokens; when there are no cookie tokens but body or http tokens hold material, it writes a short comment naming which map has the material and pointing to --format json, instead of a bare header that looks like an empty capture.
  2. New shared helper capture_has_material returns true when any of tokens, body_tokens, http_tokens, custom, username, or password is set. prune_empty_captures now uses it, so the prune check and the has-material judgment share one definition and cannot drift.
  3. Tests in src/sessions.rs:
    • a body/http-only capture exports non-empty (JSON carries the body material; Netscape emits the note),
    • a cookie-only capture is not pruned while a genuinely empty one still is,
    • JSON export includes all three maps.

Compatibility note

The JSON export shape changed. It used to return the bare tokens object; it now returns { cookies, body_tokens, http_tokens }, where cookies holds what tokens used to be. Anything parsing the JSON export directly should read .cookies for the old value. Netscape output is unchanged for captures that have cookie tokens. The change was needed to surface body and http material at all, which is the point of the fix.

Tests

cargo test -p phishkit-core, all green:

test sessions::export_tests::body_http_only_capture_exports_non_empty ... ok
test sessions::export_tests::cookie_only_capture_is_not_pruned ... ok
test sessions::export_tests::export_json_shape_includes_all_three_maps ... ok
test result: ok. 36 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

The integration test binaries also pass (recon, secret_store).

Testing help

@seth-stitik if you can repro against a live evilginx run, it would help to confirm the end-to-end path: capture a session that lands tokens in body_tokens/http_tokens but not tokens, run export --format json and check all three keys are present, then run prune and confirm a cookie-only capture survives.

…ie-only captures

export_capture_cookies now reads tokens, body_tokens, and http_tokens. JSON
output returns { cookies, body_tokens, http_tokens }; Netscape output emits a
note when there are no cookie tokens but body/http material exists.

Adds capture_has_material as the single has-material check, used by both the
exporter and prune_empty_captures so they cannot drift. prune previously only
looked at body_tokens, so cookie-only captures were wrongly pruned.

Fixes #17
@adamsiwiec1
adamsiwiec1 merged commit 3c56698 into main Oct 26, 2026
5 checks passed
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.

export-cookies returns empty when auth material is captured as body/HTTP tokens, not cookies

1 participant