mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
refactored client/pm3_*.py to use with statements, contants and iterators
This commit is contained in:
parent
0aceafbf2e
commit
70049c47db
2 changed files with 11 additions and 24 deletions
|
@ -6,6 +6,7 @@
|
||||||
# Converts PM3 Mifare Classic emulator EML text file to MFD binary dump file
|
# Converts PM3 Mifare Classic emulator EML text file to MFD binary dump file
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
from __future__ import with_statement
|
||||||
import sys
|
import sys
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
|
@ -15,21 +16,12 @@ def main(argv):
|
||||||
print 'Usage:', argv[0], 'input.eml output.mfd'
|
print 'Usage:', argv[0], 'input.eml output.mfd'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
with file(argv[1], "r") as file_inp, file(argv[2], "wb") as file_out:
|
||||||
file_inp = open(argv[1], "r")
|
for line in file_inp:
|
||||||
file_out = open(argv[2], "wb")
|
line = line.rstrip('\n').rstrip('\r')
|
||||||
line = file_inp.readline()
|
|
||||||
while line:
|
|
||||||
line = line.rstrip('\n')
|
|
||||||
line = line.rstrip('\r')
|
|
||||||
print line
|
print line
|
||||||
data = binascii.unhexlify(line)
|
data = binascii.unhexlify(line)
|
||||||
file_out.write(data)
|
file_out.write(data)
|
||||||
line = file_inp.readline()
|
|
||||||
|
|
||||||
finally:
|
|
||||||
file_inp.close()
|
|
||||||
file_out.close()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|
|
@ -6,31 +6,26 @@
|
||||||
# Converts PM3 Mifare Classic MFD binary dump file to emulator EML text file
|
# Converts PM3 Mifare Classic MFD binary dump file to emulator EML text file
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
from __future__ import with_statement
|
||||||
import sys
|
import sys
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
|
READ_BLOCKSIZE = 16
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
argc = len(argv)
|
argc = len(argv)
|
||||||
if argc < 3:
|
if argc < 3:
|
||||||
print 'Usage:', argv[0], 'input.mfd output.eml'
|
print 'Usage:', argv[0], 'input.mfd output.eml'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
with file(argv[1], "rb") as file_inp, file(argv[2], "w") as file_out:
|
||||||
file_inp = open(argv[1], "rb")
|
while True:
|
||||||
file_out = open(argv[2], "w")
|
byte_s = file_inp.read(READ_BLOCKSIZE)
|
||||||
|
|
||||||
while 1:
|
|
||||||
# TODO: need to use defines instead of hardcoded 16, 64, etc.
|
|
||||||
byte_s = file_inp.read(16)
|
|
||||||
if not byte_s:
|
if not byte_s:
|
||||||
break
|
break
|
||||||
hex_char_repr = binascii.hexlify(byte_s)
|
hex_char_repr = binascii.hexlify(byte_s)
|
||||||
file_out.write(hex_char_repr)
|
file_out.write(hex_char_repr)
|
||||||
file_out.write("\n")
|
file_out.write("\n")
|
||||||
|
|
||||||
finally:
|
|
||||||
file_inp.close()
|
|
||||||
file_out.close()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue