pycookiecheat icon indicating copy to clipboard operation
pycookiecheat copied to clipboard

Enhancement: support the Slack app's cookies

Open hraftery opened this issue 3 years ago • 4 comments

  • Operating system and version:

macOS 11.6.5 and Linux Mint 20

  • Python version:

3.9.12 and 3.8.10

  • pycookiecheat version:

v0.4.7 and master head.

My Issue

The Slack desktop app uses the same cookie storage mechanism as Chrome and Chromium, and there appears to be no more advanced tool for Cookie extraction than pycookiecheat. Although the use cases for extracting cookies from a browser (ie. to browse web pages) might be slightly different to the use cases for extracting cookies from Slack (ie. to access the Slack API manually), the modification to allow pycookiecheat to do both turns out to be really small.

After much consideration about whether to diverge or merge, I believe the best option is to generalise pycookiecheat's functionality slightly, and keep it as the best resource for cookie extraction.

WHYT

Simply passing "Slack" as the browser parameter and Slack's cookie file as the cookie_file parameter to chrome_cookies() results in the misleading "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 3: invalid start byte" type errors. It turns out this is simply because the wrong password is pulled from the keyring. All that needs to change for this to work is to point to a different keyring. Specifying the correct cookie_file can easily be achieved using the existing interface, but specifying the keyring name cannot.

By simply allowing "Slack" as a browser name, the keyring name is correctly determined on macos. The story is a bit more complicated on Linux (tested with some effort on Linux Mint), but turns out to provide a more robust keyring determination method in general anyway.

Thus, I'd like to offer the improvements in a pull request, in the hope that they find their way to PyPI. The relevant commit is ~~here~~.


Please make sure you've taken these steps before submitting a new issue:

  • [X] Include the Python and pycookiecheat version in your issue
  • [X] Ensure you're running a supported version of Python
  • [X] Run pycookiecheat in debug mode if applicable and include relevant output
  • [X] Search the existing (including closed) issues
  • [X] Please use codeblocks for any code, config, program output, etc.

hraftery avatar Apr 27 '22 03:04 hraftery

Sorry, relevant commit is here

hraftery avatar Apr 27 '22 06:04 hraftery

Interesting find!

Yes, can you please make this into a PR?

Any chance you can also incorporate a test or two?

n8henrie avatar May 03 '22 02:05 n8henrie

@hraftery Are you interested in making a pull request? Otherwise I'll likely close this soonish.

n8henrie avatar Jul 15 '22 17:07 n8henrie

I am yes. Went travelling immediately after your message and haven’t returned to it, but intend to do so.

Sent from my iPad

On 16 Jul 2022, at 3:28 am, Nathan Henrie @.***> wrote:

 @hraftery Are you interested in making a pull request? Otherwise I'll likely close this soonish.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

hraftery avatar Jul 16 '22 05:07 hraftery

Sweet, thanks. Enjoy your travels!

n8henrie avatar Oct 11 '22 07:10 n8henrie