Skip to content
Snippets Groups Projects
Commit 1763e2d0 authored by Javali's avatar Javali Committed by Jason A. Donenfeld
Browse files

revelation2pass: add plain XML import

I found that revelatio2pass.py script doesn't work. It can not decrypt
my password file. I got following error message:

raceback (most recent call last):
 File "git/password-store/contrib/importers/revelation2pass.py", line 159, in <module>
   main(args.FILE, verbose=args.verbose, xml=args.xml)
 File "git/password-store/contrib/importers/revelation2pass.py", line 140, in main
   cleardata_gz = decrypt_gz(password, data)
 File "git/password-store/contrib/importers/revelation2pass.py", line 117, in decrypt_gz
   ct = c.decrypt(cipher_text[28:])
 File "/usr/lib/python2.7/site-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt
   return self._cipher.decrypt(ciphertext)

I was unable to fix the problem, but I created a workaround, that add
plain XML import option to the revelation2pass.py script. Revelation can
export its password file as plain XML format.
parent 3f6b8a20
No related branches found
No related tags found
No related merge requests found
...@@ -122,25 +122,29 @@ def decrypt_gz(key, cipher_text): ...@@ -122,25 +122,29 @@ def decrypt_gz(key, cipher_text):
ct = c.decrypt(cipher_text[28:], iv=iv) ct = c.decrypt(cipher_text[28:], iv=iv)
return ct return ct
def main(datafile, verbose=False): def main(datafile, verbose=False, xml=False):
f = None f = None
with open(datafile, "rb") as f: with open(datafile, "rb") as f:
# Encrypted data # Encrypted data
data = f.read() data = f.read()
password = getpass.getpass() if xml:
# Pad password xmldata = data
password += (chr(0) * (32 - len(password))) else:
# Decrypt. Decrypted data is compressed password = getpass.getpass()
cleardata_gz = decrypt_gz(password, data) # Pad password
# Length of data padding password += (chr(0) * (32 - len(password)))
padlen = ord(cleardata_gz[-1]) # Decrypt. Decrypted data is compressed
# Decompress actual data (15 is wbits [ref3] DON'T CHANGE, 2**15 is the (initial) buf size) cleardata_gz = decrypt_gz(password, data)
xmldata = zlib.decompress(cleardata_gz[:-padlen], 15, 2**15) # 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) root = etree.fromstring(xmldata)
import_subentries(root, verbose=verbose) import_subentries(root, verbose=verbose)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() 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('--verbose', '-v', action='count')
parser.add_argument('FILE', help="the file storing the Revelation passwords") parser.add_argument('FILE', help="the file storing the Revelation passwords")
args = parser.parse_args() args = parser.parse_args()
...@@ -149,7 +153,7 @@ if __name__ == '__main__': ...@@ -149,7 +153,7 @@ if __name__ == '__main__':
sys.stderr.write(s+'\n') sys.stderr.write(s+'\n')
try: try:
main(args.FILE, verbose=args.verbose) main(args.FILE, verbose=args.verbose, xml=args.xml)
except KeyboardInterrupt: except KeyboardInterrupt:
if args.verbose: if args.verbose:
traceback.print_exc() traceback.print_exc()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment