mirror of
				https://github.com/RfidResearchGroup/proxmark3.git
				synced 2025-11-04 11:38:03 +08:00 
			
		
		
		
	text
This commit is contained in:
		
							parent
							
								
									6eaff873ba
								
							
						
					
					
						commit
						c27264e4c4
					
				
					 15 changed files with 68 additions and 51 deletions
				
			
		| 
						 | 
				
			
			@ -894,7 +894,7 @@ static int CmdAutoCorr(const char *Cmd) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (window >= g_GraphTraceLen) {
 | 
			
		||||
        PrintAndLogEx(WARNING, "window must be smaller than trace (" _YELLOW_("%zu") " samples)", g_GraphTraceLen);
 | 
			
		||||
        PrintAndLogEx(WARNING, "window must be smaller than trace ( " _YELLOW_("%zu") " samples )", g_GraphTraceLen);
 | 
			
		||||
        return PM3_EINVARG;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1377,7 +1377,7 @@ static int CmdHF15Dump(const char *Cmd) {
 | 
			
		|||
 | 
			
		||||
            if (CheckCrc15(recv, resp.length) == false) {
 | 
			
		||||
                PrintAndLogEx(NORMAL, "");
 | 
			
		||||
                PrintAndLogEx(FAILED, "crc (" _RED_("fail") ")");
 | 
			
		||||
                PrintAndLogEx(FAILED, "crc ( " _RED_("fail") " )");
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1603,7 +1603,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
 | 
			
		|||
    uint8_t *data = resp.data.asBytes;
 | 
			
		||||
 | 
			
		||||
    if (CheckCrc15(data, resp.length) == false) {
 | 
			
		||||
        PrintAndLogEx(FAILED, "crc (" _RED_("fail") ")");
 | 
			
		||||
        PrintAndLogEx(FAILED, "crc ( " _RED_("fail") " )");
 | 
			
		||||
        return PM3_ESOFT;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1734,7 +1734,7 @@ static int CmdHF15Readblock(const char *Cmd) {
 | 
			
		|||
    uint8_t *data = resp.data.asBytes;
 | 
			
		||||
 | 
			
		||||
    if (CheckCrc15(data, resp.length) == false) {
 | 
			
		||||
        PrintAndLogEx(FAILED, "crc (" _RED_("fail") ")");
 | 
			
		||||
        PrintAndLogEx(FAILED, "crc ( " _RED_("fail") " )");
 | 
			
		||||
        return PM3_ESOFT;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1785,7 +1785,7 @@ static int hf_15_write_blk(bool verbose, bool fast, uint8_t *req, uint8_t reqlen
 | 
			
		|||
    uint8_t *recv = resp.data.asBytes;
 | 
			
		||||
    if (CheckCrc15(recv, resp.length) == false) {
 | 
			
		||||
        if (verbose) {
 | 
			
		||||
            PrintAndLogEx(FAILED, "crc (" _RED_("fail") ")");
 | 
			
		||||
            PrintAndLogEx(FAILED, "crc ( " _RED_("fail") " )");
 | 
			
		||||
        }
 | 
			
		||||
        return PM3_ESOFT;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -2103,10 +2103,10 @@ static int CmdHF15CSetUID(const char *Cmd) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (memcmp(revuid, payload.uid, 8) != 0) {
 | 
			
		||||
        PrintAndLogEx(FAILED, "setting new UID (" _RED_("failed") ")");
 | 
			
		||||
        PrintAndLogEx(FAILED, "setting new UID ( " _RED_("fail") " )");
 | 
			
		||||
        return PM3_ESOFT;
 | 
			
		||||
    } else {
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "setting new UID (" _GREEN_("ok") ")");
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "setting new UID ( " _GREEN_("ok") " )");
 | 
			
		||||
        return PM3_SUCCESS;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -639,7 +639,7 @@ static int CmdHFFidoAuthenticate(const char *cmd) {
 | 
			
		|||
                    PrintAndLogEx(WARNING, "Other signature check error: %x %s", (res < 0) ? -res : res, ecdsa_get_error(res));
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                PrintAndLogEx(SUCCESS, "Signature is (" _GREEN_("ok") " )");
 | 
			
		||||
                PrintAndLogEx(SUCCESS, "Signature is ( " _GREEN_("ok") " )");
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            PrintAndLogEx(WARNING, "No public key provided. can't check signature.");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -841,7 +841,7 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q
 | 
			
		|||
 | 
			
		||||
        if (verbose) {
 | 
			
		||||
            if (region_code > 0 || facility_code > 0 || current_aid > 0) {
 | 
			
		||||
                PrintAndLogEx(INFO, "Reading AID: " _YELLOW_("%06X") ", region: " _YELLOW_("%c") " (" _YELLOW_("%u") "), facility: " _YELLOW_("%u"),
 | 
			
		||||
                PrintAndLogEx(INFO, "Reading AID: " _YELLOW_("%06X") ", region: " _YELLOW_("%c") " ( " _YELLOW_("%u") " ), facility: " _YELLOW_("%u"),
 | 
			
		||||
                              current_aid,
 | 
			
		||||
                              'A' + region_code,
 | 
			
		||||
                              region_code,
 | 
			
		||||
| 
						 | 
				
			
			@ -861,7 +861,7 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q
 | 
			
		|||
        }
 | 
			
		||||
        PM3_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials");
 | 
			
		||||
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%c") " (" _GREEN_("%u") ")"
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )"
 | 
			
		||||
                      ", facility: " _GREEN_("%u")
 | 
			
		||||
                      ", card number: " _GREEN_("%u")
 | 
			
		||||
                      ", issue level: " _GREEN_("%u"),
 | 
			
		||||
| 
						 | 
				
			
			@ -1298,7 +1298,7 @@ static int CmdGallagherDecode(const char *cmd) {
 | 
			
		|||
    GallagherCredentials_t creds = {0};
 | 
			
		||||
    gallagher_decode_creds(data_buf, &creds);
 | 
			
		||||
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "Gallagher - region: " _GREEN_("%c") " (" _GREEN_("%u") ")"
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "Gallagher - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )"
 | 
			
		||||
                  ", facility: " _GREEN_("%u")
 | 
			
		||||
                  ", card number: " _GREEN_("%u")
 | 
			
		||||
                  ", issue level: " _GREEN_("%u"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5150,7 +5150,7 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
 | 
			
		|||
    if (resp.status == PM3_SUCCESS)
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "Change ( " _GREEN_("ok") " )");
 | 
			
		||||
    else
 | 
			
		||||
        PrintAndLogEx(FAILED, "Change (" _GREEN_("fail") " )");
 | 
			
		||||
        PrintAndLogEx(FAILED, "Change ( " _RED_("fail") " )");
 | 
			
		||||
 | 
			
		||||
    return resp.status;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,9 +65,9 @@ static char *getCardSizeStr(uint8_t fsize) {
 | 
			
		|||
 | 
			
		||||
    // is  LSB set?
 | 
			
		||||
    if (fsize & 1)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X (" _GREEN_("%d - %d bytes") ")", fsize, usize, lsize);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X ( " _GREEN_("%d - %d bytes") " )", fsize, usize, lsize);
 | 
			
		||||
    else
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X (" _GREEN_("%d bytes") ")", fsize, lsize);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X ( " _GREEN_("%d bytes") " )", fsize, lsize);
 | 
			
		||||
    return buf;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -77,14 +77,14 @@ static char *getProtocolStr(uint8_t id, bool hw) {
 | 
			
		|||
    char *retStr = buf;
 | 
			
		||||
 | 
			
		||||
    if (id == 0x04) {
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("ISO 14443-3 MIFARE, 14443-4") ")", id);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("ISO 14443-3 MIFARE, 14443-4") " )", id);
 | 
			
		||||
    } else if (id == 0x05) {
 | 
			
		||||
        if (hw)
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("ISO 14443-2, 14443-3") ")", id);
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("ISO 14443-2, 14443-3") " )", id);
 | 
			
		||||
        else
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("ISO 14443-3, 14443-4") ")", id);
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("ISO 14443-3, 14443-4") " )", id);
 | 
			
		||||
    } else {
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("Unknown") ")", id);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("Unknown") " )", id);
 | 
			
		||||
    }
 | 
			
		||||
    return buf;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -95,19 +95,19 @@ static char *getVersionStr(uint8_t major, uint8_t minor) {
 | 
			
		|||
    char *retStr = buf;
 | 
			
		||||
 | 
			
		||||
    if (major == 0x00)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _GREEN_("DESFire MF3ICD40") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire MF3ICD40") " )", major, minor);
 | 
			
		||||
    else if (major == 0x01 && minor == 0x00)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _GREEN_("DESFire EV1") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV1") " )", major, minor);
 | 
			
		||||
    else if (major == 0x12 && minor == 0x00)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _GREEN_("DESFire EV2") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV2") " )", major, minor);
 | 
			
		||||
    else if (major == 0x33 && minor == 0x00)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _GREEN_("DESFire EV3") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV3") " )", major, minor);
 | 
			
		||||
    else if (major == 0x30 && minor == 0x00)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _GREEN_("DESFire Light") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire Light") " )", major, minor);
 | 
			
		||||
    else if (major == 0x11 && minor == 0x00)
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _GREEN_("Plus EV1") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("Plus EV1") " )", major, minor);
 | 
			
		||||
    else
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x (" _YELLOW_("Unknown") ")", major, minor);
 | 
			
		||||
        snprintf(retStr, sizeof(buf), "%x.%x ( " _YELLOW_("Unknown") " )", major, minor);
 | 
			
		||||
    return buf;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -118,16 +118,16 @@ static char *getTypeStr(uint8_t type) {
 | 
			
		|||
 | 
			
		||||
    switch (type) {
 | 
			
		||||
        case 1:
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("DESFire") ")", type);
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("DESFire") " )", type);
 | 
			
		||||
            break;
 | 
			
		||||
        case 2:
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("Plus") ")", type);
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("Plus") " )", type);
 | 
			
		||||
            break;
 | 
			
		||||
        case 3:
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("Ultralight") ")", type);
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("Ultralight") " )", type);
 | 
			
		||||
            break;
 | 
			
		||||
        case 4:
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X (" _YELLOW_("NTAG") ")", type);
 | 
			
		||||
            snprintf(retStr, sizeof(buf), "0x%02X ( " _YELLOW_("NTAG") " )", type);
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
| 
						 | 
				
			
			@ -513,8 +513,8 @@ static int CmdHFMFPWritePerso(const char *Cmd) {
 | 
			
		|||
        PrintAndLogEx(ERR, "Command error: %02x %s", data[0], mfpGetErrorDescription(data[0]));
 | 
			
		||||
        return PM3_ESOFT;
 | 
			
		||||
    }
 | 
			
		||||
    PrintAndLogEx(INFO, "Write (" _GREEN_("ok") " )");
 | 
			
		||||
 | 
			
		||||
    PrintAndLogEx(INFO, "Write ( " _GREEN_("ok") " )");
 | 
			
		||||
    return PM3_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ static void print_st25ta_system_info(uint8_t *d, uint8_t n) {
 | 
			
		|||
    PrintAndLogEx(SUCCESS, "------------ " _CYAN_("ST System file") " ------------");
 | 
			
		||||
 | 
			
		||||
    uint16_t len = (d[0] << 8 | d[1]);
 | 
			
		||||
    PrintAndLogEx(SUCCESS, " len      %u bytes (" _GREEN_("0x%04X") ")", len, len);
 | 
			
		||||
    PrintAndLogEx(SUCCESS, " len      %u bytes ( " _GREEN_("0x%04X") " )", len, len);
 | 
			
		||||
 | 
			
		||||
    if (d[2] == 0x80) {
 | 
			
		||||
        PrintAndLogEx(SUCCESS, " ST reserved  ( 0x%02X )", d[2]);
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ static void print_st25ta_system_info(uint8_t *d, uint8_t n) {
 | 
			
		|||
    PrintAndLogEx(SUCCESS, "      Device#  " _YELLOW_("%s"), sprint_hex_inrow(d + 10, 5));
 | 
			
		||||
 | 
			
		||||
    uint16_t mem = (d[0xF] << 8 | d[0x10]);
 | 
			
		||||
    PrintAndLogEx(SUCCESS, " Memory Size - 1   %u bytes (" _GREEN_("0x%04X") ")", mem, mem);
 | 
			
		||||
    PrintAndLogEx(SUCCESS, " Memory Size - 1   %u bytes ( " _GREEN_("0x%04X") " )", mem, mem);
 | 
			
		||||
 | 
			
		||||
    PrintAndLogEx(SUCCESS, " IC Reference code %u ( 0x%02X )", d[0x12], d[0x12]);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -939,7 +939,7 @@ int CmdEM4x50WritePwd(const char *Cmd) {
 | 
			
		|||
        return PM3_SUCCESS;
 | 
			
		||||
 | 
			
		||||
    if (resp.status != PM3_SUCCESS) {
 | 
			
		||||
        PrintAndLogEx(FAILED, "Writing password (" _RED_("failed") ")");
 | 
			
		||||
        PrintAndLogEx(FAILED, "Writing password ( " _RED_("fail") " )");
 | 
			
		||||
        return PM3_EFAILED;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ static int lf_search_plus(const char *Cmd) {
 | 
			
		|||
        // Try to change config!
 | 
			
		||||
        uint32_t d;
 | 
			
		||||
        d = config.divisor = default_divisor[i];
 | 
			
		||||
        PrintAndLogEx(INFO, "-->  trying  (" _GREEN_("%d.%02d kHz")")", 12000 / (d + 1), ((1200000 + (d + 1) / 2) / (d + 1)) - ((12000 / (d + 1)) * 100));
 | 
			
		||||
        PrintAndLogEx(INFO, "-->  trying  ( " _GREEN_("%d.%02d kHz")" )", 12000 / (d + 1), ((1200000 + (d + 1) / 2) / (d + 1)) - ((12000 / (d + 1)) * 100));
 | 
			
		||||
 | 
			
		||||
        retval = lf_config(&config);
 | 
			
		||||
        if (retval != PM3_SUCCESS)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ static int test_genkey(unsigned int keylength, unsigned char *msg, size_t msg_le
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    free(tmp2);
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "passed (" _GREEN_("%" PRIu64) " ms)", msclock() - ms);
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "passed ( " _GREEN_("%" PRIu64) " ms )", msclock() - ms);
 | 
			
		||||
 | 
			
		||||
free_tmp:
 | 
			
		||||
    free(tmp);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -290,9 +290,9 @@ int testMAC(void) {
 | 
			
		|||
    doMAC(cc_nr, div_key, calculated_mac);
 | 
			
		||||
 | 
			
		||||
    if (memcmp(calculated_mac, correct_MAC, 4) == 0) {
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    MAC calculation (%s)", _GREEN_("ok"));
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    MAC calculation ( %s )", _GREEN_("ok"));
 | 
			
		||||
    } else {
 | 
			
		||||
        PrintAndLogEx(FAILED, "    MAC calculation (%s)", _RED_("failed"));
 | 
			
		||||
        PrintAndLogEx(FAILED, "    MAC calculation ( %s )", _RED_("fail"));
 | 
			
		||||
        printarr("    Calculated_MAC", calculated_mac, 4);
 | 
			
		||||
        printarr("    Correct_MAC   ", correct_MAC, 4);
 | 
			
		||||
        return PM3_ESOFT;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -198,9 +198,9 @@ static int testBitStream(void) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (memcmp(input, output, sizeof(input)) == 0) {
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    Bitstream test 1 (%s)", _GREEN_("ok"));
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    Bitstream test 1 ( %s )", _GREEN_("ok"));
 | 
			
		||||
    } else {
 | 
			
		||||
        PrintAndLogEx(FAILED, "    Bitstream test 1 (%s)", _RED_("failed"));
 | 
			
		||||
        PrintAndLogEx(FAILED, "    Bitstream test 1 ( %s )", _RED_("fail"));
 | 
			
		||||
        uint8_t i;
 | 
			
		||||
        for (i = 0 ; i < ARRAYLEN(input) ; i++) {
 | 
			
		||||
            PrintAndLogEx(NORMAL, "    IN %02x, OUT %02x", input[i], output[i]);
 | 
			
		||||
| 
						 | 
				
			
			@ -228,9 +228,9 @@ static int testReversedBitstream(void) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (memcmp(input, output, sizeof(input)) == 0) {
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    Bitstream test 2 (%s)", _GREEN_("ok"));
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    Bitstream test 2 ( %s )", _GREEN_("ok"));
 | 
			
		||||
    } else {
 | 
			
		||||
        PrintAndLogEx(FAILED, "    Bitstream test 2 (%s)", _RED_("failed"));
 | 
			
		||||
        PrintAndLogEx(FAILED, "    Bitstream test 2 ( %s )", _RED_("fail"));
 | 
			
		||||
        uint8_t i;
 | 
			
		||||
        for (i = 0 ; i < ARRAYLEN(input) ; i++) {
 | 
			
		||||
            PrintAndLogEx(NORMAL, "    IN %02x, MIDDLE: %02x, OUT %02x", input[i], reverse[i], output[i]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -707,7 +707,7 @@ int calculateMasterKey(uint8_t first16bytes[], uint8_t kcus[]) {
 | 
			
		|||
    PrintAndLogEx(SUCCESS, "-----  " _CYAN_("High security custom key (Kcus)") " -----");
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "Standard format  %s", sprint_hex(key64_stdformat, 8));
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "iCLASS format    " _GREEN_("%s"), sprint_hex(key64, 8));
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "Key verified (" _GREEN_("ok") ")");
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "Key verified ( " _GREEN_("ok") " )");
 | 
			
		||||
    PrintAndLogEx(NORMAL, "");
 | 
			
		||||
    return PM3_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -758,7 +758,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
 | 
			
		|||
        first16bytes[i] = keytable[i] & 0xFF;
 | 
			
		||||
 | 
			
		||||
        if ((keytable[i] & LOCLASS_CRACKED) != LOCLASS_CRACKED) {
 | 
			
		||||
            PrintAndLogEx(WARNING, "Warning: we are missing byte %d, custom key calculation will fail...", i);
 | 
			
		||||
            PrintAndLogEx(WARNING, "Warning: we are missing byte " _RED_("%d") " , custom key calculation will fail...", i);
 | 
			
		||||
            return PM3_ESOFT;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -849,7 +849,7 @@ static int _test_iclass_key_permutation(void) {
 | 
			
		|||
        return PM3_ESOFT;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "    Iclass key permutation (%s)", _GREEN_("ok"));
 | 
			
		||||
    PrintAndLogEx(SUCCESS, "    Iclass key permutation ( %s )", _GREEN_("ok"));
 | 
			
		||||
    return PM3_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -892,17 +892,17 @@ int testElite(bool slowtests) {
 | 
			
		|||
    hash2(k_cus, keytable);
 | 
			
		||||
    printarr_human_readable("---------------------- Hash2 ----------------------", keytable, sizeof(keytable));
 | 
			
		||||
    if (keytable[3] == 0xA1 && keytable[0x30] == 0xA3 && keytable[0x6F] == 0x95) {
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    hash2 (%s)", _GREEN_("ok"));
 | 
			
		||||
        PrintAndLogEx(SUCCESS, "    hash2 ( %s )", _GREEN_("ok"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int res = PM3_SUCCESS;
 | 
			
		||||
    PrintAndLogEx(INFO, "Testing hash1...");
 | 
			
		||||
    res += _testHash1();
 | 
			
		||||
    PrintAndLogEx((res == PM3_SUCCESS) ? SUCCESS : WARNING, "    hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
 | 
			
		||||
    PrintAndLogEx((res == PM3_SUCCESS) ? SUCCESS : WARNING, "    hash1 ( %s )", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
 | 
			
		||||
 | 
			
		||||
    PrintAndLogEx(INFO, "Testing key diversification...");
 | 
			
		||||
    res += _test_iclass_key_permutation();
 | 
			
		||||
    PrintAndLogEx((res == PM3_SUCCESS) ? SUCCESS : WARNING, "    key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
 | 
			
		||||
    PrintAndLogEx((res == PM3_SUCCESS) ? SUCCESS : WARNING, "    key diversification ( %s )", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
 | 
			
		||||
 | 
			
		||||
    if (slowtests)
 | 
			
		||||
        res += _testBruteforce();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -141,8 +141,25 @@ static uint8_t get_length_from_header(wiegand_message_t *data) {
 | 
			
		|||
        hfmt = data->Top & 0x000FFFFF;
 | 
			
		||||
        len = 64;
 | 
			
		||||
    } else if (data->Mid > 0) { // < 63-32 bits
 | 
			
		||||
        hfmt = data->Mid;
 | 
			
		||||
        len = 32;
 | 
			
		||||
 | 
			
		||||
        // detect HID format b38 set
 | 
			
		||||
        if (data->Mid & 0xFFFFFFC0) {
 | 
			
		||||
            hfmt = data->Mid;
 | 
			
		||||
            len = 32;
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
            printf("hid preamble detected\n");
 | 
			
		||||
            len = 32; 
 | 
			
		||||
 | 
			
		||||
            if ((data->Mid ^ 0x20) == 0) { hfmt = data->Bot; len = 0; } 
 | 
			
		||||
            else if ((data->Mid & 0x10) == 0) { hfmt = data->Mid & 0x1F; } 
 | 
			
		||||
            else if ((data->Mid & 0x08) == 0) { hfmt = data->Mid & 0x0F; } 
 | 
			
		||||
            else if ((data->Mid & 0x04) == 0) { hfmt = data->Mid & 0x07; } 
 | 
			
		||||
            else if ((data->Mid & 0x02) == 0) { hfmt = data->Mid & 0x03; } 
 | 
			
		||||
            else if ((data->Mid & 0x01) == 0) { hfmt = data->Mid & 0x01; } 
 | 
			
		||||
            else { hfmt = data->Mid & 0x3F;} 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    } else {
 | 
			
		||||
        hfmt = data->Bot;
 | 
			
		||||
        len = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -502,11 +502,11 @@ while true; do
 | 
			
		|||
      echo -e "\n${C_BLUE}Testing HF:${C_NC}"
 | 
			
		||||
      if ! CheckExecute "hf mf offline text"               "$CLIENTBIN -c 'hf mf'" "at_enc"; then break; fi
 | 
			
		||||
      if ! CheckExecute slow retry ignore "hf mf hardnested long test"  "$CLIENTBIN -c 'hf mf hardnested -t --tk 000000000000'" "found:"; then break; fi
 | 
			
		||||
      if ! CheckExecute slow "hf iclass loclass long test" "$CLIENTBIN -c 'hf iclass loclass --long'" "verified \(ok\)"; then break; fi
 | 
			
		||||
      if ! CheckExecute slow "hf iclass loclass long test" "$CLIENTBIN -c 'hf iclass loclass --long'" "verified \( ok \)"; then break; fi
 | 
			
		||||
      if ! CheckExecute slow "emv long test"               "$CLIENTBIN -c 'emv test -l'" "Test\(s\) \[ ok"; then break; fi
 | 
			
		||||
      if ! CheckExecute "hf iclass lookup test"            "$CLIENTBIN -c 'hf iclass lookup --csn 9655a400f8ff12e0 --epurse f0ffffffffffffff --macs 0000000089cb984b -f $DICPATH/iclass_default_keys.dic'" \
 | 
			
		||||
                                                                      "valid key AE A6 84 A6 DA B2 32 78"; then break; fi
 | 
			
		||||
      if ! CheckExecute "hf iclass loclass test"         "$CLIENTBIN -c 'hf iclass loclass --test'" "key diversification \(ok\)"; then break; fi
 | 
			
		||||
      if ! CheckExecute "hf iclass loclass test"         "$CLIENTBIN -c 'hf iclass loclass --test'" "key diversification \( ok \)"; then break; fi
 | 
			
		||||
      if ! CheckExecute "emv test"                       "$CLIENTBIN -c 'emv test'" "Test\(s\) \[ ok"; then break; fi
 | 
			
		||||
      if ! CheckExecute "hf cipurse test"                "$CLIENTBIN -c 'hf cipurse test'" "Tests \[ ok"; then break; fi
 | 
			
		||||
      if ! CheckExecute "hf mfdes test"                  "$CLIENTBIN -c 'hf mfdes test'"   "Tests \[ ok"; then break; fi
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue