Skip to content

Instantly share code, notes, and snippets.

@dov
Created May 16, 2017 20:51
Show Gist options
  • Save dov/877ac1052c8f6080e4053eef18b497ca to your computer and use it in GitHub Desktop.
Save dov/877ac1052c8f6080e4053eef18b497ca to your computer and use it in GitHub Desktop.
Decrypting Epsilon Note encoded notes with python (given the password)
#!/usr/bin/python
######################################################################
# Decrypt an Epsilon Note encoded file given the password.
#
# This file is in the public domain.
#
# Dov Grobgeld <dov.grobgeld@gmail.com>
# 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),
@zettelmuseum
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment