mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-26 16:15:25 -07:00
advanced record reading
This commit is contained in:
parent
882e96a3ce
commit
5a7e507de2
3 changed files with 28 additions and 8 deletions
|
@ -6345,7 +6345,7 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
||||||
|
|
||||||
if (resplen > 0) {
|
if (resplen > 0) {
|
||||||
PrintAndLogEx(SUCCESS, "Read %u bytes from file 0x%02x offset %u", resplen, fnum, offset);
|
PrintAndLogEx(SUCCESS, "Read %u bytes from file 0x%02x offset %u", resplen, fnum, offset);
|
||||||
print_buffer_with_offset(resp, resplen, offset);
|
print_buffer_with_offset(resp, resplen, offset, true);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, "Read operation returned no data from file %d", fnum);
|
PrintAndLogEx(SUCCESS, "Read operation returned no data from file %d", fnum);
|
||||||
}
|
}
|
||||||
|
@ -6363,6 +6363,17 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == RFTRecord) {
|
if (op == RFTRecord) {
|
||||||
|
res = DesfireReadRecords(&dctx, fnum, offset, 1, resp, &resplen);
|
||||||
|
if (res != PM3_SUCCESS) {
|
||||||
|
PrintAndLogEx(ERR, "Desfire ReadRecords (len=1) command " _RED_("error") ". Result: %d", res);
|
||||||
|
DropField();
|
||||||
|
return PM3_ESOFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t reclen = resplen;
|
||||||
|
if (verbose)
|
||||||
|
PrintAndLogEx(INFO, "Record length %zu", reclen);
|
||||||
|
|
||||||
res = DesfireReadRecords(&dctx, fnum, offset, length, resp, &resplen);
|
res = DesfireReadRecords(&dctx, fnum, offset, length, resp, &resplen);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire ReadRecords command " _RED_("error") ". Result: %d", res);
|
PrintAndLogEx(ERR, "Desfire ReadRecords command " _RED_("error") ". Result: %d", res);
|
||||||
|
@ -6371,8 +6382,15 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resplen > 0) {
|
if (resplen > 0) {
|
||||||
PrintAndLogEx(SUCCESS, "Read %u bytes from file 0x%02x offset %u", resplen, fnum, offset);
|
size_t reccount = resplen / reclen;
|
||||||
print_buffer_with_offset(resp, resplen, offset);
|
PrintAndLogEx(SUCCESS, "Read %u bytes from file 0x%02x from record %u record count %zu record length %zu", resplen, fnum, offset, reccount, reclen);
|
||||||
|
if (reccount > 0)
|
||||||
|
PrintAndLogEx(SUCCESS, "Lastest record at the bottom.");
|
||||||
|
for (int i = 0; i < reccount; i++) {
|
||||||
|
if (i != 0)
|
||||||
|
PrintAndLogEx(SUCCESS, "Record %d", i + offset);
|
||||||
|
print_buffer_with_offset(&resp[i * reclen], reclen, offset, (i == 0));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, "Read operation returned no data from file %d", fnum);
|
PrintAndLogEx(SUCCESS, "Read operation returned no data from file %d", fnum);
|
||||||
}
|
}
|
||||||
|
@ -6389,7 +6407,7 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
||||||
if (resplen > 0) {
|
if (resplen > 0) {
|
||||||
if (resplen != 12) {
|
if (resplen != 12) {
|
||||||
PrintAndLogEx(WARNING, "Read wrong %u bytes from file 0x%02x offset %u", resplen, fnum, offset);
|
PrintAndLogEx(WARNING, "Read wrong %u bytes from file 0x%02x offset %u", resplen, fnum, offset);
|
||||||
print_buffer_with_offset(resp, resplen, offset);
|
print_buffer_with_offset(resp, resplen, offset, true);
|
||||||
} else {
|
} else {
|
||||||
uint32_t cnt = MemLeToUint4byte(&resp[0]);
|
uint32_t cnt = MemLeToUint4byte(&resp[0]);
|
||||||
PrintAndLogEx(SUCCESS, "Transaction counter: %d (0x%08x)", cnt, cnt);
|
PrintAndLogEx(SUCCESS, "Transaction counter: %d (0x%08x)", cnt, cnt);
|
||||||
|
|
|
@ -249,9 +249,11 @@ void print_buffer(const uint8_t *data, const size_t len, int level) {
|
||||||
print_buffer_ex(data, len, level, 16);
|
print_buffer_ex(data, len, level, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset) {
|
void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset, bool print_header) {
|
||||||
|
if (print_header) {
|
||||||
PrintAndLogEx(INFO, " Offset | Data | Ascii");
|
PrintAndLogEx(INFO, " Offset | Data | Ascii");
|
||||||
PrintAndLogEx(INFO, "----------------------------------------------------------------------------");
|
PrintAndLogEx(INFO, "----------------------------------------------------------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i += 16) {
|
for (uint32_t i = 0; i < len; i += 16) {
|
||||||
uint32_t l = len - i;
|
uint32_t l = len - i;
|
||||||
|
|
|
@ -52,7 +52,7 @@ char *sprint_hex_ascii(const uint8_t *data, const size_t len);
|
||||||
char *sprint_ascii(const uint8_t *data, const size_t len);
|
char *sprint_ascii(const uint8_t *data, const size_t len);
|
||||||
char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_str_len);
|
char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_str_len);
|
||||||
|
|
||||||
void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset);
|
void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset, bool print_header);
|
||||||
void print_buffer(const uint8_t *data, const size_t len, int level);
|
void print_buffer(const uint8_t *data, const size_t len, int level);
|
||||||
void print_blocks(uint32_t *data, size_t len);
|
void print_blocks(uint32_t *data, size_t len);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue