convert python2 mfd2eml and eml2mfd scripts to python3

This commit is contained in:
Joe Harrison 2020-02-21 15:09:36 +00:00
commit f28404581d
3 changed files with 17 additions and 18 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
'''
# Andrei Costin <zveriu@gmail.com>, 2011
@ -6,24 +6,23 @@
# Converts PM3 Mifare Classic MFD binary dump file to emulator EML text file
'''
from __future__ import with_statement
import sys
import binascii
READ_BLOCKSIZE = 16
def main(argv):
argc = len(argv)
if argc < 3:
print 'Usage:', argv[0], 'input.mfd output.eml'
print('Usage:', argv[0], 'input.mfd output.eml')
sys.exit(1)
with file(argv[1], "rb") as file_inp, file(argv[2], "w") as file_out:
with open(argv[1], "rb") as file_inp, open(argv[2], "w") as file_out:
while True:
byte_s = file_inp.read(READ_BLOCKSIZE)
if not byte_s:
break
hex_char_repr = binascii.hexlify(byte_s)
hex_char_repr = byte_s.hex()
file_out.write(hex_char_repr)
file_out.write("\n")