diff --git a/pm3py/core/lf.py b/pm3py/core/lf.py index 2baacb5..da0e008 100644 --- a/pm3py/core/lf.py +++ b/pm3py/core/lf.py @@ -25,8 +25,15 @@ class T55xxCommands: } async def writebl(self, block: int, data: int, page: int = 0, - password: int | None = None, downlink_mode: int = 0) -> dict: - """Write a T55xx block.""" + password: int | None = None, downlink_mode: int = 0, + test: bool = False) -> dict: + """Write a T55xx block. + + ``test`` uses the test-mode write (downlink opcode 01) instead of the standard opcode 10. + Test mode is the datasheet's reconfiguration path (§5.10.3) — it can rewrite a tag that a + normal write can't (a corrupted/locked config), provided the master key still permits it + (allowed for key 9, denied once key 6 is set). Use it for recovery, not routine writes. + """ pwd = password if password is not None else 0 # Firmware t55xx_write_block_t: data(4)+pwd(4)+blockno(1)+flags(1). # flags: 0x01 PwdMode, 0x02 Page, 0x04 test, 0x18 downlink_mode<<3. @@ -35,6 +42,8 @@ class T55xxCommands: flags |= 0x01 if page: flags |= 0x02 + if test: + flags |= 0x04 flags |= (downlink_mode & 0x03) << 3 payload = struct.pack("