Skip to content

Commit

Permalink
Make encfs2john more robust against bad data
Browse files Browse the repository at this point in the history
  • Loading branch information
kholia committed Dec 30, 2012
1 parent 4e8362a commit dd493df
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions run/encfs2john.py
Expand Up @@ -22,11 +22,23 @@ def process_folder(folder):
r = tree.getroot()
elements = list(r.iter())
cipher = None
keySize = None
iterations = None
salt = None
saltLen = None
dataLen = None
data = None
for element in elements:
if element.tag == "keySize":
keySize = element.text
if not keySize.isdigit():
print >> sys.stderr, "%s contains bad keySize" % filename
return
if element.tag == "kdfIterations":
iterations = element.text
if not iterations.isdigit():
print >> sys.stderr, "%s contains bad iterations" % filename
return
if element.tag == "name" and not cipher:
cipher = element.text
if element.tag == "saltData":
Expand All @@ -38,6 +50,10 @@ def process_folder(folder):
if element.tag == "encodedKeyData":
data = element.text

if not cipher or not keySize or not iterations or not salt or not saltLen or not dataLen or not data:
print >> sys.stderr, "%s contains bad data, please report this if target contains valid EncFS data" % filename
return

if cipher.upper().find("AES") > -1:
cipher = 0
print "%s:$encfs$%s*%s*%s*%s*%s*%s*%s" % (folder, keySize, iterations, cipher,
Expand Down

0 comments on commit dd493df

Please sign in to comment.