feat: add WSL2 Windows Firefox cookie extraction for X auth

On WSL2, native Linux Firefox typically has no x.com cookies since users
browse in Windows. Chromium browsers (Edge, Chrome, Brave) encrypt cookies
with DPAPI/app-bound encryption, making them inaccessible without admin
privileges. Windows Firefox stores cookies unencrypted in SQLite, readable
directly through the /mnt/c mount.

The cookie extractor now detects WSL2 via /proc/version, locates Windows
Firefox profiles under /mnt/c/Users/*/AppData/Roaming/Mozilla/Firefox,
and falls back to them when Linux Firefox yields no results. Reports
source as "firefox-wsl" to distinguish from native.

Also fixes profile resolution priority: Install* sections (Firefox >= 67)
now take precedence over the legacy Default=1 flag, which could select a
stale profile on multi-profile installations.
This commit is contained in:
Ilia Alshanetsky
2026-04-09 18:33:03 -04:00
parent 45f596ca0c
commit 252c8222f1
2 changed files with 106 additions and 18 deletions
+9
View File
@@ -153,6 +153,9 @@ class TestExtractFirefoxCookies:
with patch(
"scripts.lib.cookie_extract._get_firefox_profiles_dir",
return_value=None,
), patch(
"scripts.lib.cookie_extract._is_wsl",
return_value=False,
):
result = extract_firefox_cookies(".x.com", ["auth_token"])
@@ -167,6 +170,9 @@ class TestExtractFirefoxCookies:
with patch(
"scripts.lib.cookie_extract._get_firefox_profiles_dir",
return_value=profiles_dir,
), patch(
"scripts.lib.cookie_extract._is_wsl",
return_value=False,
):
result = extract_firefox_cookies(".x.com", ["auth_token", "ct0"])
@@ -185,6 +191,9 @@ class TestExtractFirefoxCookies:
with patch(
"scripts.lib.cookie_extract._get_firefox_profiles_dir",
return_value=profiles_dir,
), patch(
"scripts.lib.cookie_extract._is_wsl",
return_value=False,
):
result = extract_firefox_cookies(".x.com", ["auth_token", "ct0"])