Skip to content

Commit

Permalink
Merge pull request #2162 from merlokk/ginfo_add
Browse files Browse the repository at this point in the history
Ginfo add some additional info
  • Loading branch information
merlokk authored Nov 6, 2023
2 parents 1e893f8 + f617cac commit 7692f09
Showing 1 changed file with 112 additions and 9 deletions.
121 changes: 112 additions & 9 deletions client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7453,7 +7453,7 @@ static int CmdHF14AGen4Info(const char *cmd) {

int pwd_len = 0;
uint8_t pwd[4] = {0};
CLIGetHexWithReturn(ctx, 3, pwd, &pwd_len);
CLIGetHexWithReturn(ctx, 2, pwd, &pwd_len);
CLIParserFree(ctx);

if (pwd_len != 0 && pwd_len != 4) {
Expand Down Expand Up @@ -7481,22 +7481,103 @@ static int CmdHF14AGen4Info(const char *cmd) {
if (verbose)
PrintAndLogEx(INFO, "Raw config [%02d]..... %s", resplen, sprint_hex_inrow(resp, resplen));

PrintAndLogEx(INFO, "UL protocol......... %02x", resp[0]);
PrintAndLogEx(INFO, "UID length.......... %02x", resp[1]);
PrintAndLogEx(INFO, "UL protocol......... %02x" NOLF, resp[0]);
switch (resp[0]){
case 0x00:
PrintAndLogEx(NORMAL, " (MIFARE Classic mode)");
break;
case 0x01:
PrintAndLogEx(NORMAL, " (MIFARE Ultralight/NTAG mode)");
break;
default:
PrintAndLogEx(NORMAL, " (unknown %02x)", resp[0]);
break;
}

uint8_t uid_len = resp[1];
PrintAndLogEx(INFO, "UID length.......... %02x" NOLF, resp[1]);
switch (resp[1]){
case 0x00:
PrintAndLogEx(NORMAL, " (4 byte)");
break;
case 0x01:
PrintAndLogEx(NORMAL, " (7 byte)");
break;
case 0x02:
PrintAndLogEx(NORMAL, " (10 byte)");
break;
default:
PrintAndLogEx(NORMAL, " (unknown %02x)", resp[1]);
break;
}

PrintAndLogEx(INFO, "Password............ %s", sprint_hex_inrow(&resp[2], 4));
PrintAndLogEx(INFO, "GTU mode............ %02x", resp[6]);

PrintAndLogEx(INFO, "GTU mode............ %02x" NOLF, resp[6]);
switch (resp[6]){
case 0x00:
PrintAndLogEx(NORMAL, " (pre-write, shadow data can be written)");
break;
case 0x01:
PrintAndLogEx(NORMAL, " (restore mode)");
break;
case 0x02:
PrintAndLogEx(NORMAL, " (disabled)");
break;
case 0x03:
PrintAndLogEx(NORMAL, " (disabled, high speed R/W mode for Ultralight?)");
break;
default:
PrintAndLogEx(NORMAL, " (unknown %02x)", resp[6]);
break;
}

PrintAndLogEx(INFO, "ATS [%02d]............ %s", resp[7], sprint_hex_inrow(&resp[8], resp[7]));
PrintAndLogEx(INFO, "ATQA................ %02x%02x", resp[24], resp[25]);
PrintAndLogEx(INFO, "ATQA................ %02x%02x", resp[25], resp[24]);
PrintAndLogEx(INFO, "SAK................. %02x", resp[26]);
PrintAndLogEx(INFO, "UL mode............. %02x", resp[27]);
PrintAndLogEx(INFO, "max rd/wr sectors... %02x", resp[28]);
PrintAndLogEx(INFO, "block0 direct wr.... %02x", resp[29]);

PrintAndLogEx(INFO, "UL mode............. %02x" NOLF, resp[27]);
switch (resp[27]){
case 0x00:
PrintAndLogEx(NORMAL, " (UL EV1)");
break;
case 0x01:
PrintAndLogEx(NORMAL, " (NTAG)");
break;
case 0x02:
PrintAndLogEx(NORMAL, " (UL-C)");
break;
case 0x03:
PrintAndLogEx(NORMAL, " (UL)");
break;
default:
PrintAndLogEx(NORMAL, " (unknown %02x)", resp[27]);
break;
}

PrintAndLogEx(INFO, "max rd/wr sectors... %02x", resp[28]);
PrintAndLogEx(INFO, "block0 direct wr.... %02x" NOLF, resp[29]);
switch (resp[29]){
case 0x00:
PrintAndLogEx(NORMAL, " (Activate direct write to block 0 (Same behaviour of Gen2 cards. Some readers may identify the card as magic))");
break;
case 0x01:
PrintAndLogEx(NORMAL, " (Deactivate direct write to block 0 (Same behaviour of vanilla cards))");
break;
case 0x02:
PrintAndLogEx(NORMAL, " (Default value. Same behaviour as 00?");
break;
default:
PrintAndLogEx(NORMAL, " (unknown %02x)", resp[29]);
break;
}

res = mfG4GetFactoryTest(pwd, resp, &resplen, false);
if (res == PM3_SUCCESS && resplen > 2) {
if (verbose)
if (verbose) {
PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, "Raw test [%02d]....... %s", resplen, sprint_hex_inrow(resp, resplen));
}

if (resp[resplen - 2] == 0x66 && resp[resplen - 1] == 0x66)
PrintAndLogEx(INFO, "Card type........... generic");
Expand All @@ -7508,6 +7589,28 @@ static int CmdHF14AGen4Info(const char *cmd) {
PrintAndLogEx(INFO, "Card type........... unknown %02x%02x", resp[resplen - 2], resp[resplen - 1]);
}

// read block 0
res = mfG4GetBlock(pwd, 0, resp, MAGIC_INIT | MAGIC_OFF);
if (res == PM3_SUCCESS) {
PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, "Block 0............. %s", sprint_hex_inrow(resp, 16));

switch (uid_len){
case 0x00:
PrintAndLogEx(INFO, "UID [4]............. %s", sprint_hex(resp, 4));
break;
case 0x01:
PrintAndLogEx(INFO, "UID [7]............. %s", sprint_hex(resp, 7));
break;
case 0x02:
PrintAndLogEx(INFO, "UID [10]............ %s", sprint_hex(resp, 10));
break;
default:
break;
}
}


return PM3_SUCCESS;
}

Expand Down

0 comments on commit 7692f09

Please sign in to comment.