diff options
author | Robbie Harwood <rharwood@redhat.com> | 2023-03-09 18:48:16 -0500 |
---|---|---|
committer | Robbie Harwood <rharwood@redhat.com> | 2023-03-13 09:47:55 -0400 |
commit | 1de68f913458c3b7db992b7a6e16558775aa96a8 (patch) | |
tree | e8f94e0bef96b2c7271ddda04872ae79a5828272 | |
parent | a8fd46bb50fdfa30d4dabf634dcc26749c9864a8 (diff) | |
download | wee-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.md | 2 | ||||
-rwxr-xr-x | extract_token_from_browser.py | 20 |
2 files changed, 18 insertions, 4 deletions
@@ -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") |