python script: add --fast

This commit is contained in:
Philippe Teuwen 2024-11-07 21:42:04 +01:00
commit 7be2a671c8

View file

@ -158,7 +158,7 @@ globals:
# 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
# Currently readBlocks is hardcoded for RF08S # Currently readBlocks is hardcoded for RF08S
data, blkn = readBlocks(bdkey) data, blkn = readBlocks(bdkey, args.fast)
data = patchKeys(data, key) data = patchKeys(data, key)
dump18 = diskDump(data, uid, dpath) # save it before you do anything else dump18 = diskDump(data, uid, dpath) # save it before you do anything else
@ -211,6 +211,7 @@ def parseCli():
parser.add_argument('-f', '--force', action='store_true', help='force recovery of keys') parser.add_argument('-f', '--force', action='store_true', help='force recovery of keys')
parser.add_argument('-b', '--bambu', action='store_true', help='force Bambu tag decode') parser.add_argument('-b', '--bambu', action='store_true', help='force Bambu tag decode')
parser.add_argument('-v', '--validate', action='store_true', help='check Fudan signature (requires internet)') parser.add_argument('-v', '--validate', action='store_true', help='check Fudan signature (requires internet)')
parser.add_argument('--fast', action='store_true', help='use ecfill for faster card transactions')
args = parser.parse_args() args = parser.parse_args()
@ -481,7 +482,7 @@ globals:
return rv return rv
def readBlocks(bdkey): def readBlocks(bdkey, fast=False):
""" """
Read all block data - INCLUDING advanced verification blocks Read all block data - INCLUDING advanced verification blocks
@ -497,25 +498,26 @@ globals:
lprint("\n Load blocks {0..63, 128..135}[64+8=72] from the card") lprint("\n Load blocks {0..63, 128..135}[64+8=72] from the card")
# Try fast dump first
blkn_todo = blkn blkn_todo = blkn
# The user uses keyhole #0 (-a) if fast:
# The vendor uses keyhole #1 (-b) # Try fast dump first
# The thief uses keyhole #4 (backdoor) # The user uses keyhole #0 (-a)
# |___ # The vendor uses keyhole #1 (-b)
cmd = f"hf mf ecfill -c 4 --key {bdkey}" # The thief uses keyhole #4 (backdoor)
lprint(f"`{cmd}`", flush=True, log=False) # |___
p.console(cmd) cmd = f"hf mf ecfill -c 4 --key {bdkey}"
for line in p.grabbed_output.split('\n'): lprint(f"`{cmd}`", flush=True, log=False)
if "ok" in line: p.console(cmd)
cmd = "hf mf eview" for line in p.grabbed_output.split('\n'):
lprint(f"`{cmd}`", flush=True, log=False) if "ok" in line:
p.console(cmd) cmd = "hf mf eview"
for line in p.grabbed_output.split('\n'): lprint(f"`{cmd}`", flush=True, log=False)
if " | " in line and "sec | blk | data" not in line: p.console(cmd)
lsub = line[11:83] for line in p.grabbed_output.split('\n'):
data.append(lsub) if " | " in line and "sec | blk | data" not in line:
blkn_todo = list(range(128, 135+1)) lsub = line[11:83]
data.append(lsub)
blkn_todo = list(range(128, 135+1))
bad = 0 bad = 0
for n in blkn_todo: for n in blkn_todo: