1f947c4b |
1 | #!/usr/bin/python |
2 | |
3 | ''' |
4 | # Andrei Costin <zveriu@gmail.com>, 2011 |
5 | # pm3_eml2mfd.py |
6 | # Converts PM3 Mifare Classic MFD binary dump file to emulator EML text file |
7 | ''' |
8 | |
70049c47 |
9 | from __future__ import with_statement |
1f947c4b |
10 | import sys |
11 | import binascii |
12 | |
70049c47 |
13 | READ_BLOCKSIZE = 16 |
14 | |
1f947c4b |
15 | def main(argv): |
16 | argc = len(argv) |
17 | if argc < 3: |
18 | print 'Usage:', argv[0], 'input.mfd output.eml' |
19 | sys.exit(1) |
20 | |
70049c47 |
21 | with file(argv[1], "rb") as file_inp, file(argv[2], "w") as file_out: |
22 | while True: |
23 | byte_s = file_inp.read(READ_BLOCKSIZE) |
1f947c4b |
24 | if not byte_s: |
25 | break |
26 | hex_char_repr = binascii.hexlify(byte_s) |
27 | file_out.write(hex_char_repr) |
28 | file_out.write("\n") |
1f947c4b |
29 | |
11d23264 |
30 | if __name__ == '__main__': |
31 | main(sys.argv) |