feat(pm3py): ISO15693 + MIFARE Classic commands

This commit is contained in:
michael
2026-03-15 22:18:11 -07:00
parent 2f88fabde6
commit 31a6036cd3
5 changed files with 276 additions and 0 deletions

15
tests/test_hf_15.py Normal file
View File

@@ -0,0 +1,15 @@
import asyncio
from unittest.mock import AsyncMock
from pm3py.protocol import Cmd
from pm3py.transport import PM3Response
from pm3py.hf_15 import HF15Commands
def test_15_scan():
t = AsyncMock()
iso15 = HF15Commands(t)
# Fake response: flags(1) + DSFID(1) + UID(8)
resp_data = bytes([0x00, 0x00]) + bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xE0])
t.send_ng.return_value = PM3Response(cmd=Cmd.HF_ISO15693_COMMAND, status=0,
reason=0, ng=True, data=resp_data)
result = asyncio.get_event_loop().run_until_complete(iso15.scan())
assert "uid" in result

26
tests/test_hf_mf.py Normal file
View File

@@ -0,0 +1,26 @@
import struct
import asyncio
from unittest.mock import AsyncMock
from pm3py.protocol import Cmd
from pm3py.transport import PM3Response
from pm3py.hf_mf import HFMFCommands
def test_mf_rdbl():
t = AsyncMock()
mf = HFMFCommands(t)
block_data = bytes(range(16))
t.send_ng.return_value = PM3Response(cmd=Cmd.HF_MIFARE_READBL, status=0,
reason=0, ng=True, data=block_data)
result = asyncio.get_event_loop().run_until_complete(
mf.rdbl(block=0, key="FFFFFFFFFFFF"))
assert result["data"] == block_data.hex()
assert len(result["raw"]) == 16
def test_mf_wrbl():
t = AsyncMock()
mf = HFMFCommands(t)
t.send_mix.return_value = PM3Response(cmd=Cmd.ACK, status=0, reason=0,
ng=False, data=b"", oldarg=[1, 0, 0])
result = asyncio.get_event_loop().run_until_complete(
mf.wrbl(block=4, key="FFFFFFFFFFFF", data="00" * 16))
assert result["success"] is True