Skip to content

Commit

Permalink
Adding an output option inside the dump feature for MIFARE Ultralight
Browse files Browse the repository at this point in the history
  • Loading branch information
FlUxIuS committed Sep 14, 2023
1 parent d894953 commit 302beca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions software/script/chameleon_cli_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ def args_parser(self) -> ArgumentParserNoExit or None:
parser = ArgumentParserNoExit()
parser.add_argument('-m', '--maxpages', type=int, required=False, metavar="decimal", default=16,
help="Number of maximum page")
parser.add_argument('-o', '--outputbin', type=str, required=False, default="",
help="Number of maximum page")
parser.add_argument('-t', '--type', type=str, required=False, choices=type_choices,
help="The key type of the tag") #XXXTODO: manage all types C and EV1

Expand All @@ -603,6 +605,7 @@ def get_param(self, args):
class Param:
def __init__(self):
self.mpage = args.maxpages
self.outputbin = args.outputbin
self.type = 0x60 if args.type == 'BASIC' or args.type == 'C' or args.type == 'EV1' else 0x61

return Param()
Expand Down Expand Up @@ -634,9 +637,19 @@ class HFMFUCDMPPG(BaseMFUCDUMP):
# hf mfu rdpg -p 2
def on_exec(self, args: argparse.Namespace):
param = self.get_param(args)
fd = None
if param.outputbin != "":
fd =open(param.outputbin, 'wb+')
for i in range(param.mpage):
resp = self.cmd.read_mfuc_page(i, param.type)
if fd is not None:
fd.write(resp.data)
print(f" - Page {i}: {resp.data.hex()}")
if fd is not None:
print(f" - {colorama.Fore.GREEN}Write done in {param.outputbin}.{colorama.Style.RESET_ALL}")
fd.close()




@hf_mf.command('wrbl', 'Mifare Classic write one block')
Expand Down

0 comments on commit 302beca

Please sign in to comment.