aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xextract_token_from_browser.py20
2 files changed, 18 insertions, 4 deletions
diff --git a/README.md b/README.md
index f1e870e..74ea2aa 100644
--- a/README.md
+++ b/README.md
@@ -207,6 +207,8 @@ get the tokens and cookies for all the teams you're logged into:
./extract_token_from_browser.py firefox
```
+(Note this script requires the python3-snappy library.)
+
#### Optional: Connecting to multiple teams
You can run the register command multiple times to connect to multiple teams.
diff --git a/extract_token_from_browser.py b/extract_token_from_browser.py
index d42bd5b..a4a0d2c 100755
--- a/extract_token_from_browser.py
+++ b/extract_token_from_browser.py
@@ -4,6 +4,7 @@ import argparse
from configparser import ConfigParser
import json
from pathlib import Path
+from snappy import snappy
import sqlite3
import sys
@@ -62,12 +63,23 @@ if cookie_ds_values:
else:
cookie_value = cookie_d_value
-local_storage_path = default_profile_path.joinpath("webappsstore.sqlite")
-con = sqlite3.connect(f"file:{local_storage_path}?immutable=1", uri=True)
-local_storage_query = "SELECT value FROM webappsstore2 WHERE key = 'localConfig_v2'"
-local_config_str = con.execute(local_storage_query).fetchone()[0]
+storage_path = default_profile_path.joinpath(
+ "storage/default/https+++app.slack.com/ls/data.sqlite"
+)
+con = sqlite3.connect(f"file:{storage_path}?immutable=1", uri=True)
+storage_query = "SELECT compression_type, conversion_type, value FROM data WHERE key = 'localConfig_v2'"
+is_compressed, conversion, payload = con.execute(storage_query).fetchone()
con.close()
+if is_compressed:
+ payload = snappy.decompress(payload)
+
+if conversion == 1:
+ local_config_str = payload.decode("utf-8")
+else:
+ # untested; possibly Windows-only?
+ local_config_str = payload.decode("utf-16")
+
local_config = json.loads(local_config_str)
teams = [
team for team in local_config["teams"].values() if not team["id"].startswith("E")