Created
April 16, 2013 01:24
-
-
Save nickhs/5392647 to your computer and use it in GitHub Desktop.
Decrypt cookie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cookie is named session in the client browser, is set to persist across subdomains (so foobar.com and app.foobar.com will | |
# still be valid). | |
#!/usr/bin/env python | |
import base64 | |
cookie = 'eyJjb21wYW55IjoiZm9vYmFyIiwidXNlcl9pZCI6NSwiZW1haWwiOiJuaWNrQG5pY2tocy5jb20ifQ.BE43Cw.7CUdWGN2mjcKsRdOOtrIamCv09s' | |
info, timestamp, signature = cookie.split('.') | |
padding = -len(info) % 4 * '=' | |
info = info + padding | |
print base64.urlsafe_b64decode(info) | |
# result: '{"company":"foobar","user_id":5,"email":"nick@nickhs.com"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment