Skip to content
Browse files

Make agilekc2john more robust against bad data

  • Loading branch information...
1 parent 3ba8d2a commit 4e8362af12e9cd83b7496dc3e63277a9242ef1dd @kholia kholia committed Dec 30, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 run/agilekc2john.py
View
16 run/agilekc2john.py
@@ -100,15 +100,13 @@ def __init__(self, path, name='default'):
self.path = path
self.name = name
self.entries = None
- self.__open_keys_file()
+ ret = self.__open_keys_file()
+ if ret:
+ self.john_output()
def __repr__(self):
return '<%s.AgileKeychain path="%s">' % (self.__module__, self.path)
- def open(self, password):
- self.__decrypt_keys(password)
- del password
-
def __open_keys_file(self):
"""Open the json file containing the keys for decrypting the
real keychain and parse it
@@ -132,8 +130,11 @@ def __open_keys_file(self):
self.keys.append(key)
finally:
keys_file.close()
- except (IOError, KeyError):
- print >> sys.stderr, 'error while opening the keychain'
+ except (IOError, KeyError, ValueError, TypeError) as e:
+ print >> sys.stderr, 'error while opening the keychain,', str(e)
+ return False
+
+ return True
def john_output(self):
sys.stdout.write("%s:$agilekeychain$%s" % (self.path, len(self.keys)))
@@ -147,7 +148,6 @@ def john_output(self):
def process_file(keychain):
keychain = AgileKeychain(keychain)
- keychain.john_output()
if __name__ == "__main__":
if len(sys.argv) < 2:

0 comments on commit 4e8362a

Please sign in to comment.
Something went wrong with that request. Please try again.