diff --git a/client/cmdhf.c b/client/cmdhf.c index 2465641db..a766388c9 100644 --- a/client/cmdhf.c +++ b/client/cmdhf.c @@ -54,7 +54,7 @@ int CmdHFSearch(const char *Cmd) { PrintAndLogEx(INFO, "Checking for known tags...\n"); - if (infoThinFilm() == PM3_SUCCESS) { + if (infoThinFilm(false) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Thinfilm tag") " found\n"); return 1; } diff --git a/client/cmdhfthinfilm.c b/client/cmdhfthinfilm.c index 0b2642b1b..18a0804ef 100644 --- a/client/cmdhfthinfilm.c +++ b/client/cmdhfthinfilm.c @@ -25,20 +25,19 @@ static int usage_thinfilm_info(void) { // Printing function based upon the code in libnfc // ref // https://github.com/nfc-tools/libnfc/blob/master/utils/nfc-barcode.c -static int print_barcode(uint8_t *barcode, const size_t barcode_len) { +static int print_barcode(uint8_t *barcode, const size_t barcode_len, bool verbose) { PrintAndLogEx(SUCCESS, " Manufacturer : "_YELLOW_("%s") "[0x%02X]", (barcode[0] == 0xB7) ? "Thinfilm" : "unknown", barcode[0]); - PrintAndLogEx(SUCCESS, " Data format : "_YELLOW_("%02X"), barcode[1]); - uint8_t b1, b2; - compute_crc(CRC_14443_A, barcode, barcode_len - 2, &b1, &b2); - bool isok = (barcode[barcode_len - 1] == b1 && barcode[barcode_len - 2] == b2); - - PrintAndLogEx(SUCCESS, " checksum : "_YELLOW_("%02X %02X")"- %s", b2, b1, (isok) ? _GREEN_("OK") : _RED_("fail")); - PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"), - sprint_hex(barcode, barcode_len) - ); + if (verbose) { + uint8_t b1, b2; + compute_crc(CRC_14443_A, barcode, barcode_len - 2, &b1, &b2); + bool isok = (barcode[barcode_len - 1] == b1 && barcode[barcode_len - 2] == b2); + PrintAndLogEx(SUCCESS, " Data format : "_YELLOW_("%02X"), barcode[1]); + PrintAndLogEx(SUCCESS, " checksum : "_YELLOW_("%02X %02X")"- %s", b2, b1, (isok) ? _GREEN_("OK") : _RED_("fail")); + PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"), sprint_hex(barcode, barcode_len)); + } char s[45]; memset(s, 0x00, sizeof(s)); @@ -104,10 +103,10 @@ static int CmdHfThinFilmInfo(const char *Cmd) { return PM3_EINVARG; } - return infoThinFilm(); + return infoThinFilm(true); } -int infoThinFilm(void) { +int infoThinFilm(bool verbose) { clearCommandBuffer(); SendCommandNG(CMD_THINFILM_READ, NULL, 0); @@ -119,7 +118,12 @@ int infoThinFilm(void) { } if (resp.status == PM3_SUCCESS) { - print_barcode(resp.data.asBytes, resp.length); + if (resp.length == 16 || resp.length == 32) { + print_barcode(resp.data.asBytes, resp.length, verbose); + } else { + PrintAndLogEx(WARNING, "Response is wrong length. (%d)", resp.length); + return PM3_ESOFT; + } } return resp.status; diff --git a/client/cmdhfthinfilm.h b/client/cmdhfthinfilm.h index f67084cbd..defe674aa 100644 --- a/client/cmdhfthinfilm.h +++ b/client/cmdhfthinfilm.h @@ -21,7 +21,7 @@ #include "util.h" #include "cmdhf.h" // list cmd -int infoThinFilm(void); +int infoThinFilm(bool verbose); int CmdHFThinfilm(const char *Cmd);