aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobbie Harwood <rharwood@redhat.com>2023-03-09 18:48:16 -0500
committerRobbie Harwood <rharwood@redhat.com>2023-03-13 09:47:55 -0400
commit1de68f913458c3b7db992b7a6e16558775aa96a8 (patch)
treee8f94e0bef96b2c7271ddda04872ae79a5828272
parenta8fd46bb50fdfa30d4dabf634dcc26749c9864a8 (diff)
downloadwee-slack-1de68f913458c3b7db992b7a6e16558775aa96a8.tar.gz
extract_token_from_browser: use new local storage path
webappsstore.sqlite seems to be deprecated, and firefox is migrating to per-page locations. The values inside the database can be snappy-compressed, so handle decoding with a new dependency on python-snappy. Suggested by Trygve Aaberge. Signed-off-by: Robbie Harwood <rharwood@redhat.com>
-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")