]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | import sys | |
10 | import binascii | |
11 | ||
12 | def main(argv): | |
13 | argc = len(argv) | |
14 | if argc < 3: | |
15 | print 'Usage:', argv[0], 'input.mfd output.eml' | |
16 | sys.exit(1) | |
17 | ||
18 | try: | |
19 | file_inp = open(argv[1], "rb") | |
20 | file_out = open(argv[2], "w") | |
21 | ||
22 | while 1: | |
23 | # TODO: need to use defines instead of hardcoded 16, 64, etc. | |
24 | byte_s = file_inp.read(16) | |
25 | if not byte_s: | |
26 | break | |
27 | hex_char_repr = binascii.hexlify(byte_s) | |
28 | file_out.write(hex_char_repr) | |
29 | file_out.write("\n") | |
30 | ||
31 | finally: | |
32 | file_inp.close() | |
33 | file_out.close() | |
34 | ||
35 | if __name__ == '__main__': | |
36 | main(sys.argv) |