mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
refactor console flushing; make indentation consistent; change the word 'hash' for 'sig'nature
This commit is contained in:
parent
3e1c21ac83
commit
55f8e6ed4b
1 changed files with 18 additions and 23 deletions
|
@ -53,7 +53,7 @@ except ModuleNotFoundError:
|
||||||
# >> "logfile"
|
# >> "logfile"
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def startlog(uid, append = False):
|
def startlog(uid, append = False):
|
||||||
global logfile
|
global logfile
|
||||||
|
|
||||||
logfile = f"{dpath}hf-mf-{uid:08X}-log.txt"
|
logfile = f"{dpath}hf-mf-{uid:08X}-log.txt"
|
||||||
if append == False:
|
if append == False:
|
||||||
|
@ -74,8 +74,8 @@ def lprint(s, end='\n', flush=False):
|
||||||
# >> "keyfile"
|
# >> "keyfile"
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def main():
|
def main():
|
||||||
global prompt
|
global prompt
|
||||||
global p
|
global p
|
||||||
|
|
||||||
prompt = "[bc]"
|
prompt = "[bc]"
|
||||||
p = pm3.pm3() # console interface
|
p = pm3.pm3() # console interface
|
||||||
|
@ -94,8 +94,10 @@ def main():
|
||||||
getDarkKey()
|
getDarkKey()
|
||||||
decodeBlock0()
|
decodeBlock0()
|
||||||
|
|
||||||
global keyfile
|
global keyfile
|
||||||
|
global mad
|
||||||
|
|
||||||
|
mad = False
|
||||||
keyfile = f"{dpath}hf-mf-{uid:08X}-key.bin"
|
keyfile = f"{dpath}hf-mf-{uid:08X}-key.bin"
|
||||||
keyok = False
|
keyok = False
|
||||||
|
|
||||||
|
@ -137,7 +139,7 @@ def main():
|
||||||
# >> "dpath"
|
# >> "dpath"
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def getPrefs():
|
def getPrefs():
|
||||||
global dpath
|
global dpath
|
||||||
|
|
||||||
p.console("prefs show --json")
|
p.console("prefs show --json")
|
||||||
prefs = json.loads(p.grabbed_output)
|
prefs = json.loads(p.grabbed_output)
|
||||||
|
@ -158,7 +160,7 @@ def checkVer():
|
||||||
# >> args.
|
# >> args.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def parseCli():
|
def parseCli():
|
||||||
global args
|
global args
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Full recovery of Fudan FM11RF08* cards.')
|
parser = argparse.ArgumentParser(description='Full recovery of Fudan FM11RF08* cards.')
|
||||||
|
|
||||||
|
@ -183,8 +185,8 @@ def parseCli():
|
||||||
'''
|
'''
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def getDarkKey():
|
def getDarkKey():
|
||||||
global dkey
|
global dkey
|
||||||
global blk0
|
global blk0
|
||||||
|
|
||||||
# FM11RF08S FM11RF08 FM11RF32
|
# FM11RF08S FM11RF08 FM11RF32
|
||||||
dklist = ["A396EFA4E24F", "A31667A8CEC1", "518b3354E760"]
|
dklist = ["A396EFA4E24F", "A31667A8CEC1", "518b3354E760"]
|
||||||
|
@ -196,13 +198,12 @@ def getDarkKey():
|
||||||
for k in dklist:
|
for k in dklist:
|
||||||
cmd = f"hf mf rdbl -c 4 --key {k} --blk 0"
|
cmd = f"hf mf rdbl -c 4 --key {k} --blk 0"
|
||||||
print(f"{prompt} `{cmd}`", end='', flush=True)
|
print(f"{prompt} `{cmd}`", end='', flush=True)
|
||||||
res = p.console(f"{cmd}")
|
res = p.console(f"{cmd}", capture=False)
|
||||||
if res == 0:
|
if res == 0:
|
||||||
print(" - success")
|
print(" - success")
|
||||||
dkey = k;
|
dkey = k;
|
||||||
break;
|
break;
|
||||||
print(f" - fail [{res}]")
|
print(f" - fail [{res}]")
|
||||||
_ = p.grabbed_output
|
|
||||||
|
|
||||||
if dkey == "":
|
if dkey == "":
|
||||||
print(f"{prompt}")
|
print(f"{prompt}")
|
||||||
|
@ -219,8 +220,8 @@ def getDarkKey():
|
||||||
# >> "uids"
|
# >> "uids"
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def decodeBlock0():
|
def decodeBlock0():
|
||||||
global uid
|
global uid
|
||||||
global uids
|
global uids
|
||||||
|
|
||||||
# We do this early so we can name the logfile!
|
# We do this early so we can name the logfile!
|
||||||
uids = blk0[0:11] # UID string : "11 22 33 44"
|
uids = blk0[0:11] # UID string : "11 22 33 44"
|
||||||
|
@ -230,7 +231,7 @@ def decodeBlock0():
|
||||||
lprint(prompt)
|
lprint(prompt)
|
||||||
lprint(f"{prompt} UID BCC ++----- RF08 ID -----++")
|
lprint(f"{prompt} UID BCC ++----- RF08 ID -----++")
|
||||||
lprint(f"{prompt} ! ! SAK !! !!")
|
lprint(f"{prompt} ! ! SAK !! !!")
|
||||||
lprint(f"{prompt} ! ! ! ATQA !! RF08 Hash !!")
|
lprint(f"{prompt} ! ! ! ATQA !! Fudan Sig !!")
|
||||||
lprint(f"{prompt} !---------. !. !. !---. VV .---------------. VV")
|
lprint(f"{prompt} !---------. !. !. !---. VV .---------------. VV")
|
||||||
# 0 12 15 18 24 27 45
|
# 0 12 15 18 24 27 45
|
||||||
# ! ! ! ! ! ! !
|
# ! ! ! ! ! ! !
|
||||||
|
@ -333,12 +334,10 @@ def fudanValidate():
|
||||||
# If keys cannot be loaded AND --recover is specified, then run key recovery
|
# If keys cannot be loaded AND --recover is specified, then run key recovery
|
||||||
# >> "keyfile"
|
# >> "keyfile"
|
||||||
# >> "key[17][2]"
|
# >> "key[17][2]"
|
||||||
# >> mad!
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def loadKeys():
|
def loadKeys():
|
||||||
global keyfile
|
global keyfile
|
||||||
global key
|
global key
|
||||||
global mad
|
|
||||||
|
|
||||||
key = [[0 for _ in range(2)] for _ in range(17)] # create a fresh array
|
key = [[0 for _ in range(2)] for _ in range(17)] # create a fresh array
|
||||||
|
|
||||||
|
@ -361,7 +360,7 @@ def loadKeys():
|
||||||
# >> "keyfile"
|
# >> "keyfile"
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def recoverKeys():
|
def recoverKeys():
|
||||||
global keyfile
|
global keyfile
|
||||||
|
|
||||||
badrk = 0 # 'bad recovered key' count (ie. not recovered)
|
badrk = 0 # 'bad recovered key' count (ie. not recovered)
|
||||||
|
|
||||||
|
@ -402,7 +401,6 @@ def verifyKeys():
|
||||||
global mad
|
global mad
|
||||||
|
|
||||||
badk = 0
|
badk = 0
|
||||||
mad = False
|
|
||||||
|
|
||||||
lprint(f"{prompt} Check keys..")
|
lprint(f"{prompt} Check keys..")
|
||||||
|
|
||||||
|
@ -417,7 +415,7 @@ def verifyKeys():
|
||||||
cmd = f"hf mf rdbl -c {ab} --key {key[sec][ab].hex()} --blk {bn}"
|
cmd = f"hf mf rdbl -c {ab} --key {key[sec][ab].hex()} --blk {bn}"
|
||||||
lprint(f"{prompt} `{cmd}`", end='', flush=True)
|
lprint(f"{prompt} `{cmd}`", end='', flush=True)
|
||||||
|
|
||||||
res = p.console(f"{cmd}")
|
res = p.console(f"{cmd}", capture=False)
|
||||||
lprint(" " * (3-len(str(bn))), end="")
|
lprint(" " * (3-len(str(bn))), end="")
|
||||||
if res == 0:
|
if res == 0:
|
||||||
lprint(" ... PASS", end="")
|
lprint(" ... PASS", end="")
|
||||||
|
@ -434,9 +432,6 @@ def verifyKeys():
|
||||||
else:
|
else:
|
||||||
lprint("")
|
lprint("")
|
||||||
|
|
||||||
# We need to flush all the output we just collected <shrug>
|
|
||||||
_ = p.grabbed_output
|
|
||||||
|
|
||||||
if badk > 0:
|
if badk > 0:
|
||||||
lprint(f"{prompt} ! {badk} bad key", end='')
|
lprint(f"{prompt} ! {badk} bad key", end='')
|
||||||
lprint("s exist" if badk != 1 else " exists")
|
lprint("s exist" if badk != 1 else " exists")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue