This commit is contained in:
iceman1001 2025-03-19 11:26:25 +01:00
commit 3c873d34bc
4 changed files with 46 additions and 44 deletions

View file

@ -3119,45 +3119,45 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, bool send_chaining, void *data, u
} }
// S-Block WTX // S-Block WTX
while (len && ((data_bytes[0] & 0xF2) == 0xF2)) { while (len && ((data_bytes[0] & 0xF2) == 0xF2)) {
uint32_t save_iso14a_timeout = iso14a_get_timeout(); uint32_t save_iso14a_timeout = iso14a_get_timeout();
// temporarily increase timeout // temporarily increase timeout
iso14a_set_timeout(MAX((data_bytes[1] & 0x3f) * save_iso14a_timeout, MAX_ISO14A_TIMEOUT)); iso14a_set_timeout(MAX((data_bytes[1] & 0x3f) * save_iso14a_timeout, MAX_ISO14A_TIMEOUT));
// Transmit WTX back // Transmit WTX back
// byte1 - WTXM [1..59]. command FWT=FWT*WTXM // byte1 - WTXM [1..59]. command FWT=FWT*WTXM
data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b
// now need to fix CRC. // now need to fix CRC.
AddCrc14A(data_bytes, len - 2); AddCrc14A(data_bytes, len - 2);
// transmit S-Block // transmit S-Block
ReaderTransmit(data_bytes, len, NULL); ReaderTransmit(data_bytes, len, NULL);
// retrieve the result again (with increased timeout) // retrieve the result again (with increased timeout)
data_bytes[0] = 0x00; data_bytes[0] = 0x00;
len = ReaderReceive(data, data_len, parity_array); len = ReaderReceive(data, data_len, parity_array);
data_bytes = data; data_bytes = data;
// restore timeout // restore timeout
iso14a_set_timeout(save_iso14a_timeout); iso14a_set_timeout(save_iso14a_timeout);
} }
// if we received an I- or R(ACK)-Block with a block number equal to the // if we received an I- or R(ACK)-Block with a block number equal to the
// current block number, toggle the current block number // current block number, toggle the current block number
if (len >= 3 // PCB+CRC = 3 bytes if (len >= 3 // PCB+CRC = 3 bytes
&& ((data_bytes[0] & 0xC0) == 0 // I-Block && ((data_bytes[0] & 0xC0) == 0 // I-Block
|| (data_bytes[0] & 0xD0) == 0x80) // R-Block with ACK bit set to 0 || (data_bytes[0] & 0xD0) == 0x80) // R-Block with ACK bit set to 0
&& (data_bytes[0] & 0x01) == iso14_pcb_blocknum) { // equal block numbers && (data_bytes[0] & 0x01) == iso14_pcb_blocknum) { // equal block numbers
iso14_pcb_blocknum ^= 1; iso14_pcb_blocknum ^= 1;
} }
// if we received I-block with chaining we need to send ACK and receive another block of data // if we received I-block with chaining we need to send ACK and receive another block of data
if (res) { if (res) {
*res = data_bytes[0]; *res = data_bytes[0];
} }
// crc check // crc check
if (len >= 3 && !CheckCrc14A(data_bytes, len)) { if (len >= 3 && !CheckCrc14A(data_bytes, len)) {
BigBuf_free(); BigBuf_free();
return -1; return -1;
} }
if (len) { if (len) {
// cut frame byte // cut frame byte

View file

@ -10102,14 +10102,16 @@
"description": "Simulate Hitag S transponder You need to `lf hitag hts eload` first", "description": "Simulate Hitag S transponder You need to `lf hitag hts eload` first",
"notes": [ "notes": [
"lf hitag hts sim", "lf hitag hts sim",
"lf hitag hts sim --82xx" "lf hitag hts sim --82xx",
"lf hitag hts sim -t 30 -> set threshold to 30"
], ],
"offline": false, "offline": false,
"options": [ "options": [
"-h, --help This help", "-h, --help This help",
"-8, --82xx simulate 8268/8310" "-8, --82xx simulate 8268/8310",
"-t, --threshold <dec> set edge detect threshold (def: 127)"
], ],
"usage": "lf hitag hts sim [-h8]" "usage": "lf hitag hts sim [-h8] [-t <dec>]"
}, },
"lf hitag hts wrbl": { "lf hitag hts wrbl": {
"command": "lf hitag hts wrbl", "command": "lf hitag hts wrbl",
@ -13248,6 +13250,6 @@
"metadata": { "metadata": {
"commands_extracted": 761, "commands_extracted": 761,
"extracted_by": "PM3Help2JSON v1.00", "extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2025-03-19T08:33:58" "extracted_on": "2025-03-19T10:24:44"
} }
} }