Add a command to reset MF0 / NTAG unsuccessful auth counter.

This commit is contained in:
turbocool3r
2024-07-09 21:30:27 +03:00
parent 202f5d3884
commit 607df41bca
6 changed files with 41 additions and 2 deletions
+12 -1
View File
@@ -2216,12 +2216,15 @@ class HFMFUEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequired
uid_magic_group.add_argument('--disable-uid-magic', action='store_true', help="Disable UID magic mode")
parser.add_argument('--set-version', type=bytes.fromhex, help="Set data to be returned by the GET_VERSION command.")
parser.add_argument('--set-signature', type=bytes.fromhex, help="Set data to be returned by the READ_SIG command.")
parser.add_argument('--reset-auth-cnt', action='store_true', help="Resets the counter of unsuccessful authentication attempts.")
return parser
def on_exec(self, args: argparse.Namespace):
aux_data_changed = False
aux_data_change_requested = False
if args.set_version is not None:
aux_data_change_requested = True
aux_data_changed = True
if len(args.set_version) != 8:
@@ -2235,6 +2238,7 @@ class HFMFUEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequired
return
if args.set_signature is not None:
aux_data_change_requested = True
aux_data_changed = True
if len(args.set_signature) != 32:
@@ -2246,6 +2250,13 @@ class HFMFUEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequired
except:
print(f"{CR}Tag type does not support READ_SIG command.{C0}")
return
if args.reset_auth_cnt:
aux_data_change_requested = True
old_value = self.cmd.mfu_reset_auth_cnt()
if old_value != 0:
aux_data_changed = True
print(f"- Unsuccessful auth counter has been reset from {old_value} to 0.")
# collect current settings
anti_coll_data = self.cmd.hf14a_get_anti_coll_data()
@@ -2285,7 +2296,7 @@ class HFMFUEConfig(SlotIndexArgsAndGoUnit, HF14AAntiCollArgsUnit, DeviceRequired
if change_done or aux_data_changed:
print(' - MFU/NTAG Emulator settings updated')
if not (change_requested or aux_data_changed):
if not (change_requested or aux_data_change_requested):
print(f'- {"Type:":40}{CY}{hf_tag_type}{C0}')
print(f'- {"UID:":40}{CY}{uid.hex().upper()}{C0}')
print(f'- {"ATQA:":40}{CY}{atqa.hex().upper()} '
+10
View File
@@ -628,6 +628,16 @@ class ChameleonCMD:
resp = self.device.send_cmd_sync(Command.MF0_NTAG_SET_COUNTER_DATA, data)
return resp
@expect_response(Status.SUCCESS)
def mfu_reset_auth_cnt(self):
"""
Resets authentication counter
"""
resp = self.device.send_cmd_sync(Command.MF0_NTAG_RESET_AUTH_CNT, bytes())
if resp.status == Status.SUCCESS:
resp.parsed = resp.data[0]
return resp
@expect_response(Status.SUCCESS)
def hf14a_set_anti_coll_data(self, uid: bytes, atqa: bytes, sak: bytes, ats: bytes = b''):
"""
+1
View File
@@ -105,6 +105,7 @@ class Command(enum.IntEnum):
MF0_NTAG_SET_SIGNATURE_DATA = 4026
MF0_NTAG_GET_COUNTER_DATA = 4027
MF0_NTAG_SET_COUNTER_DATA = 4028
MF0_NTAG_RESET_AUTH_CNT = 4029
EM410X_SET_EMU_ID = 5000
EM410X_GET_EMU_ID = 5001