diff options
author | Krzysztof Konopko <krzysztof.konopko@amk.zone> | 2023-12-13 09:36:20 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2023-12-13 10:25:22 +0100 |
commit | e093af47456199fcb41614665cc07debd74151ef (patch) | |
tree | abd55df40ba83e99825b9bc2b6351834669ee158 | |
parent | 32a6b4dca0217b3ce8066672e019005b0bee607a (diff) | |
download | wee-slack-e093af47456199fcb41614665cc07debd74151ef.tar.gz |
Add no-secretstorage option for extract_token_from_browser.py
On some Linux systems org.freedesktop.Secret D-Bus service is not
available (installed/enabled), typically as a deliberate choice. In
those cases `extract_token_from_browser.py` hands for the duration of
D-Bus timeout and eventually fails. Note that it does not handle the
timeout exception, so a fallback is not used.
This commit adds `--no-secretstorage` option which skips using that
service.
-rwxr-xr-x | extract_token_from_browser.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/extract_token_from_browser.py b/extract_token_from_browser.py index d287f97..070e563 100755 --- a/extract_token_from_browser.py +++ b/extract_token_from_browser.py @@ -74,6 +74,11 @@ parser.add_argument( metavar="<id or name>", nargs="?", ) +parser.add_argument( + "--no-secretstorage", + help="Disable accessing freedesktop Secret D-Bus service", + action="store_true", +) args = parser.parse_args() browser: Literal["firefox", "chrome"] @@ -232,22 +237,25 @@ elif browser == "chrome": ) cookie_d_value, cookie_ds_value = get_cookies(cookies_path, cookie_query, ()) - bus = secretstorage.dbus_init() - try: - collection = secretstorage.get_default_collection(bus) - for item in collection.get_all_items(): - if item.get_label() == "Chrome Safe Storage": - passwd = item.get_secret() - break - else: - raise Exception("Chrome password not found!") - except SecretStorageException: - print( - "Error communicating org.freedesktop.secrets, trying 'peanuts' " - "as a password", - file=sys.stderr, - ) + if args.no_secretstorage: passwd = "peanuts" + else: + bus = secretstorage.dbus_init() + try: + collection = secretstorage.get_default_collection(bus) + for item in collection.get_all_items(): + if item.get_label() == "Chrome Safe Storage": + passwd = item.get_secret() + break + else: + raise Exception("Chrome password not found!") + except SecretStorageException: + print( + "Error communicating org.freedesktop.secrets, trying 'peanuts' " + "as a password", + file=sys.stderr, + ) + passwd = "peanuts" salt = b"saltysalt" length = 16 |