summaryrefslogtreecommitdiff
path: root/contrib/importers/revelation2pass.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xcontrib/importers/revelation2pass.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/contrib/importers/revelation2pass.py b/contrib/importers/revelation2pass.py
index f04c1a8..cc2d01c 100755
--- a/contrib/importers/revelation2pass.py
+++ b/contrib/importers/revelation2pass.py
@@ -122,25 +122,29 @@ def decrypt_gz(key, cipher_text):
ct = c.decrypt(cipher_text[28:], iv=iv)
return ct
-def main(datafile, verbose=False):
+def main(datafile, verbose=False, xml=False):
f = None
with open(datafile, "rb") as f:
# Encrypted data
data = f.read()
- password = getpass.getpass()
- # Pad password
- password += (chr(0) * (32 - len(password)))
- # Decrypt. Decrypted data is compressed
- cleardata_gz = decrypt_gz(password, data)
- # Length of data padding
- padlen = ord(cleardata_gz[-1])
- # Decompress actual data (15 is wbits [ref3] DON'T CHANGE, 2**15 is the (initial) buf size)
- xmldata = zlib.decompress(cleardata_gz[:-padlen], 15, 2**15)
+ if xml:
+ xmldata = data
+ else:
+ password = getpass.getpass()
+ # Pad password
+ password += (chr(0) * (32 - len(password)))
+ # Decrypt. Decrypted data is compressed
+ cleardata_gz = decrypt_gz(password, data)
+ # Length of data padding
+ padlen = ord(cleardata_gz[-1])
+ # Decompress actual data (15 is wbits [ref3] DON'T CHANGE, 2**15 is the (initial) buf size)
+ xmldata = zlib.decompress(cleardata_gz[:-padlen], 15, 2**15)
root = etree.fromstring(xmldata)
import_subentries(root, verbose=verbose)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
+ parser.add_argument('-x', '--xml', help='read plain XML file', action='store_true')
parser.add_argument('--verbose', '-v', action='count')
parser.add_argument('FILE', help="the file storing the Revelation passwords")
args = parser.parse_args()
@@ -149,7 +153,7 @@ if __name__ == '__main__':
sys.stderr.write(s+'\n')
try:
- main(args.FILE, verbose=args.verbose)
+ main(args.FILE, verbose=args.verbose, xml=args.xml)
except KeyboardInterrupt:
if args.verbose:
traceback.print_exc()
sertions'>+1 2014-03-22Makefile: do not use recursion and organizeJason A. Donenfeld12-9/+7 2014-03-22clip: suppress kill errorJason A. Donenfeld2-3/+3 2014-03-22clip: do not race on osxJason A. Donenfeld1-5/+5 2014-03-22clip: use pkill instead of procJason A. Donenfeld1-1/+1 2014-03-20Keepass import should include root-level entriesErik Mackdanz1-0/+1 Repro steps: 1. In KeePass, add some entries as children of the root node 2. Export the KeePass to foo.xml 3. 'keepass2pass.py -f foo.xml' Expect: all entries imported Actual: root-level entries are skipped 2014-03-20keepassx2pass: friendly title fieldPhilip Chase1-1/+24 This patch removes several special characters while attempting to preserve as much meaning in the filename as possible. These changes are made to the KeepassX title before it is used as a file password store filename: - Spaces between words in file names are replaced with camelCasing. - The characters \ | ( ) are each replaced with a hyphen. - Trailing hypens are removed. - @ is replaced with "At" - ' is removed