This commit is contained in:
iceman1001 committed 2024-01-24 18:18:13 +01:00
1 parent 7afe2dab8c
commit 2d9c1a941c
6 files changed
+264 -296

No files matched your search

+18 -24
View File
@@ -532,12 +532,11 @@ static uint8_t arg_add_default(void *at[]) {
}
static uint16_t arg_get_raw_flag(uint8_t uidlen, bool unaddressed, bool scan, bool add_option) {
uint16_t flags = 0;
;
;
if (uidlen == 8 || scan || unaddressed) {
flags = (ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY);
}
if ((!unaddressed) || scan)
{
if ((!unaddressed) || scan) {
flags |= ISO15_REQ_ADDRESS;
}
if (add_option) {
@@ -1278,10 +1277,9 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize, boo
PrintAndLogEx(NORMAL, "");
if (blocksize == 0 || bytes == 0)
{
PrintAndLogEx(INFO, "Tag is empty!");
return;
if (blocksize == 0 || bytes == 0) {
PrintAndLogEx(INFO, "Tag is empty!");
return;
}
print_hrule(blocksize);
@@ -1432,8 +1430,7 @@ static int CmdHF15Sim(const char *Cmd) {
}
CLIParserFree(ctx);
if (uidlen == 0) // get UID from emulator
{
if (uidlen == 0) { // get UID from emulator
// reserve memory
iso15_tag_t *tag = calloc(1, sizeof(iso15_tag_t));
if (tag == NULL) {
@@ -1441,7 +1438,7 @@ static int CmdHF15Sim(const char *Cmd) {
return PM3_EMALLOC;
}
if (GetFromDevice(BIG_BUF_EML, (uint8_t*)tag, sizeof(iso15_tag_t), 0, NULL, 0, NULL, 2500, false) == false) {
if (GetFromDevice(BIG_BUF_EML, (uint8_t *)tag, sizeof(iso15_tag_t), 0, NULL, 0, NULL, 2500, false) == false) {
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
free(tag);
return PM3_ETIMEOUT;
@@ -1729,8 +1726,8 @@ static int CmdHF15Dump(const char *Cmd) {
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0(NULL, "ns", "no save to file"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_lit0(NULL, "ns", "no save to file"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true);
@@ -1847,21 +1844,18 @@ static int CmdHF15Dump(const char *Cmd) {
tag->dsfid = d[dCpt++];
if (d[1] & 0x02)
tag->afi = d[dCpt++];
if (d[1] & 0x04)
{
tag->pagesCount = d[dCpt++]+1;
tag->bytesPerPage = d[dCpt++]+1;
}
else
{ // Set tag memory layout values (if can't be readed in SYSINFO)
if (d[1] & 0x04) {
tag->pagesCount = d[dCpt++] + 1;
tag->bytesPerPage = d[dCpt++] + 1;
} else {
// Set tag memory layout values (if can't be readed in SYSINFO)
tag->bytesPerPage = blocksize;
tag->pagesCount = 128;
}
if (d[1] & 0x08)
tag->ic = d[dCpt++];
if (verbose)
{
if (verbose) {
print_emltag_info_15693(tag);
}
@@ -1957,9 +1951,9 @@ static int CmdHF15Dump(const char *Cmd) {
PrintAndLogEx(INFO, "%3d/0x%02X | %s| %s | %s"
, i
, i
, sprint_hex(&tag->data[i*tag->bytesPerPage], tag->bytesPerPage)
, sprint_hex(&tag->data[i * tag->bytesPerPage], tag->bytesPerPage)
, lck
, sprint_ascii(&tag->data[i*tag->bytesPerPage], tag->bytesPerPage)
, sprint_ascii(&tag->data[i * tag->bytesPerPage], tag->bytesPerPage)
);
}
PrintAndLogEx(INFO, "---------+-------------+---+-------");
@@ -1979,7 +1973,7 @@ static int CmdHF15Dump(const char *Cmd) {
FillFileNameByUID(fptr, SwapEndian64(uid, sizeof(uid), 8), "-dump", sizeof(uid));
}
pm3_save_dump(filename, (uint8_t*)tag, sizeof(iso15_tag_t), jsf15_v4);
pm3_save_dump(filename, (uint8_t *)tag, sizeof(iso15_tag_t), jsf15_v4);
return PM3_SUCCESS;
}
+1 -1
View File
@@ -2132,7 +2132,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
}
out:
mfu_fingerprint(tagtype, has_auth_key, authkeyptr, ak_len);
mfu_fingerprint(tagtype, has_auth_key, authkeyptr, ak_len);
DropField();
if (locked) {
+8 -8
View File
@@ -525,19 +525,19 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
iso15_tag_t *tag = (iso15_tag_t *)data;
JsonSaveBufAsHexCompact(root, "$.Card.uid", tag->uid, 8);
JsonSaveBufAsHexCompact(root, "$.Card.dsfid", &tag->dsfid, 1);
JsonSaveBufAsHexCompact(root, "$.Card.dsfidLock", (uint8_t*)&tag->dsfidLock, 1);
JsonSaveBufAsHexCompact(root, "$.Card.dsfidLock", (uint8_t *)&tag->dsfidLock, 1);
JsonSaveBufAsHexCompact(root, "$.Card.afi", &tag->afi, 1);
JsonSaveBufAsHexCompact(root, "$.Card.afiLock", (uint8_t*)&tag->afiLock, 1);
JsonSaveBufAsHexCompact(root, "$.Card.afiLock", (uint8_t *)&tag->afiLock, 1);
JsonSaveBufAsHexCompact(root, "$.Card.bytesPerPage", &tag->bytesPerPage, 1);
JsonSaveBufAsHexCompact(root, "$.Card.pagesCount", &tag->pagesCount, 1);
JsonSaveBufAsHexCompact(root, "$.Card.IC", &tag->ic, 1);
JsonSaveBufAsHexCompact(root, "$.Card.locks", tag->locks, tag->pagesCount);
JsonSaveBufAsHexCompact(root, "$.Card.random", tag->random, 2);
JsonSaveBufAsHexCompact(root, "$.Card.privacyPasswd", tag->privacyPasswd, 4);
JsonSaveBufAsHexCompact(root, "$.Card.state", (uint8_t*)&tag->state, 1);
JsonSaveBufAsHexCompact(root, "$.Card.state", (uint8_t *)&tag->state, 1);
for (size_t i = 0 ; i < tag->pagesCount ; i++) {
if (((i+1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE)
if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE)
break;
snprintf(path, sizeof(path), "$.blocks.%zu", i);
JsonSaveBufAsHexCompact(root, path,
@@ -1705,20 +1705,20 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
iso15_tag_t *tag = (iso15_tag_t *)udata.bytes;
JsonLoadBufAsHex(root, "$.Card.UID", tag->uid, 8, datalen);
JsonLoadBufAsHex(root, "$.Card.dsfid", &tag->dsfid, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.dsfidLock", (uint8_t*)&tag->dsfidLock, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.dsfidLock", (uint8_t *)&tag->dsfidLock, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.afi", &tag->afi, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.afiLock", (uint8_t*)&tag->afiLock, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.afiLock", (uint8_t *)&tag->afiLock, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.bytesPerPage", &tag->bytesPerPage, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.pagesCount", &tag->pagesCount, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.IC", &tag->ic, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.locks", tag->locks, tag->pagesCount, datalen);
JsonLoadBufAsHex(root, "$.Card.random", tag->random, 2, datalen);
JsonLoadBufAsHex(root, "$.Card.privacyPasswd", tag->privacyPasswd, 4, datalen);
JsonLoadBufAsHex(root, "$.Card.state", (uint8_t*)&tag->state, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.state", (uint8_t *)&tag->state, 1, datalen);
size_t sptr = 0;
for (int i = 0; i < tag->pagesCount ; i++) {
if (((i+1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) {
if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) {
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen", maxdatalen, maxdatalen, i, i, sptr, sptr);
retval = PM3_EMALLOC;
goto out;