From 63bd0cb22e57afd97b6c160e40fa8e60fef9d7e8 Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Thu, 3 Apr 2025 13:55:38 +0200 Subject: [PATCH] Update chameleon_cli_unit.py Defined a working function load_key_file(import_key, keys) for command hf mf fchk --key function load_dic_file(import_dic, keys) is empty for now, to prevent an error when executing hf mf fchk --dic --- software/script/chameleon_cli_unit.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/software/script/chameleon_cli_unit.py b/software/script/chameleon_cli_unit.py index 6bcf9e9..fc58144 100644 --- a/software/script/chameleon_cli_unit.py +++ b/software/script/chameleon_cli_unit.py @@ -42,7 +42,18 @@ type_id_SAK_dict = {0x00: "MIFARE Ultralight Classic/C/EV1/Nano | NTAG 2xx", default_cwd = Path.cwd() / Path(__file__).with_name("bin") +def load_key_file(import_key, keys): + """ + Load key file and append its content to the provided set of keys. + Each key is expected to be on a new line in the file. + """ + with open(import_key.name, 'rb') as file: + keys.update(line.encode('utf-8') for line in file.read().decode('utf-8').splitlines()) + return keys +def load_dic_file(import_dic, keys): + return keys + def check_tools(): tools = ['staticnested', 'nested', 'darkside', 'mfkey32v2'] if sys.platform == "win32":