Created
May 16, 2017 20:51
-
-
Save dov/877ac1052c8f6080e4053eef18b497ca to your computer and use it in GitHub Desktop.
Decrypting Epsilon Note encoded notes with python (given the password)
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
#!/usr/bin/python | |
###################################################################### | |
# Decrypt an Epsilon Note encoded file given the password. | |
# | |
# This file is in the public domain. | |
# | |
# Dov Grobgeld <[email protected]> | |
# 2017-02-17 Fri | |
###################################################################### | |
import sys,StringIO,base64,hashlib | |
from Crypto.Cipher import AES | |
def unpad(s): | |
return s[0:-ord(s[-1])] | |
def filetob64(handle): | |
b64 = '' | |
within = False | |
for line in handle: | |
if '~~~~~~~~~~' in line: | |
within = not within | |
continue | |
if within: | |
b64 += line[:-1] | |
return b64 | |
def en_decrypt(handle, password): | |
raw = base64.b64decode(filetob64(handle)) | |
enc_text,iv = raw[:-16],raw[-16:] | |
key = hashlib.sha256(password).digest()[:16] | |
aes = AES.new(key, AES.MODE_CBC, iv) | |
return unpad(aes.decrypt(enc_text)) | |
if len(sys.argv) > 1: | |
handle = open(sys.argv[1]) | |
password = sys.argv[2] | |
else: | |
# test below | |
encrypted_text = ''' | |
~~~~~~~~~~encrypted | |
D2gQe2He6bgKqYe4ijqoD96KORqBNbtgcAyaMYq+gROr3Qp3KG87Ti0JMdXdBh0vk4yVXlAraRGQLZnQuiCuzht03O4QBN//p4NziDyDuvM= | |
~~~~~~~~~~ | |
''' | |
password = 'password' | |
handle = StringIO.StringIO(encrypted_text) | |
print en_decrypt(handle, password), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I have updated this script for python3 and aes256 (seems in 2017 epsilon used only 128bit).
https://gist.github.com/zettelding/eba76cdf702ec12cb0fb7307d149a5d9
I have also created bash-oneliner to do the same https://gist.github.com/zettelding/4f4eea0941ef94a83c0b75caab75a722
enjoy!