diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index 1890faec2..9bbdbd5c7 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -2133,7 +2133,7 @@ static int iso14443b_select_picopass_card(picopass_hdr_t *hdr) { uint16_t retlen = 0; // first, wake up the tag 0x0A - CodeAndTransmit14443bAsReader(act_all, sizeof(act_all), &start_time, &eof_time, true); + CodeAndTransmit14443bAsReader(act_all, sizeof(act_all), &start_time, &eof_time, true); eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER; // 0x0C @@ -2204,7 +2204,7 @@ static int iso14443b_select_picopass_card(picopass_hdr_t *hdr) { memcpy(hdr->app_issuer_area, resp, sizeof(hdr->app_issuer_area)); // card selected, now read e-purse (cc) (block2) (only 8 bytes no CRC) - start_time = eof_time + ISO14B_TR2; + start_time = eof_time + ISO14B_TR2; CodeAndTransmit14443bAsReader(read_check_cc, sizeof(read_check_cc), &start_time, &eof_time, true); eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER; @@ -2605,7 +2605,7 @@ void SendRawCommand14443B(iso14b_raw_cmd_t *p) { reply_ng(CMD_HF_ISO14443B_COMMAND, status, (uint8_t *)cts, sendlen); if (status != PM3_SUCCESS) goto out; } - + if ((p->flags & ISO14B_SELECT_PICOPASS) == ISO14B_SELECT_PICOPASS) { picopass_hdr_t *hdr = (picopass_hdr_t *)buf; memset(hdr, 0, sizeof(picopass_hdr_t)); @@ -2619,11 +2619,11 @@ void SendRawCommand14443B(iso14b_raw_cmd_t *p) { if ( ((p->flags & ISO14B_APDU) == ISO14B_APDU) || ((p->flags & ISO14B_RAW) == ISO14B_RAW) - ) { + ) { if (s_field_on == false) { DbpString("Field is off"); reply_ng(CMD_HF_ISO14443B_COMMAND, PM3_ERFTRANS, NULL, 0); - goto out; + goto out; } } diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 9ad2e7c00..32b5039f7 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -2554,7 +2554,7 @@ int readHF14B(bool loop, bool verbose) { else if (found) return PM3_SUCCESS; - // Picopass + // Picopass found |= HF14B_picopass_reader(verbose) ; if (found && loop) continue; diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 41c5d8732..55ae1c028 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1312,31 +1312,31 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize, boo // suppress repeating blocks, truncate as such that the first and last block with the same data is shown // but the blocks in between are replaced with a single line of "......" if dense_output is enabled - if ( dense_output && - (i > 6) && - (i < (blocks - 1)) && - (in_repeated_block == false) && - (memcmp(blk, blk - blocksize, blocksize) == 0) && - (memcmp(blk, blk + blocksize, blocksize) == 0) && - (memcmp(blk, blk + (blocksize * 2), blocksize) == 0) - ) { + if (dense_output && + (i > 6) && + (i < (blocks - 1)) && + (in_repeated_block == false) && + (memcmp(blk, blk - blocksize, blocksize) == 0) && + (memcmp(blk, blk + blocksize, blocksize) == 0) && + (memcmp(blk, blk + (blocksize * 2), blocksize) == 0) + ) { // we're in a user block that isn't the first user block nor last two user blocks, // and the current block data is the same as the previous and next two block in_repeated_block = true; PrintAndLogEx(INFO, " ......"); - } else if (in_repeated_block && - (memcmp(blk, blk + blocksize, blocksize) || i == blocks) - ) { + } else if (in_repeated_block && + (memcmp(blk, blk + blocksize, blocksize) || i == blocks) + ) { // in a repeating block, but the next block doesn't match anymore, or we're at the end block in_repeated_block = false; } if (in_repeated_block == false) { PrintAndLogEx(INFO, "%4d | %s " - , i - , sprint_hex_ascii(blk, blocksize) - , blocksize - ); + , i + , sprint_hex_ascii(blk, blocksize) + , blocksize + ); } } @@ -1344,10 +1344,10 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize, boo // If there is something left over print it too // This will have a broken layout, but should not happen anyway PrintAndLogEx(INFO, "%4d | %s " - , blocks - , sprint_hex_ascii(data + (blocks * blocksize) - , bytes % blocksize) - ); + , blocks + , sprint_hex_ascii(data + (blocks * blocksize) + , bytes % blocksize) + ); } print_hrule(blocksize); @@ -1372,7 +1372,7 @@ static int CmdHF15EView(const char *Cmd) { CLIExecWithReturn(ctx, Cmd, argtable, true); int blocksize = arg_get_int_def(ctx, 1, 4); int count = arg_get_int_def(ctx, 2, -1); - bool dense_output = (g_session.dense_output || arg_get_lit(ctx, 3)); + bool dense_output = (g_session.dense_output || arg_get_lit(ctx, 3)); CLIParserFree(ctx); // santity checks @@ -1722,9 +1722,9 @@ static int CmdHF15Dump(const char *Cmd) { void *argtable[6 + 5] = {0}; uint8_t arglen = arg_add_default(argtable); argtable[arglen++] = arg_str0("f", "file", "", "Specify a filename for dump file"), - argtable[arglen++] = arg_int0(NULL, "bs", "", "block size (def 4)"), - argtable[arglen++] = arg_lit0(NULL, "ns", "no save to file"), - argtable[arglen++] = arg_lit0("v", "verbose", "verbose output"); + argtable[arglen++] = arg_int0(NULL, "bs", "", "block size (def 4)"), + argtable[arglen++] = arg_lit0(NULL, "ns", "no save to file"), + argtable[arglen++] = arg_lit0("v", "verbose", "verbose output"); argtable[arglen++] = arg_param_end; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -2234,7 +2234,7 @@ static int CmdHF15Readblock(const char *Cmd) { uint8_t arglen = arg_add_default(argtable); argtable[arglen++] = arg_int1("b", "blk", "", "page number (0-255)"); argtable[arglen++] = arg_int0(NULL, "bs", "", "block size (def 4)"), - argtable[arglen++] = arg_lit0("v", "verbose", "verbose output"); + argtable[arglen++] = arg_lit0("v", "verbose", "verbose output"); argtable[arglen++] = arg_param_end; CLIExecWithReturn(ctx, Cmd, argtable, false); diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index cd2876bfa..0308c543e 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -3484,7 +3484,7 @@ static int CmdHF14AMfSmartBrute(const char *Cmd) { if (msclock() - t1 > 0 && keys_checked > 0) { PrintAndLogEx(INFO, "Current cracking speed (keys/s): %lu", keys_checked / ((msclock() - t1) / 1000)); - + t1 = msclock(); keys_checked = 0; } diff --git a/client/src/cmdhfxerox.c b/client/src/cmdhfxerox.c index 5ee2e48f5..3ca77dcad 100644 --- a/client/src/cmdhfxerox.c +++ b/client/src/cmdhfxerox.c @@ -519,7 +519,7 @@ static const xerox_part_t xerox_part_mappings[] = { static const xerox_part_t *get_xerox_part_info(const char *pn) { for (int i = 0; i < ARRAYLEN(xerox_part_mappings); i++) { // Todo: make str_startswith, accept additional "Maximum number of characters to compare" - if(strncmp(pn, xerox_part_mappings[i].partnumber, strlen(pn)-3) == 0){ + if (strncmp(pn, xerox_part_mappings[i].partnumber, strlen(pn) - 3) == 0) { return &xerox_part_mappings[i]; } } @@ -907,11 +907,11 @@ static int CmdHFXeroxDump(const char *Cmd) { PrintAndLogEx(INFO, "Using UID as filename"); fptr += snprintf(fptr, sizeof(filename), "hf-xerox-"); FillFileNameByUID(fptr - , SwapEndian64(card.uid, card.uidlen, 8) - , (decrypt) ? "-dump-dec" : "-dump" - , card.uidlen - ); -} + , SwapEndian64(card.uid, card.uidlen, 8) + , (decrypt) ? "-dump-dec" : "-dump" + , card.uidlen + ); + } pm3_save_dump(filename, data, blockno * XEROX_BLOCK_SIZE, jsf14b_v2); return PM3_SUCCESS; diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index 5a46e9150..9bc48b8ec 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -674,7 +674,7 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { PrintAndLogEx(INFO, "Default read..... " _YELLOW_("%u") " blocks", numblks); PrintAndLogEx(INFO, "Last word read... " _YELLOW_("%u") " th block", LWR); - uint8_t bits[32+1] = {0}; + uint8_t bits[32 + 1] = {0}; num_to_bytebitsLSBF(wordData, 32, bits); const char *bs = sprint_bytebits_bin(bits, 32); @@ -693,13 +693,13 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { if (card_type == EM_4369 || card_type == EM_4469) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 10, 2, cf)); } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (PSKcf) ? C_RED : C_NONE, bs, 32, 10, 2, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((PSKcf) ? C_RED : C_NONE, bs, 32, 10, 2, "Must be 0")); } if (card_type == EM_4305) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 12, 2, "Delayed ON")); } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (delay) ? C_RED : C_NONE, bs, 32, 12, 2, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((delay) ? C_RED : C_NONE, bs, 32, 12, 2, "Must be 0")); } PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 14, 4, "LWR, Last default read word ")); @@ -717,7 +717,7 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_GREEN, bs, 32, 19, 1, "Read HK, not required")); } } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (readHKL) ? C_RED : C_NONE, bs, 32, 19, 1, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((readHKL) ? C_RED : C_NONE, bs, 32, 19, 1, "Must be 0")); } if (writeLogin) { @@ -733,7 +733,7 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 21, 1, "Write HK, login not required")); } } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (writeHKL) ? C_RED : C_NONE, bs, 32, 21, 1, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((writeHKL) ? C_RED : C_NONE, bs, 32, 21, 1, "Must be 0")); } if (card_type == EM_4369 || card_type == EM_4469) { @@ -743,7 +743,7 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 22, 1, "Read after write is OFF")); } } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (raw) ? C_RED : C_NONE, bs, 32, 22, 1, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((raw) ? C_RED : C_NONE, bs, 32, 22, 1, "Must be 0")); } if (disable) { @@ -765,7 +765,7 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 25, 1, "Invert data? no")); } } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (invert) ? C_RED : C_NONE, bs, 32, 25, 1, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((invert) ? C_RED : C_NONE, bs, 32, 25, 1, "Must be 0")); } if (card_type == EM_4305) { @@ -775,7 +775,7 @@ static void printEM4x05config(em_tech_type_t card_type, uint32_t wordData) { PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 26, 1, "Pigeon mode disabled")); } } else { - PrintAndLogEx(INFO, "%s", sprint_breakdown_bin( (pigeon) ? C_RED : C_NONE, bs, 32, 26, 1, "Must be 0")); + PrintAndLogEx(INFO, "%s", sprint_breakdown_bin((pigeon) ? C_RED : C_NONE, bs, 32, 26, 1, "Must be 0")); } PrintAndLogEx(INFO, "%s", sprint_breakdown_bin(C_NONE, bs, 32, 27, 5, "RFU, Reserved for future use")); @@ -865,7 +865,7 @@ static bool is_cancelled(void) { return false; } -static void em4x05_print_hdr(void) { +static void em4x05_print_hdr(void) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "Addr | data | ascii |lck| info"); PrintAndLogEx(INFO, "-----+----------+-------+---+-----"); @@ -873,7 +873,7 @@ static void em4x05_print_hdr(void) { static void em4x05_print_footer(void) { PrintAndLogEx(INFO, "-----+----------+-------+---+-----"); - PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, ""); } static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) { @@ -883,10 +883,10 @@ static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) return; } - uint32_t *d = (uint32_t*)data; + uint32_t *d = (uint32_t *)data; uint8_t i; - for (i = 0; i< (dlen >> 2); i++) { + for (i = 0; i < (dlen >> 2); i++) { d[i] = BSWAP_32(d[i]); } i = 0; @@ -903,7 +903,7 @@ static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) if ((d[EM4305_PROT1_BLOCK] & 0x00008000) != 0x00) { got_lock_bits = true; lock = d[EM4305_PROT1_BLOCK]; - } else if ((d[EM4305_PROT2_BLOCK] & 0x00008000) != 0x00) { + } else if ((d[EM4305_PROT2_BLOCK] & 0x00008000) != 0x00) { // assume block 15 is the current lock block p15_active = true; got_lock_bits = true; @@ -917,32 +917,32 @@ static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) // hack: since sprint_ascii doesnt handle MSB/LSB swaps reverse_array_copy(data + (i * EM4X05_BLOCK_SIZE), EM4X05_BLOCK_SIZE, rev); - + if (i == EM_SERIAL_BLOCK) { PrintAndLogEx(INFO, " %02u | " _GREEN_("%08X") " | %s | %s | " _GREEN_("%s") - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - ); - } else if ( i == EM_CONFIG_BLOCK) { + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + ); + } else if (i == EM_CONFIG_BLOCK) { PrintAndLogEx(INFO, " %02u | " _YELLOW_("%08X") " | %s | %s | " _YELLOW_("%s") - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + ); } else { PrintAndLogEx(INFO, " %02u | %08X | %s | %s | %s" - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + ); } } @@ -955,22 +955,22 @@ static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) if (p15_active) { PrintAndLogEx(INFO, " %02u | %08X | %s | %s | %-10s %s" - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - , "" - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + , "" + ); } else { PrintAndLogEx(INFO, " %02u | " _GREEN_("%08X") " | %s | %s | %-10s %s" - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - , _GREEN_("active") - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + , _GREEN_("active") + ); } i = 15; @@ -980,22 +980,22 @@ static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) if (p15_active) { PrintAndLogEx(INFO, " %02u | " _GREEN_("%08X") " | %s | %s | %-10s %s" - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - , _GREEN_("active") - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + , _GREEN_("active") + ); } else { PrintAndLogEx(INFO, " %02u | %08X | %s | %s | %-10s %s" - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x05_annotation[i] - , "" - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x05_annotation[i] + , "" + ); } } @@ -1011,28 +1011,28 @@ static void em4x05_print_blocks(uint32_t cardtype, uint8_t *data, uint8_t dlen) if (i == EM_SERIAL_BLOCK) { PrintAndLogEx(INFO, " %02u | " _GREEN_("%08X") " | %s | %s | " _GREEN_("%s") - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x69_annotation[i] - ); - } else if ( i == EM_CONFIG_BLOCK) { + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x69_annotation[i] + ); + } else if (i == EM_CONFIG_BLOCK) { PrintAndLogEx(INFO, " %02u | " _YELLOW_("%08X") " | %s | %s | " _YELLOW_("%s") - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x69_annotation[i] - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x69_annotation[i] + ); } else { PrintAndLogEx(INFO, " %02u | %08X | %s | %s | %s" - , i - , d[i] - , sprint_ascii(rev, EM4X05_BLOCK_SIZE) - , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") - , em4x69_annotation[i] - ); + , i + , d[i] + , sprint_ascii(rev, EM4X05_BLOCK_SIZE) + , (got_lock_bits) ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?") + , em4x69_annotation[i] + ); } } } @@ -2473,12 +2473,12 @@ int CmdEM4x05Sniff(const char *Cmd) { static int CmdEM4x05View(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "lf em ex05 view", - "Print a EM4205/4305/4369/4469 dump file (bin/eml/json)\n" - "note:\n" - "We don't track if password is known in current dump file formats.\n" - "All zeros password block might be filler data", - "lf em 4x05 view -f lf-4x05-01020304-dump.json" - ); + "Print a EM4205/4305/4369/4469 dump file (bin/eml/json)\n" + "note:\n" + "We don't track if password is known in current dump file formats.\n" + "All zeros password block might be filler data", + "lf em 4x05 view -f lf-4x05-01020304-dump.json" + ); void *argtable[] = { arg_param_begin, arg_str1("f", "file", "", "Specify a filename for dump file"), diff --git a/client/src/cmdlfidteck.c b/client/src/cmdlfidteck.c index edd5701ab..b8623a1c7 100644 --- a/client/src/cmdlfidteck.c +++ b/client/src/cmdlfidteck.c @@ -82,7 +82,7 @@ static int demod_idteck_signal(void) { } } setDemodBuff(g_DemodBuffer, 64, idx); - return PM3_SUCCESS; + return PM3_SUCCESS; } int demodIdteck(uint8_t *raw, bool verbose) { @@ -110,7 +110,7 @@ int demodIdteck(uint8_t *raw, bool verbose) { if (raw1 != 0x4944544B) { PrintAndLogEx(FAILED, "No genuine IDTECK found"); } - + // parity check (TBD) uint32_t tmp = raw2; @@ -120,20 +120,20 @@ int demodIdteck(uint8_t *raw, bool verbose) { // So, first byte is Csum uint8_t chksum = ((tmp >> 24) & 0xFF); uint8_t calc = ((tmp >> 16) & 0xFF) + - ((tmp >> 8) & 0xFF) + - (tmp & 0xFF); - + ((tmp >> 8) & 0xFF) + + (tmp & 0xFF); + id = ((tmp >> 16) & 0xFF) | ((tmp >> 8) & 0xFF) << 8 | (tmp & 0xFF) << 16; // output - PrintAndLogEx(SUCCESS, "IDTECK Tag Found: Card ID " _GREEN_("%u") " ( 0x%06X ) Raw: %08X%08X chksum 0x%02X ( %s )", - id, - id, - raw1, - raw2, - chksum, - (chksum == calc) ? _GREEN_("ok") : _RED_("fail") - ); + PrintAndLogEx(SUCCESS, "IDTECK Tag Found: Card ID " _GREEN_("%u") " ( 0x%06X ) Raw: %08X%08X chksum 0x%02X ( %s )", + id, + id, + raw1, + raw2, + chksum, + (chksum == calc) ? _GREEN_("ok") : _RED_("fail") + ); wiegand_message_t packed = { .Bot = id, diff --git a/client/src/pm3line_vocabulary.h b/client/src/pm3line_vocabulary.h index 73970c9ba..778fc8b40 100644 --- a/client/src/pm3line_vocabulary.h +++ b/client/src/pm3line_vocabulary.h @@ -578,6 +578,7 @@ const static vocabulary_t vocabulary[] = { { 0, "lf em 4x05 read" }, { 1, "lf em 4x05 sniff" }, { 0, "lf em 4x05 unlock" }, + { 1, "lf em 4x05 view" }, { 0, "lf em 4x05 wipe" }, { 0, "lf em 4x05 write" }, { 1, "lf em 4x50 help" }, diff --git a/client/src/util.c b/client/src/util.c index 47f0ce8ba..2cf077fa7 100644 --- a/client/src/util.c +++ b/client/src/util.c @@ -558,7 +558,7 @@ char *sprint_ascii(const uint8_t *data, const size_t len) { return sprint_ascii_ex(data, len, 0); } -char *sprint_breakdown_bin(color_t color, const char* bs, int width, int padn, int bits, const char* msg) { +char *sprint_breakdown_bin(color_t color, const char *bs, int width, int padn, int bits, const char *msg) { if (bs == NULL || width > 32) { return NULL; @@ -577,39 +577,39 @@ char *sprint_breakdown_bin(color_t color, const char* bs, int width, int padn, i switch (color) { case C_GREEN: { snprintf(buf, sizeof(buf), "%.*s" _GREEN_("%.*s") "%.*s - " _GREEN_("%s") - , padn, prepad - , bits, bs + padn - , end, postmarker - , msg - ); + , padn, prepad + , bits, bs + padn + , end, postmarker + , msg + ); break; } case C_RED: { snprintf(buf, sizeof(buf), "%.*s" _RED_("%.*s") "%.*s - " _RED_("%s") - , padn, prepad - , bits, bs + padn - , end, postmarker - , msg - ); + , padn, prepad + , bits, bs + padn + , end, postmarker + , msg + ); break; } case C_YELLOW: { snprintf(buf, sizeof(buf), "%.*s" _YELLOW_("%.*s") "%.*s - " _YELLOW_("%s") - , padn, prepad - , bits, bs + padn - , end, postmarker - , msg - ); + , padn, prepad + , bits, bs + padn + , end, postmarker + , msg + ); break; } case C_NONE: default: { snprintf(buf, sizeof(buf), "%.*s%.*s%.*s - %s" - , padn, prepad - , bits, bs + padn - , end, postmarker - , msg - ); + , padn, prepad + , bits, bs + padn + , end, postmarker + , msg + ); break; } } diff --git a/client/src/util.h b/client/src/util.h index 4dd95175b..226443dab 100644 --- a/client/src/util.h +++ b/client/src/util.h @@ -88,7 +88,7 @@ char *sprint_hex_ascii(const uint8_t *data, const size_t len); char *sprint_ascii(const uint8_t *data, const size_t len); char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_str_len); -char *sprint_breakdown_bin(color_t color, const char* bs, int width, int padn, int bits, const char* msg); +char *sprint_breakdown_bin(color_t color, const char *bs, int width, int padn, int bits, const char *msg); void print_buffer_with_offset(const uint8_t *data, const size_t len, int offset, bool print_header); void print_buffer(const uint8_t *data, const size_t len, int level); diff --git a/common/bruteforce.c b/common/bruteforce.c index 5946a689b..eb3c521b1 100644 --- a/common/bruteforce.c +++ b/common/bruteforce.c @@ -226,18 +226,18 @@ int smart_generator_msb_byte_only(generator_context_t *ctx) { int smart_generator_nibble_sequence(generator_context_t *ctx) { // patterns like A0A1A2A3...F0F1F2F3 // also with offsets - A1A2A3, A2A3A4, etc - // counter1 is high nibble (A, B, C), counter2 is low nibble (0,1, etc) + // counter1 is high nibble (A, B, C), counter2 is low nibble (0,1, etc) - if(ctx->counter1 == 0){ // init values on first generator call + if (ctx->counter1 == 0) { // init values on first generator call ctx->counter1 = 0x0A; } uint8_t key_byte; - - // we substract %2 value because max_offset must be even number - uint8_t max_offset = 10 - (ctx->key_length / 2) - (ctx->key_length/2) % 2; - if(ctx->counter1 == 0x10){ + // we substract %2 value because max_offset must be even number + uint8_t max_offset = 10 - (ctx->key_length / 2) - (ctx->key_length / 2) % 2; + + if (ctx->counter1 == 0x10) { return BF_GENERATOR_END; } @@ -245,16 +245,16 @@ int smart_generator_nibble_sequence(generator_context_t *ctx) { for (key_byte = 0; key_byte < ctx->key_length; key_byte++) { ctx->current_key |= (uint64_t) ctx->counter1 << (((ctx->key_length - key_byte - 1) * 8) + 4); - ctx->current_key |= (uint64_t) (key_byte + ctx->counter2) %10 << ((ctx->key_length - key_byte - 1) * 8); + ctx->current_key |= (uint64_t)(key_byte + ctx->counter2) % 10 << ((ctx->key_length - key_byte - 1) * 8); } // counter 2 is the offset ctx->counter2++; - if(ctx->counter2 == max_offset){ + if (ctx->counter2 == max_offset) { ctx->counter2 = 0; ctx->counter1++; } return BF_GENERATOR_NEXT; -} \ No newline at end of file +} diff --git a/common/crapto1/crapto1.c b/common/crapto1/crapto1.c index 934fb11e4..60ae72dad 100644 --- a/common/crapto1/crapto1.c +++ b/common/crapto1/crapto1.c @@ -37,7 +37,7 @@ static void CONSTRUCTOR init_lut(void) { for (uint32_t i = 0; i < 1 << 20; ++i) { filterlut[i] = filter(i); -} + } for (uint32_t i = 0; i < 0x10E100A; i++) { uc_evenparity32_lut[i] = evenparity32(i); @@ -45,9 +45,9 @@ static void CONSTRUCTOR init_lut(void) { } // MSVC -#if defined _MSC_VER +#if defined _MSC_VER -typedef void(__cdecl* PF)(void); +typedef void(__cdecl *PF)(void); #pragma section(".CRT$XCG", read) __declspec(allocate(".CRT$XCG")) PF f[] = { init_lut }; @@ -79,16 +79,14 @@ static inline void extend_table(uint32_t *tbl, uint32_t **end, int bit, int m1, *tbl |= tbl_filter ^ bit; update_contribution(tbl, m1, m2); *tbl ^= in; - } - else if (tbl_filter == bit) { + } else if (tbl_filter == bit) { *++*end = tbl[1]; tbl[1] = tbl[0] | 1; update_contribution(tbl, m1, m2); *tbl++ ^= in; update_contribution(tbl, m1, m2); *tbl ^= in; - } - else + } else *tbl-- = *(*end)--; } } @@ -102,12 +100,10 @@ static inline void extend_table_simple(uint32_t *tbl, uint32_t **end, int bit) { tbl_filter = filter(*tbl); if (tbl_filter ^ filter(*tbl | 1)) { // replace *tbl |= tbl_filter ^ bit; - } - else if (tbl_filter == bit) { // insert + } else if (tbl_filter == bit) { // insert *++*end = *++tbl; *tbl = tbl[-1] | 1; - } - else { // drop + } else { // drop *tbl-- = *(*end)--; } } diff --git a/doc/commands.json b/doc/commands.json index b852f32fc..ace5033f0 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1277,21 +1277,21 @@ "offline": false, "options": [ "-h, --help This help", - "-a active signal field ON without select", - "-b number of bits to send. Useful for send partial byte", - "-c calculate and append CRC", - "-k keep signal field ON after receive", + "-a Active signal field ON without select", + "-c Calculate and append CRC", + "-k Keep signal field ON after receive", "-3 ISO14443-3 select only (skip RATS)", - "-r do not read response", - "-s active signal field ON with select", - "-t, --timeout timeout in milliseconds", + "-r Do not read response", + "-s Active signal field ON with select", + "-t, --timeout Timeout in milliseconds", + "-b Number of bits to send. Useful for send partial byte", "-v, --verbose Verbose output", - "--topaz use Topaz protocol to send command", - "--ecp use enhanced contactless polling", - "--mag use Apple magsafe polling", - " raw bytes to send" + "--ecp Use enhanced contactless polling", + "--mag Use Apple magsafe polling", + "--topaz Use Topaz protocol to send command", + " Raw bytes to send" ], - "usage": "hf 14a raw [-hack3rsv] [-b ] [-t ] [--topaz] [--ecp] [--mag] []..." + "usage": "hf 14a raw [-hack3rsv] [-t ] [-b ] [--ecp] [--mag] [--topaz] []..." }, "hf 14a reader": { "command": "hf 14a reader", @@ -1450,7 +1450,7 @@ }, "hf 14b raw": { "command": "hf 14b raw", - "description": "Sends raw bytes to card", + "description": "Sends raw bytes to card. Activates field by default", "notes": [ "hf 14b raw -cks --data 0200a40400 -> standard select, apdu 0200a4000 (7816)", "hf 14b raw -ck --sr --data 0200a40400 -> SRx select", @@ -1459,18 +1459,20 @@ "offline": false, "options": [ "-h, --help This help", - "-k, --keep leave the signal field ON after receive response", - "-s, --std activate field, use ISO14B select", - "--sr activate field, use SRx ST select", - "--cts activate field, use ASK C-ticket select", - "--xrx activate field, use Fuji/Xerox select", + "-a active signal field ON without select", "-c, --crc calculate and append CRC", + "-k, --keep leave the signal field ON after receive response", + "-d, --data data, bytes to send", "-r do not read response from card", "-t, --timeout timeout in ms", - "-v, --verbose verbose output", - "-d, --data data, bytes to send" + "-s, --std use ISO14B select", + "--sr use SRx ST select", + "--cts use ASK C-ticket select", + "--xrx use Fuji/Xerox select", + "--pico use Picopass select", + "-v, --verbose verbose output" ], - "usage": "hf 14b raw [-hkscrv] [--sr] [--cts] [--xrx] [-t ] [-d ]" + "usage": "hf 14b raw [-hackrsv] [-d ] [-t ] [--sr] [--cts] [--xrx] [--pico]" }, "hf 14b rdbl": { "command": "hf 14b rdbl", @@ -1659,9 +1661,10 @@ "options": [ "-h, --help This help", "-b, --blocksize block size (def 4)", - "-c, --count number of blocks to display (def all)" + "-c, --count number of blocks to display (def all)", + "-z, --dense dense dump output style" ], - "usage": "hf 15 eview [-h] [-b ] [-c ]" + "usage": "hf 15 eview [-hz] [-b ] [-c ]" }, "hf 15 findafi": { "command": "hf 15 findafi", @@ -1748,21 +1751,21 @@ "command": "hf 15 raw", "description": "Sends raw bytes over ISO-15693 to card", "notes": [ - "hf 15 raw -sc -d 260100 -> add crc", - "hf 15 raw -skrc -d 260100 -> add crc, keep field on, skip response" + "hf 15 raw -ac -d 260100 -> activate, add crc", + "hf 15 raw -akrc -d 260100 -> activate, add crc, keep field on, skip response" ], "offline": false, "options": [ "-h, --help This help", - "-2 use slower '1 out of 256' mode", + "-a activate field", "-c, --crc calculate and append CRC", "-k keep signal field ON after receive", + "-2 use slower '1 out of 256' mode", "-r do not read response", "-d, --data raw bytes to send", - "-w, --wait wait longer for response. For writes etc.", - "-a activate field" + "-w, --wait wait longer for response. For writes etc." ], - "usage": "hf 15 raw [-h2ckrwa] -d " + "usage": "hf 15 raw [-hack2rw] -d " }, "hf 15 rdbl": { "command": "hf 15 rdbl", @@ -1958,9 +1961,10 @@ "offline": true, "options": [ "-h, --help This help", - "-f, --file Specify a filename for dump file" + "-f, --file Specify a filename for dump file", + "-z, --dense dense dump output style" ], - "usage": "hf 15 view [-h] -f " + "usage": "hf 15 view [-hz] -f " }, "hf 15 wipe": { "command": "hf 15 wipe", @@ -4084,6 +4088,29 @@ ], "usage": "hf mf autopwn [-hablv] [-k ]... [-s ] [-f ] [--slow] [--mini] [--1k] [--2k] [--4k] [--in] [--im] [--is] [--ia] [--i2] [--i5]" }, + "hf mf brute": { + "command": "hf mf brute", + "description": "This is a smart bruteforce, exploiting common patterns, bugs and bad designs in key generators.", + "notes": [ + "hf mf brute --mini -> Key recovery against MIFARE Mini", + "hf mf brute --1k -> Key recovery against MIFARE Classic 1k", + "hf mf brute --2k -> Key recovery against MIFARE 2k", + "hf mf brute --4k -> Key recovery against MIFARE 4k", + "hf mf brute --1k --emu -> Target 1K, write keys to emulator memory", + "hf mf brute --1k --dump -> Target 1K, write keys to file" + ], + "offline": false, + "options": [ + "-h, --help This help", + "--mini MIFARE Classic Mini / S20", + "--1k MIFARE Classic 1k / S50 (default)", + "--2k MIFARE Classic/Plus 2k", + "--4k MIFARE Classic 4k / S70", + "--emu Fill simulator keys from found keys", + "--dump Dump found keys to binary file" + ], + "usage": "hf mf brute [-h] [--mini] [--1k] [--2k] [--4k] [--emu] [--dump]" + }, "hf mf cgetblk": { "command": "hf mf cgetblk", "description": "Get block data from magic Chinese card. Only works with magic gen1a cards", @@ -4154,9 +4181,13 @@ "options": [ "-h, --help This help", "-f, --file Specify a filename for dump file", + "--mini MIFARE Classic Mini / S20", + "--1k MIFARE Classic 1k / S50 (def)", + "--2k MIFARE Classic/Plus 2k", + "--4k MIFARE Classic 4k / S70", "--emu from emulator memory" ], - "usage": "hf mf cload [-h] [-f ] [--emu]" + "usage": "hf mf cload [-h] [-f ] [--mini] [--1k] [--2k] [--4k] [--emu]" }, "hf mf csave": { "command": "hf mf csave", @@ -8304,7 +8335,7 @@ }, "lf em 4x05 help": { "command": "lf em 4x05 help", - "description": "help This help demod Demodulate a EM4x05/EM4x69 tag from the GraphBuffer sniff Attempt to recover em4x05 commands from sample buffer --------------------------------------------------------------------------------------- lf em 4x05 brute available offline: no This command tries to bruteforce the password of a EM4205/4305/4469/4569 The loop is running on device side, press Proxmark3 button to abort", + "description": "help This help ----------- ----------------------- general ----------------------- demod Demodulate a EM4x05/EM4x69 tag from the GraphBuffer sniff Attempt to recover em4x05 commands from sample buffer view Display content from tag dump file --------------------------------------------------------------------------------------- lf em 4x05 brute available offline: no This command tries to bruteforce the password of a EM4205/4305/4469/4569 The loop is running on device side, press Proxmark3 button to abort", "notes": [ "Note: if you get many false positives, change position on the antennalf em 4x05 brute", "lf em 4x05 brute -n 1 -> stop after first candidate found", @@ -8328,9 +8359,10 @@ "offline": false, "options": [ "-h, --help This help", - "-p, --pwd optional - password, 4 hex bytes" + "-p, --pwd optional - password, 4 hex bytes", + "-v, --verbose Verbose output" ], - "usage": "lf em 4x05 info [-h] [-p ]" + "usage": "lf em 4x05 info [-hv] [-p ]" }, "lf em 4x05 read": { "command": "lf em 4x05 read", @@ -8382,6 +8414,20 @@ ], "usage": "lf em 4x05 unlock [-hv] [-n ] [-s ] [-e ] [-p ]" }, + "lf em 4x05 view": { + "command": "lf em 4x05 view", + "description": "Print a EM4205/4305/4369/4469 dump file (bin/eml/json) note: We don't track if password is known in current dump file formats. All zeros password block might be filler data", + "notes": [ + "lf em 4x05 view -f lf-4x05-01020304-dump.json" + ], + "offline": true, + "options": [ + "-h, --help This help", + "-f, --file Specify a filename for dump file", + "-v, --verbose Verbose output" + ], + "usage": "lf em ex05 view [-hv] -f " + }, "lf em 4x05 wipe": { "command": "lf em 4x05 wipe", "description": "Wipe EM4x05/EM4x69. Tag must be on antenna.", @@ -8494,12 +8540,13 @@ "description": "help This help ----------- --------------------- operations --------------------- ----------- --------------------- simulation --------------------- --------------------------------------------------------------------------------------- lf em 4x50 brute available offline: no Tries to bruteforce the password of a EM4x50 card. Function can be stopped by pressing pm3 button.", "notes": [ "lf em 4x50 brute --mode range --begin 12330000 --end 12340000 -> tries pwds from 0x12330000 to 0x12340000", - "lf em 4x50 brute --mode charset --digits --uppercase -> tries all combinations of ASCII codes for digits and uppercase letters" + "lf em 4x50 brute --mode charset --digits --uppercase -> tries all combinations of ASCII codes for digits and uppercase letters", + "lf em 4x50 brute --mode smart -> enable 'smart' pattern key cracking" ], "offline": true, "options": [ "-h, --help This help", - "--mode Bruteforce mode (range|charset)", + "--mode Bruteforce mode (range|charset|smart)", "--begin Range mode - start of the key range", "--end Range mode - end of the key range", "--digits Charset mode - include ASCII codes for digits", @@ -8763,9 +8810,10 @@ "--err maximum allowed errors (default 100)", "--len maximum length", "-i, --invert invert output", - "-a, --amp amplify signal" + "-a, --amp amplify signal", + "--bin Binary string i.e 0001001001" ], - "usage": "lf em 410x demod [-hia] [--clk ] [--err ] [--len ]" + "usage": "lf em 410x demod [-hia] [--clk ] [--err ] [--len ] [--bin ]" }, "lf fdxb clone": { "command": "lf fdxb clone", @@ -9304,13 +9352,15 @@ "command": "lf idteck help", "description": "help This help demod demodulate an Idteck tag from the GraphBuffer --------------------------------------------------------------------------------------- lf idteck demod available offline: yes Try to find Idteck preamble, if found decode / descramble data", "notes": [ - "lf idteck demod" + "lf idteck demod", + "lf idteck demod --raw 4944544B351FBE4B" ], "offline": true, "options": [ - "-h, --help This help" + "-h, --help This help", + "-r, --raw raw bytes" ], - "usage": "lf idteck demod [-h]" + "usage": "lf idteck demod [-h] [-r ]" }, "lf idteck reader": { "command": "lf idteck reader", @@ -12240,8 +12290,8 @@ } }, "metadata": { - "commands_extracted": 707, + "commands_extracted": 709, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2024-01-16T12:52:56" + "extracted_on": "2024-01-18T15:39:50" } } \ No newline at end of file diff --git a/doc/commands.md b/doc/commands.md index a4fc98c18..2f0de6ce2 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -909,6 +909,7 @@ Check column "offline" for their availability. |`lf em 4x05 read `|N |`Read word data from EM4x05/EM4x69` |`lf em 4x05 sniff `|Y |`Attempt to recover em4x05 commands from sample buffer` |`lf em 4x05 unlock `|N |`Execute tear off against EM4x05/EM4x69` +|`lf em 4x05 view `|Y |`Display content from tag dump file` |`lf em 4x05 wipe `|N |`Wipe EM4x05/EM4x69 tag` |`lf em 4x05 write `|N |`Write word data to EM4x05/EM4x69`