Skip to content

Commit

Permalink
pgpwde2john.py: Restore Python 2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
solardiz committed Mar 19, 2024
1 parent 9dab32a commit bcf8f7a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions run/pgpwde2john.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import struct
from binascii import hexlify

PY3 = sys.version_info[0] == 3

"""
Random notes on PGP WDE.
Expand Down Expand Up @@ -235,9 +236,15 @@ def process_file(filename):
userflags, serialNumber, userLocalId, reserved = fields[7:11]
size, symmAlg, totalESKsize, reserved, userName, s2ktype, hashIterations, reserved2, salt, esk = fields[11:]
userName = userName.strip(b"\x00").decode()
esk_cut = esk.hex()[0:256]
sys.stderr.write("DEBUG: %s, %s, %s, %s, %s, %s, %s\n" % (size, symmAlg, totalESKsize, userName, s2ktype, hashIterations, esk.hex()))
print("%s:$pgpwde$0*%s*%s*%s*%s*%s" % (userName, symmAlg, s2ktype, hashIterations, salt.hex(), esk_cut))
if PY3:
esk_hex = esk.hex()
salt_hex = salt.hex()
else:
esk_hex = esk.encode("hex")
salt_hex = salt.encode("hex")
esk_cut = esk_hex[0:256]
sys.stderr.write("DEBUG: %s, %s, %s, %s, %s, %s, %s\n" % (size, symmAlg, totalESKsize, userName, s2ktype, hashIterations, esk_hex))
print("%s:$pgpwde$0*%s*%s*%s*%s*%s" % (userName, symmAlg, s2ktype, hashIterations, salt_hex, esk_cut))

f.close()

Expand Down

0 comments on commit bcf8f7a

Please sign in to comment.