This commit is contained in:
iceman1001 2024-11-07 21:52:07 +01:00
commit e65a15337e

View file

@ -139,7 +139,7 @@ globals:
if args.force or (key := loadKeys(keyfile)) is None: if args.force or (key := loadKeys(keyfile)) is None:
if args.recover is False: if args.recover is False:
s = color("--recover", fg="yellow") s = color("--recover", fg="yellow")
lprint(f"Keys not loaded, use {s} to run recovery script [slow]") lprint(f" Keys not loaded, use {s} to run recovery script [slow]", prompt='[!]')
else: else:
# FIXME: recovery() is only for RF08S. TODO for the other ones with a "darknested" attack # FIXME: recovery() is only for RF08S. TODO for the other ones with a "darknested" attack
keyfile = recoverKeys() keyfile = recoverKeys()
@ -150,7 +150,7 @@ globals:
if ret is False: if ret is False:
if args.nokeys is False: if args.nokeys is False:
s = color("--nokeys", fg="yellow") s = color("--nokeys", fg="yellow")
lprint(f"Use {s} to keep going past this point") lprint(f" Use {s} to keep going past this point", prompt='[!]')
return return
# FIXME: nr of blocks depend on the tag. RF32 is 256, RF08 is 64, RF08S is 64+8 # FIXME: nr of blocks depend on the tag. RF32 is 256, RF08 is 64, RF08S is 64+8
@ -246,7 +246,7 @@ globals:
lprint(f" - fail [{res}]", prompt='') lprint(f" - fail [{res}]", prompt='')
if bdkey == "": if bdkey == "":
lprint("\n! Unknown key, or card not detected.") lprint("\n Unknown key, or card not detected.", prompt='[!]')
return None, None return None, None
return bdkey, blk0 return bdkey, blk0
@ -362,7 +362,8 @@ def fudanValidate(blk0, live=False):
desc = "" desc = ""
lprint(f"The man from Fudan, he say: {r['code']} - {r['message']}{desc}") lprint(f"The man from Fudan, he say: {r['code']} - {r['message']}{desc}")
else: else:
lprint("\n ...Use --validate to perform Fudan signature check automatically") s = color('--validate', fg="yellow")
lprint(f'\n Use {s} to perform Fudan signature check automatically', prompt='[?]')
def loadKeys(keyfile): def loadKeys(keyfile):
@ -538,7 +539,8 @@ globals:
data.append(f"{n:3d} | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ----------------") data.append(f"{n:3d} | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ----------------")
bad += 1 bad += 1
lprint(" .. OK", log=False) s = color("ok", fg="green")
lprint(f'Loading ( {s} )', log=False)
return data, blkn return data, blkn
@ -546,7 +548,7 @@ def patchKeys(data, key):
"""Patch keys in to data """Patch keys in to data
3 | 00 00 00 00 00 00 87 87 87 69 00 00 00 00 00 00 | .........i...... 3 | 00 00 00 00 00 00 87 87 87 69 00 00 00 00 00 00 | .........i......
""" """
lprint("\nPatch keys in to data") lprint("\nPatching keys in to data")
for sec in range(0, 16 + 1): for sec in range(0, 16 + 1):
blk = (sec * 4) + 3 # find "trailer" for this sector blk = (sec * 4) + 3 # find "trailer" for this sector
@ -920,19 +922,24 @@ def dumpAcl(data):
def diskDump(data, uid, dpath): def diskDump(data, uid, dpath):
"""Full Dump""" """Full Dump"""
dump18 = color(f"{dpath}hf-mf-{uid.hex().upper()}-dump18.bin", fg="yellow") dump18 = color(f'{dpath}hf-mf-{uid.hex().upper()}-dump18.bin', fg='yellow')
lprint(f"\nDump Card Data to file... {dump18}") lprint(f'\nDump card data to file... {dump18}')
bad = False bad = False
try:
with open(dump18, 'wb') as f: with open(dump18, 'wb') as f:
for d in data: for d in data:
if "--" in d[6:53]: if '--' in d[6:53]:
bad = True bad = True
b = bytes.fromhex(d[6:53].replace(" ", "").replace("--", "FF")) b = bytes.fromhex(d[6:53].replace(' ', '').replace('--', 'FF'))
f.write(b) f.write(b)
if bad: if bad:
lprint("Bad data exists, and has been saved as 0xFF") lprint('Bad data exists, and has been saved as 0xFF')
except:
s = color('fail', fg='red')
lprint(f'File operations ( {s} )', prompt='[!]')
return dump18 return dump18