fix hf md ndefread, to correctly skip non ndef formatted sectors

This commit is contained in:
iceman1001 2022-10-23 02:15:47 +02:00
parent a2c4682d18
commit ac29a893cf
3 changed files with 8 additions and 5 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...
## [unreleased][unreleased]
- Fixed `hf mf ndefread` - now skips not ndef formatted sectors correctly (@iceman1001)
- Fixed `lf hitag` - keep inside the arrays for key/password/nrar (@iceman1001)
- Added `hf mf ndefwrite` - write raw NDEF records to MIFARE Classic tag (@iceman1001)
- Changed `hf mf cwipe` - swapped the block0 data to genuine manufacture ones (@iceman1001)

View file

@ -5659,10 +5659,10 @@ int CmdHFMFNDEFRead(const char *Cmd) {
}
PrintAndLogEx(INFO, "reading data from tag");
for (int i = 0; i < madlen; i++) {
for (int i = 1; i <= madlen; i++) {
if (ndef_aid == mad[i]) {
uint8_t vsector[MFBLOCK_SIZE * 4] = {0};
if (mfReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, ndefkey, vsector)) {
if (mfReadSector(i, keyB ? MF_KEY_B : MF_KEY_A, ndefkey, vsector)) {
PrintAndLogEx(ERR, "error, reading sector %d ", i + 1);
return PM3_ESOFT;
}
@ -5675,7 +5675,7 @@ int CmdHFMFNDEFRead(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "");
if (!datalen) {
if (datalen == 0) {
PrintAndLogEx(WARNING, "no NDEF data");
return PM3_SUCCESS;
}
@ -5696,7 +5696,9 @@ int CmdHFMFNDEFRead(const char *Cmd) {
res = NDEFRecordsDecodeAndPrint(data, datalen);
}
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -vv`") " for more details");
if (verbose2 == false) {
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -vv`") " for more details");
}
return PM3_SUCCESS;
}

View file

@ -188,7 +188,7 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
if (sector0 == NULL)
return PM3_EINVARG;
uint8_t GPB = sector0[3 * 16 + 9];
uint8_t GPB = sector0[(3 * 16) + 9];
if (verbose)
PrintAndLogEx(SUCCESS, "%14s " _GREEN_("0x%02x"), "GPB", GPB);