mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Added FIELD_OFF_DO_RESET support to cli hf mf econfig
This commit is contained in:
@@ -2155,6 +2155,9 @@ class HFMFEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequiredU
|
||||
log_group = parser.add_mutually_exclusive_group()
|
||||
log_group.add_argument('--enable-log', action='store_true', help="Enable logging of MFC authentication data")
|
||||
log_group.add_argument('--disable-log', action='store_true', help="Disable logging of MFC authentication data")
|
||||
field_off_reset_group = parser.add_mutually_exclusive_group()
|
||||
field_off_reset_group.add_argument('--enable_set_field_off_do_reset', action='store_true', help="Enable FIELD_OFF_DO_RESET")
|
||||
field_off_reset_group.add_argument('--disable_set_field_off_do_reset', action='store_true', help="Disable FIELD_OFF_DO_RESET")
|
||||
return parser
|
||||
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
@@ -2185,6 +2188,8 @@ class HFMFEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequiredU
|
||||
write_mode = MifareClassicWriteMode(mfc_config["write_mode"])
|
||||
detection = mfc_config["detection"]
|
||||
change_requested, change_done, uid, atqa, sak, ats = self.update_hf14a_anticoll(args, uid, atqa, sak, ats)
|
||||
field_off_do_reset = self.cmd.mf1_get_field_off_do_reset()
|
||||
|
||||
if args.enable_gen1a:
|
||||
change_requested = True
|
||||
if not gen1a_mode:
|
||||
@@ -2258,6 +2263,22 @@ class HFMFEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequiredU
|
||||
change_done = True
|
||||
else:
|
||||
print(f'{color_string((CY, "Requested logging of MFC authentication data already disabled"))}')
|
||||
if args.enable_set_field_off_do_reset:
|
||||
change_requested = True
|
||||
if not field_off_do_reset:
|
||||
field_off_do_reset = True
|
||||
self.cmd.mf1_set_field_off_do_reset(field_off_do_reset)
|
||||
change_done = True
|
||||
else:
|
||||
print(f'{color_string((CY, "Requested FIELD_OFF_DO_RESET already enabled"))}')
|
||||
elif args.disable_set_field_off_do_reset:
|
||||
change_requested = True
|
||||
if field_off_do_reset:
|
||||
field_off_do_reset = False
|
||||
self.cmd.mf1_set_field_off_do_reset(field_off_do_reset)
|
||||
change_done = True
|
||||
else:
|
||||
print(f'{color_string((CY, "Requested FIELD_OFF_DO_RESET already disabled"))}')
|
||||
|
||||
if change_done:
|
||||
print(' - MF1 Emulator settings updated')
|
||||
@@ -2284,6 +2305,8 @@ class HFMFEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequiredU
|
||||
print(f'- {"Write mode:":40}{color_string((CR, "invalid value!"))}')
|
||||
print(
|
||||
f'- {"Log (mfkey32) mode:":40}{f"{enabled_str}" if detection else f"{disabled_str}"}')
|
||||
print(
|
||||
f'- {"FIELD_OFF_DO_RESET:":40}{f"{enabled_str}" if field_off_do_reset else f"{disabled_str}"}')
|
||||
|
||||
|
||||
@hf_mfu.command('ercnt')
|
||||
|
||||
@@ -1304,6 +1304,18 @@ class ChameleonCMD:
|
||||
def set_ble_pairing_enable(self, enabled: bool):
|
||||
data = struct.pack('!B', enabled)
|
||||
return self.device.send_cmd_sync(Command.SET_BLE_PAIRING_ENABLE, data)
|
||||
|
||||
@expect_response(Status.SUCCESS)
|
||||
def mf1_get_field_off_do_reset(self):
|
||||
resp = self.device.send_cmd_sync(Command.MF1_GET_FIELD_OFF_DO_RESET)
|
||||
if resp.status == Status.SUCCESS:
|
||||
resp.parsed = struct.unpack('!B', resp.data)[0] == 1
|
||||
return resp
|
||||
|
||||
@expect_response(Status.SUCCESS)
|
||||
def mf1_set_field_off_do_reset(self, enabled: bool):
|
||||
data = struct.pack('!B', enabled)
|
||||
return self.device.send_cmd_sync(Command.MF1_SET_FIELD_OFF_DO_RESET, data)
|
||||
|
||||
|
||||
def test_fn():
|
||||
|
||||
@@ -124,6 +124,9 @@ class Command(enum.IntEnum):
|
||||
# FIXME: not implemented
|
||||
MF0_NTAG_GET_EMULATOR_CONFIG = 4037
|
||||
|
||||
MF1_SET_FIELD_OFF_DO_RESET = 4038
|
||||
MF1_GET_FIELD_OFF_DO_RESET = 4039
|
||||
|
||||
EM410X_SET_EMU_ID = 5000
|
||||
EM410X_GET_EMU_ID = 5001
|
||||
HIDPROX_SET_EMU_ID = 5002
|
||||
|
||||
Reference in New Issue
Block a user