1 #! /usr/bin/env python2
8 chromium_cookie_decrypt.py - Decrypt Chromium web browser stored cookies and output cleartext
14 from Crypto
.Cipher
import AES
15 from Crypto
.Protocol
.KDF
import PBKDF2
20 # Function to get rid of padding
22 #return x[:-x[-1]].decode('utf8')
23 return x
[:-ord(x
[-1])]
26 record
= sys
.stdin
.readline()
30 field_number_to_decrypt
= int(sys
.argv
[1])
31 fields
= record
.split()
33 encrypted_value
= binascii
.unhexlify(fields
[field_number_to_decrypt
])
35 # Trim off the 'v10' that Chrome/ium prepends
36 encrypted_value
= encrypted_value
[3:]
38 # Default values used by both Chrome and Chromium in OSX and Linux
43 # On Mac, replace MY_PASS with your password from Keychain
44 # On Linux, replace MY_PASS with 'peanuts'
45 my_pass
= os
.environ
['CHROMIUM_DECRYPT_PASS']
46 my_pass
= my_pass
.encode('utf8')
48 # 1003 on Mac, 1 on Linux
52 key
= PBKDF2(my_pass
, salt
, length
, iterations
)
53 cipher
= AES
.new(key
, AES
.MODE_CBC
, IV
=iv
)
55 decrypted
= clean_padding(cipher
.decrypt(encrypted_value
))
56 fields
[field_number_to_decrypt
] = decrypted
59 print '\t'.join(fields
)