Skip to content

Commit 345eff5

Browse files
committed
#436 - Add --nopwd option for T55xx em410x write
Add a --nopwd flag to `lf em410x write` that leaves the written T55xx tag password-free instead of applying the default password. - Firmware: clear the T5577 PWD config bit in block 0 when the key is zero, so the tag is left unprotected. - Client: add a no_pwd parameter to em410x_write_to_t55xx and a --nopwd flag. - Include the default password in the unlock key list so a tag previously locked by this tool can be freed by a --nopwd write.
1 parent f349dbe commit 345eff5

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

firmware/application/src/rfid/reader/lf/lf_reader_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ static void try_reset_t55xx_passwd(uint32_t new_passwd, uint8_t *old_passwds, ui
131131
static uint8_t write_t55xx(uint32_t *blks, uint8_t blk_count, uint8_t *new_passwd, uint8_t *old_passwds, uint8_t old_passwd_count) {
132132
uint32_t passwd = bytes_to_num(new_passwd, 4);
133133

134+
// No password: clear the PWD bit in block 0
135+
if (passwd == 0) {
136+
blks[0] &= ~T5577_PWD;
137+
}
138+
134139
start_lf_125khz_radio();
135140
bsp_delay_ms(1); // Delays for a while after starting the field
136141

software/script/chameleon_cli_unit.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5797,7 +5797,10 @@ class LFEM410xWriteT55xx(LFEMIdArgsUnit, ReaderRequiredUnit):
57975797
def args_parser(self) -> ArgumentParserNoExit:
57985798
parser = ArgumentParserNoExit()
57995799
parser.description = "Write em410x id to t55xx"
5800-
return self.add_card_arg(parser, required=True)
5800+
parser = self.add_card_arg(parser, required=True)
5801+
parser.add_argument("--nopwd", action="store_true",
5802+
help="Leave the T55xx password-free")
5803+
return parser
58015804

58025805
def on_exec(self, args: argparse.Namespace):
58035806
id_hex = args.id
@@ -5806,8 +5809,8 @@ def on_exec(self, args: argparse.Namespace):
58065809
"Writing to T55xx supports 5-byte EM410X (10 hex) or 13-byte Electra (26 hex) IDs."
58075810
)
58085811
id_bytes = bytes.fromhex(id_hex)
5809-
self.cmd.em410x_write_to_t55xx(id_bytes)
5810-
print(f" - EM410x ID write done: {id_hex}")
5812+
self.cmd.em410x_write_to_t55xx(id_bytes, no_pwd=args.nopwd)
5813+
print(f" - EM410x ID write done: {id_hex}" + (" (no password)" if args.nopwd else ""))
58115814

58125815

58135816
@lf_hid_prox.command("read")

software/script/chameleon_cmd.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
CURRENT_VERSION_SETTINGS = 6
1212

1313
new_key = b'\x20\x20\x66\x66'
14-
old_keys = [b'\x51\x24\x36\x48', b'\x19\x92\x04\x27']
14+
# Passwords tried to unlock a protected T55xx (includes the default new_key)
15+
old_keys = [b'\x51\x24\x36\x48', b'\x19\x92\x04\x27', b'\x20\x20\x66\x66']
1516

1617

1718
class ChameleonCMD:
@@ -615,18 +616,20 @@ def em410x_scan(self):
615616
return resp
616617

617618
@expect_response(Status.LF_TAG_OK)
618-
def em410x_write_to_t55xx(self, id_bytes: bytes):
619+
def em410x_write_to_t55xx(self, id_bytes: bytes, no_pwd: bool = False):
619620
"""
620621
Write EM410X card number into T55XX.
621622
622623
:param id_bytes: ID card number
624+
:param no_pwd: if True, leave the tag password-free
623625
:return:
624626
"""
627+
key = b'\x00\x00\x00\x00' if no_pwd else new_key
625628
if len(id_bytes) == 5:
626-
data = struct.pack(f'!5s4s{4*len(old_keys)}s', id_bytes, new_key, b''.join(old_keys))
629+
data = struct.pack(f'!5s4s{4*len(old_keys)}s', id_bytes, key, b''.join(old_keys))
627630
return self.device.send_cmd_sync(Command.EM410X_WRITE_TO_T55XX, data)
628631
if len(id_bytes) == 13:
629-
data = struct.pack(f'!13s4s{4*len(old_keys)}s', id_bytes, new_key, b''.join(old_keys))
632+
data = struct.pack(f'!13s4s{4*len(old_keys)}s', id_bytes, key, b''.join(old_keys))
630633
return self.device.send_cmd_sync(Command.EM410X_ELECTRA_WRITE_TO_T55XX, data)
631634
raise ValueError("The id bytes length must equal 5 (EM410X) or 13 (Electra)")
632635

0 commit comments

Comments
 (0)