Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of cookies in Chromium cookie database versions >=24. #73

Merged
merged 7 commits into from
Oct 31, 2024

Conversation

chrisgavin
Copy link
Contributor

@chrisgavin chrisgavin commented Oct 23, 2024

NB: Please make an issue prior to embarking on any significant effort towards
a pull request. This will serve as a unified place for discussion and hopefully
make sure that the change seems reasonable to merge once its implementation is
complete.

Description

This attempts to fix the problem described in #72, which I believe I've identified as being caused by the Chromium cookie database format changing to include a SHA256 hash of the domain for the cookie as part of the encrypted value.

To handle this case, I've extracted the database version of the cookie database. If it is greater than 24, I remove the first 32 bytes of the encrypted value before it is passed to clean.

I've also added a fix for not being able to read the value from the database at all, by treating all database strings as byte strings and then decoding them to UTF-8 only after decryption has happened.

Status

READY

Related Issues

Fixes #72.

Todos

  • Tests
  • Documentation

Steps to Test or Reproduce

E.g.:

git checkout -b <feature_branch> master
git pull https://github.com/<user>/pycookiecheat.git <feature_branch>
pytest tests/

Other notes

src/pycookiecheat/chrome.py Outdated Show resolved Hide resolved
src/pycookiecheat/chrome.py Outdated Show resolved Hide resolved
@chrisgavin
Copy link
Contributor Author

Thanks so much for the comments! I've hopefully addressed them and also added a fix for the SQLite encoding issue.

@NerdyShawn
Copy link

just to add to this I tried out the changed locally here and fixed my issue, thanks!

@joker-at-work
Copy link

Works like a charm. Thank you.

@max-horvath
Copy link

This PR fixes the issue on my local machine. Thanks!

@n8henrie n8henrie merged commit 94d787d into n8henrie:dev Oct 31, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlite3.OperationalError into UnicodeDecodeError | Chrome Update
5 participants