diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 95c78d5be..1b2e5ac45 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -1343,26 +1343,24 @@ static int CmdHFiClassDecrypt(const char *Cmd) { if (has_values) { //todo: remove preamble/sentinel - uint32_t top = 0, mid, bot; - mid = bytes_to_num(decrypted + (8 * 7), 4); - bot = bytes_to_num(decrypted + (8 * 7) + 4, 4); + uint32_t top = 0, mid = 0, bot = 0; PrintAndLogEx(INFO, "Block 7 decoder"); char hexstr[16 + 1] = {0}; hex_to_buffer((uint8_t *)hexstr, decrypted + (8 * 7), 8, sizeof(hexstr) - 1, 0, 0, true); + hexstring_to_u96(&top, &mid, &bot, hexstr); - char binstr[8 * 8 + 1] = {0}; + char binstr[64 + 1]; hextobinstring(binstr, hexstr); - size_t i = 0; - while (i < strlen(binstr) && binstr[i++] == '0'); + char *pbin = binstr; + while (strlen(pbin) && *(++pbin) == '0'); - PrintAndLogEx(SUCCESS, "Binary..................... " _GREEN_("%s"), binstr + i); + PrintAndLogEx(SUCCESS, "Binary..................... " _GREEN_("%s"), pbin); PrintAndLogEx(INFO, "Wiegand decode"); - wiegand_message_t packed = initialize_message_object(top, mid, bot, strlen(binstr + i)); + wiegand_message_t packed = initialize_message_object(top, mid, bot, 0); HIDTryUnpack(&packed); - } else { PrintAndLogEx(INFO, "No credential found"); } diff --git a/client/src/cmdwiegand.c b/client/src/cmdwiegand.c index fe6148f4e..0973a9beb 100644 --- a/client/src/cmdwiegand.c +++ b/client/src/cmdwiegand.c @@ -158,6 +158,7 @@ int CmdWiegandDecode(const char *Cmd) { PrintAndLogEx(ERR, "empty input"); return PM3_EINVARG; } + wiegand_message_t packed = initialize_message_object(top, mid, bot, blen); HIDTryUnpack(&packed); return PM3_SUCCESS;