Skip to content

Commit

Permalink
ATS printing can be an issue since some magic cards doesnt treat ATS …
Browse files Browse the repository at this point in the history
…properly. This will lessen the garbage output
  • Loading branch information
iceman1001 committed Sep 13, 2024
1 parent cd0ce47 commit 65cf65d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
- Changed `hf mf info` - Better handling when printing ATS (@iceman1001)
- Changed to also try the MFC_B key when extracting memory (@iceman1001)
- Fix parallel `make -j check` Thanks @elboulangero (@iceman1001)
- Added support for 8268/8310 (@douniwan5788)
Expand Down
4 changes: 2 additions & 2 deletions client/src/cmdhfcryptorf.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static bool get_14b_UID(iso14b_card_select_t *card) {
} // retry

if (retry <= 0) {
PrintAndLogEx(FAILED, "command execution timeout");
PrintAndLogEx(FAILED, "command execution time out");
}

return false;
Expand All @@ -145,7 +145,7 @@ static int infoHFCryptoRF(bool verbose) {
PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) {
if (verbose) {
PrintAndLogEx(WARNING, "command execution timeout");
PrintAndLogEx(WARNING, "command execution time out");
}
switch_off_field_cryptorf();
return false;
Expand Down
21 changes: 17 additions & 4 deletions client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7555,9 +7555,9 @@ static int CmdHF14AMfWipe(const char *Cmd) {
char *fptr;
if (keyfnlen == 0) {
fptr = GenerateFilename("hf-mf-", "-key.bin");
if (fptr == NULL)
if (fptr == NULL) {
return PM3_ESOFT;

}
strncpy(keyFilename, fptr, sizeof(keyFilename) - 1);
free(fptr);
}
Expand Down Expand Up @@ -7585,7 +7585,7 @@ static int CmdHF14AMfWipe(const char *Cmd) {
}
case (MIFARE_1K_EV1_MAX_KEY_SIZE): {
PrintAndLogEx(INFO, "Loaded keys matching MIFARE Classic 1K Ev1");
memcpy(keyA, keys, MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE);
memcpy(keyA, keys, (MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE));
memcpy(keyB, keys + (MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE), (MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE));
num_sectors = NumOfSectors('1');
memcpy(mf, "\x11\x22\x33\x44\x44\x08\x04\x00\x62\x63\x64\x65\x66\x67\x68\x69", MFBLOCK_SIZE);
Expand Down Expand Up @@ -7863,14 +7863,27 @@ static int parse_gtu_cfg(uint8_t *d, size_t n) {
break;
}

PrintAndLogEx(INFO, "..............%02X unknown", d[7]);
uint8_t atslen = d[7];
if (atslen == 0) {
PrintAndLogEx(INFO, "..............%02X ATS length %u bytes ( %s )", _YELLOW_("zero"), atslen);
} else if (atslen <= 16) {
PrintAndLogEx(INFO, "..............%02X ATS length %u bytes ( %s )", _GREEN_("ok"), atslen);
} else {
PrintAndLogEx(INFO, "..............%02X ATS length %u bytes ( %s )", _RED_("fail"), atslen);
atslen = 0;
}

PrintAndLogEx(INFO, "");

// ATS seems to have 16 bytes reserved
PrintAndLogEx(INFO, _CYAN_("Config 2 - ATS"));
PrintAndLogEx(INFO, "%s", sprint_hex_inrow(d + 8, 16));
if (atslen <= 16) {
PrintAndLogEx(INFO, "%s.............. ATS ( %d bytes )", sprint_hex_inrow(&d[8], d[7]), d[7]);
PrintAndLogEx(INFO, "..................%s Reserved for ATS", sprint_hex_inrow(d + 8 + d[7], 16 - d[7]));
} else {
PrintAndLogEx(INFO, "%s.............. %s Reserved for ATS", sprint_hex_inrow(&d[8], 16), 16);
}

PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, _CYAN_("Config 3 - Limits"));
Expand Down

0 comments on commit 65cf65d

Please sign in to comment.