Skip to content

Instantly share code, notes, and snippets.

@simonkuang
Last active April 2, 2020 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonkuang/6e0c8bfdafb43e20f44df9feca38eed0 to your computer and use it in GitHub Desktop.
Save simonkuang/6e0c8bfdafb43e20f44df9feca38eed0 to your computer and use it in GitHub Desktop.
从 chrome 本地文件中解密获取 chrome 中保存的 cookie(支持到 Chrome80)
# -*- coding: utf-8 -*-
"""
pip install cryptography
"""
import os
import sys
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import (Cipher, algorithms, modes)
NONCE_BYTE_SIZE = 12
def encrypt(cipher, plaintext, nonce):
cipher.mode = modes.GCM(nonce)
encryptor = cipher.encryptor()
ciphertext = encryptor.update(plaintext)
return (cipher, ciphertext, nonce)
def decrypt(cipher, ciphertext, nonce):
cipher.mode = modes.GCM(nonce)
decryptor = cipher.decryptor()
return decryptor.update(ciphertext)
def get_cipher(key):
cipher = Cipher(
algorithms.AES(key),
None,
backend = default_backend()
)
return cipher
# -*- coding: utf-8 -*-
from chrome_cookie import ChromeCookieJar
from pprint import pprint as pp
import sys
if __name__=='__main__':
jar = ChromeCookieJar()
jar.load()
for cookie in jar:
pp(type(cookie))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment