From 28b887aedbb934394908f22f39cd1b04fbbbec78 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 25 Jan 2024 01:45:18 +0100 Subject: [PATCH] text --- armsrc/iso15693.c | 37 +++++++++++++++++++++++++++---------- client/src/cmdhf15.c | 17 +++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index a4a806ae9..f75c2ecdc 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -2138,11 +2138,14 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) { return; } - // new tag (need initialization) if (uid != NULL) { + uint8_t empty[8] = { 0 }; - if (memcmp(uid, empty, 8) != 0) { - // simulate a new tag bazed on client parameters + + // User supplied not empty? + if (memcmp(uid, empty, 8)) { + // Set default values if user supplied a UID. + // Assume emulator memory is empty tag->uid[0] = uid[7]; // always E0 tag->uid[1] = uid[6]; // IC Manufacturer code tag->uid[2] = uid[5]; @@ -2164,20 +2167,33 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) { } } - if (tag->pagesCount > ISO15693_TAG_MAX_PAGES || \ - tag->pagesCount * tag->bytesPerPage > ISO15693_TAG_MAX_SIZE || - tag->pagesCount == 0 || tag->bytesPerPage == 0) { + if ((tag->pagesCount > ISO15693_TAG_MAX_PAGES) || + ((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) || + (tag->pagesCount == 0) || + (tag->bytesPerPage == 0)) { Dbprintf("Tag size error: pagesCount = %d, bytesPerPage=%d", tag->pagesCount, tag->bytesPerPage); reply_ng(CMD_HF_ISO15693_SIMULATE, PM3_EOPABORTED, NULL, 0); return; } - Iso15693InitTag(); // init simulator + Iso15693InitTag(); LED_A_ON(); - if (g_dbglevel >= DBG_DEBUG) - Dbprintf("ISO-15963 Simulating uid: %02X%02X%02X%02X%02X%02X%02X%02X, %u bytes/blocks x %u blocks", tag->uid[7], tag->uid[6], tag->uid[5], tag->uid[4], tag->uid[3], tag->uid[2], tag->uid[1], tag->uid[0], tag->bytesPerPage, tag->pagesCount); + if (g_dbglevel >= DBG_DEBUG) { + Dbprintf("ISO-15963 Simulating uid: %02X%02X%02X%02X%02X%02X%02X%02X, %u bytes/blocks x %u blocks" + , tag->uid[7] + , tag->uid[6] + , tag->uid[5] + , tag->uid[4] + , tag->uid[3] + , tag->uid[2] + , tag->uid[1] + , tag->uid[0] + , tag->bytesPerPage + , tag->pagesCount + ); + } LED_C_ON(); @@ -2578,8 +2594,9 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) { switch_off(); - if (button_pressed) + if (button_pressed) { DbpString("button pressed"); + } reply_ng(CMD_HF_ISO15693_SIMULATE, PM3_SUCCESS, NULL, 0); } diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index fe65b5739..2b6092e58 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1432,8 +1432,7 @@ static int CmdHF15Sim(const char *Cmd) { PacketResponseNG resp; - // get UID from emulator, for printing?? - // iceman: downloading 2200 bytes just to get a 8 byte UID is overkill + // get UID from emulator for printing if (uidlen == 0) { struct { @@ -1455,7 +1454,7 @@ static int CmdHF15Sim(const char *Cmd) { PrintAndLogEx(WARNING, "Failed to get UID from emulator memory"); return resp.status; } - PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, resp.data.asBytes)); + PrintAndLogEx(SUCCESS, "Start simulating UID... " _YELLOW_("%s"), iso15693_sprintUID(NULL, resp.data.asBytes)); } PrintAndLogEx(INFO, "Press " _YELLOW_("`pm3-button`") " to abort simulation"); @@ -1850,10 +1849,14 @@ static int CmdHF15Dump(const char *Cmd) { memcpy(tag->uid, &d[2], 8); - if (d[1] & 0x01) + if (d[1] & 0x01) { tag->dsfid = d[dCpt++]; - if (d[1] & 0x02) + } + + if (d[1] & 0x02) { tag->afi = d[dCpt++]; + } + if (d[1] & 0x04) { tag->pagesCount = d[dCpt++] + 1; tag->bytesPerPage = d[dCpt++] + 1; @@ -1862,8 +1865,10 @@ static int CmdHF15Dump(const char *Cmd) { tag->bytesPerPage = blocksize; tag->pagesCount = 128; } - if (d[1] & 0x08) + + if (d[1] & 0x08) { tag->ic = d[dCpt++]; + } if (verbose) { print_emltag_info_15693(tag);