hf 15 dump had an logic bug when reading the sysinfo response. It is always fixed size but the logic for handling the Information byte flags made it skip bytes when it wasnt 0x0F
Some checks are pending
CodeQL / Analyze (push) Waiting to run
MacOS Build and Test / macos-make (push) Waiting to run
MacOS Build and Test / macos-make-btaddon (push) Waiting to run
MacOS Build and Test / macos-cmake (push) Waiting to run
Ubuntu Build and Test / ubuntu-make (push) Waiting to run
Ubuntu Build and Test / ubuntu-make-btaddon (push) Waiting to run
Ubuntu Build and Test / ubuntu-cmake (push) Waiting to run
Windows Build and Test / proxspace (push) Waiting to run
Windows Build and Test / wsl (push) Waiting to run

This commit is contained in:
iceman1001 2025-07-02 22:04:42 +02:00
parent dab49248b4
commit 7373c38388
2 changed files with 47 additions and 21 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Fixed `hf 15 dump` - now reads sysinfo response correct (@iceman1001)
- Changed `make clean` - it now removes all __pycache__ folders (@iceman1001) - Changed `make clean` - it now removes all __pycache__ folders (@iceman1001)
- Fixed `hf 15 readmulti` - fix block calculations (@iceman1001) - Fixed `hf 15 readmulti` - fix block calculations (@iceman1001)
- Changed `mem load` - now handles UL-C and UL-AES dictionary files (@iceman1001) - Changed `mem load` - now handles UL-C and UL-AES dictionary files (@iceman1001)

View file

@ -1240,8 +1240,11 @@ static int CmdHF15ELoad(const char *Cmd) {
((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) || ((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) ||
(tag->pagesCount == 0) || (tag->pagesCount == 0) ||
(tag->bytesPerPage == 0)) { (tag->bytesPerPage == 0)) {
PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d", PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d",
tag->pagesCount, tag->bytesPerPage); tag->pagesCount,
tag->bytesPerPage
);
free(tag); free(tag);
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -1904,35 +1907,49 @@ static int CmdHF15Dump(const char *Cmd) {
uint8_t dCpt = 10; uint8_t dCpt = 10;
int res = iso15_error_handling_card_response(d, resp.length); int res = iso15_error_handling_card_response(d, resp.length);
if (res != PM3_SUCCESS) { if (res == PM3_ECRC) {
free(tag); free(tag);
free(packet); free(packet);
return res; return res;
} }
memcpy(tag->uid, &d[2], 8); if (res == PM3_SUCCESS) {
memcpy(tag->uid, d + 2, 8);
if (d[1] & 0x01) { if (d[1] & 0x01) {
tag->dsfid = d[dCpt++]; tag->dsfid = d[dCpt];
} }
dCpt++;
if (d[1] & 0x02) { if (d[1] & 0x02) {
tag->afi = d[dCpt++]; tag->afi = d[dCpt];
} }
dCpt++;
if (d[1] & 0x04) {
tag->pagesCount = d[dCpt] + 1;
tag->bytesPerPage = d[dCpt + 1] + 1;
} else {
// Set tag memory layout values (if can't be read in SYSINFO)
tag->bytesPerPage = blocksize;
tag->pagesCount = 128;
}
dCpt += 2;
if (d[1] & 0x08) {
tag->ic = d[dCpt];
}
dCpt++;
if (d[1] & 0x04) {
tag->pagesCount = d[dCpt++] + 1;
tag->bytesPerPage = d[dCpt++] + 1;
} else { } else {
tag->uid[0] = 0xE0;
tag->dsfid = 0;
tag->afi = 0;
// Set tag memory layout values (if can't be read in SYSINFO) // Set tag memory layout values (if can't be read in SYSINFO)
tag->bytesPerPage = blocksize; tag->bytesPerPage = blocksize;
tag->pagesCount = 128; tag->pagesCount = 128;
} }
if (d[1] & 0x08) {
tag->ic = d[dCpt++];
}
// add length for blockno (1) // add length for blockno (1)
packet->rawlen++; packet->rawlen++;
packet->raw[0] |= ISO15_REQ_OPTION; // Add option to dump lock status packet->raw[0] |= ISO15_REQ_OPTION; // Add option to dump lock status
@ -2244,7 +2261,9 @@ static int CmdHF15Readmulti(const char *Cmd) {
// 0 means 1 page, // 0 means 1 page,
// 1 means 2 pages, ... // 1 means 2 pages, ...
if (blockcnt > 0) blockcnt--; if (blockcnt > 0) {
blockcnt--;
}
packet->raw[packet->rawlen++] = blockno; packet->raw[packet->rawlen++] = blockno;
packet->raw[packet->rawlen++] = blockcnt; packet->raw[packet->rawlen++] = blockcnt;
@ -2702,8 +2721,11 @@ static int CmdHF15Restore(const char *Cmd) {
((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) || ((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) ||
(tag->pagesCount == 0) || (tag->pagesCount == 0) ||
(tag->bytesPerPage == 0)) { (tag->bytesPerPage == 0)) {
PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d", PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d",
tag->pagesCount, tag->bytesPerPage); tag->pagesCount,
tag->bytesPerPage
);
free(tag); free(tag);
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -2734,8 +2756,8 @@ static int CmdHF15Restore(const char *Cmd) {
for (tried = 0; tried < retries; tried++) { for (tried = 0; tried < retries; tried++) {
retval = hf_15_write_blk(&pm3flags, flags, uid, fast retval = hf_15_write_blk(&pm3flags, flags, uid, fast, i, data, tag->bytesPerPage);
, i, data, tag->bytesPerPage);
if (retval == PM3_SUCCESS) { if (retval == PM3_SUCCESS) {
PrintAndLogEx(INPLACE, "blk %3d", i); PrintAndLogEx(INPLACE, "blk %3d", i);
@ -3467,8 +3489,11 @@ static int CmdHF15View(const char *Cmd) {
((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) || ((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) ||
(tag->pagesCount == 0) || (tag->pagesCount == 0) ||
(tag->bytesPerPage == 0)) { (tag->bytesPerPage == 0)) {
PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d", PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d",
tag->pagesCount, tag->bytesPerPage); tag->pagesCount,
tag->bytesPerPage
);
free(tag); free(tag);
return PM3_EINVARG; return PM3_EINVARG;
} }