From 10504ae4fd9bb584eae642ec7ea05d6f7b7f0412 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 24 Jul 2023 03:15:14 +0200 Subject: [PATCH] text and increasing a buffer --- .../deps/hardnested/hardnested_bruteforce.c | 2 +- client/src/cmdhffido.c | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/client/deps/hardnested/hardnested_bruteforce.c b/client/deps/hardnested/hardnested_bruteforce.c index ee0c1c8f2..6bc400d1d 100644 --- a/client/deps/hardnested/hardnested_bruteforce.c +++ b/client/deps/hardnested/hardnested_bruteforce.c @@ -415,7 +415,7 @@ static bool read_bench_data(statelist_t *test_candidates) { // read 4 bytes of data ? bytes_read = fread(&nonces_to_bruteforce, 1, sizeof(uint32_t), benchfile); - if (bytes_read != sizeof(uint32_t)) { + if (bytes_read != sizeof(uint32_t) || (nonces_to_bruteforce >= 256)) { fclose(benchfile); return false; } diff --git a/client/src/cmdhffido.c b/client/src/cmdhffido.c index a8021e4cf..d3ab66fc6 100644 --- a/client/src/cmdhffido.c +++ b/client/src/cmdhffido.c @@ -78,33 +78,36 @@ static int CmdHFFidoInfo(const char *Cmd) { uint8_t buf[APDU_RES_LEN] = {0}; size_t len = 0; uint16_t sw = 0; - int res = FIDOSelect(true, true, buf, sizeof(buf), &len, &sw); + int res = FIDOSelect(true, true, buf, sizeof(buf), &len, &sw); if (res) { DropField(); return res; } if (sw != ISO7816_OK) { - if (sw) - PrintAndLogEx(INFO, "Not a FIDO card! APDU response: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); - else - PrintAndLogEx(ERR, "APDU exchange error. Card returns 0x0000."); - + if (sw) { + PrintAndLogEx(INFO, "Not a FIDO card. APDU response: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); + } else { + PrintAndLogEx(ERR, "APDU exchange error. Card returns 0x0000"); + } DropField(); return PM3_SUCCESS; } - if (!strncmp((char *)buf, "U2F_V2", 7)) { - if (!strncmp((char *)buf, "FIDO_2_0", 8)) { - PrintAndLogEx(INFO, "FIDO2 authenticator detected. Version... " _YELLOW_("%.*s"), (int)len, buf); + if (strncmp((char *)buf, "U2F_V2", 7) == 0) { + if (strncmp((char *)buf, "FIDO_2_0", 8) == 0) { + PrintAndLogEx(INFO, "FIDO2 authenticator"); + PrintAndLogEx(INFO, "Version... " _YELLOW_("%.*s"), (int)len, buf); } else { - PrintAndLogEx(INFO, "FIDO authenticator detected (not standard U2F)."); - PrintAndLogEx(INFO, "Non U2F authenticator version:"); + PrintAndLogEx(INFO, "FIDO authenticator (not standard U2F)"); + PrintAndLogEx(INFO, "Non U2F authenticator"); + PrintAndLogEx(INFO, "version... "); print_buffer((const unsigned char *)buf, len, 1); } } else { - PrintAndLogEx(INFO, "FIDO U2F authenticator detected. Version... " _YELLOW_("%.*s"), (int)len, buf); + PrintAndLogEx(INFO, "FIDO U2F authenticator detected"); + PrintAndLogEx(INFO, "Version... " _YELLOW_("%.*s"), (int)len, buf); } res = FIDO2GetInfo(buf, sizeof(buf), &len, &sw); @@ -112,6 +115,7 @@ static int CmdHFFidoInfo(const char *Cmd) { if (res) { return res; } + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "FIDO2 version doesn't exist (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); return PM3_SUCCESS; @@ -441,7 +445,7 @@ static int CmdHFFidoAuthenticate(const char *cmd) { controlByte = 0x07; uint8_t data[512] = {0}; - uint8_t hdata[250] = {0}; + uint8_t hdata[256] = {0}; bool public_key_loaded = false; uint8_t public_key[65] = {0}; int hdatalen = 0;