Guest User

Decrypting Chrome cookies on Linux/MAC

a guest
Aug 21st, 2016
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #! /usr/bin/env python3
  2.  
  3. from Crypto.Cipher import AES
  4. from Crypto.Protocol.KDF import PBKDF2
  5.  
  6. # Function to get rid of padding
  7. def clean(x):
  8.     return x[:-x[-1]].decode('utf8')
  9.  
  10. # replace with your encrypted_value from sqlite3
  11. encrypted_value = ENCRYPTED_VALUE
  12.  
  13. # Trim off the 'v10' that Chrome/ium prepends
  14. encrypted_value = encrypted_value[3:]
  15.  
  16. # Default values used by both Chrome and Chromium in OSX and Linux
  17. salt = b'saltysalt'
  18. iv = b' ' * 16
  19. length = 16
  20.  
  21. # On Mac, replace MY_PASS with your password from Keychain
  22. # On Linux, replace MY_PASS with 'peanuts'
  23. my_pass = MY_PASS
  24. my_pass = my_pass.encode('utf8')
  25.  
  26. # 1003 on Mac, 1 on Linux
  27. iterations = 1003
  28.  
  29. key = PBKDF2(my_pass, salt, length, iterations)
  30. cipher = AES.new(key, AES.MODE_CBC, IV=iv)
  31.  
  32. decrypted = cipher.decrypt(encrypted_value)
  33. print(clean(decrypted))
Advertisement
Add Comment
Please, Sign In to add comment