diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index 318e3a2f8..72af553f1 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -165,7 +165,7 @@ int CmdHFSearch(const char *Cmd) { } } - // texkom + // texkom PROMPT_CLEARLINE; PrintAndLogEx(INPLACE, " Searching for TEXKOM tag..."); if (read_texkom_uid(false, false) == PM3_SUCCESS) { diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 831f87f8c..ac1ec0b9e 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -43,7 +43,7 @@ #define APDU_TIMEOUT 2000 // for static arrays -#define ST25TB_SR_BLOCK_SIZE 4 +#define ST25TB_SR_BLOCK_SIZE 4 // iso14b apdu input frame length static uint16_t apdu_frame_length = 0; @@ -458,7 +458,7 @@ static bool get_14b_UID(uint8_t *d, iso14b_type_t *found_type) { } } - // test CT + // test CT packet.flags = (ISO14B_CONNECT | ISO14B_SELECT_CTS | ISO14B_DISCONNECT); clearCommandBuffer(); SendCommandNG(CMD_HF_ISO14443B_COMMAND, (uint8_t *)&packet, sizeof(iso14b_raw_cmd_t)); @@ -2164,7 +2164,7 @@ static command_t CommandTable[] = { {"sniff", CmdHF14BSniff, IfPm3Iso14443b, "Eavesdrop ISO-14443-B"}, {"rdbl", CmdHF14BSriRdBl, IfPm3Iso14443b, "Read SRI512/SRIX4x block"}, {"sriwrite", CmdHF14BWriteSri, IfPm3Iso14443b, "Write data to a SRI512 or SRIX4K tag"}, - {"view", CmdHF14BView, AlwaysAvailable, "Display content from tag dump file"}, + {"view", CmdHF14BView, AlwaysAvailable, "Display content from tag dump file"}, // {"valid", srix4kValid, AlwaysAvailable, "srix4k checksum test"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/src/cmdhfemrtd.c b/client/src/cmdhfemrtd.c index 3216f68ae..cb656b169 100644 --- a/client/src/cmdhfemrtd.c +++ b/client/src/cmdhfemrtd.c @@ -716,7 +716,7 @@ static const uint8_t jpeg_header[4] = { 0xFF, 0xD8, 0xFF, 0xE0 }; static const uint8_t jpeg2k_header[6] = { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50 }; static int emrtd_dump_ef_dg2(uint8_t *file_contents, size_t file_length, const char *path) { - size_t offset; + size_t offset; int datalen = 0; // This is a hacky impl that just looks for the image header. I'll improve it eventually. @@ -2083,7 +2083,7 @@ int infoHF_EMRTD_offline(const char *path) { return PM3_ESOFT; } - // coverity scan CID 395630, + // coverity scan CID 395630, if (data != NULL) { return PM3_ESOFT; } diff --git a/client/src/cmdhftexkom.c b/client/src/cmdhftexkom.c index fee7fca97..18a1f5c48 100644 --- a/client/src/cmdhftexkom.c +++ b/client/src/cmdhftexkom.c @@ -372,7 +372,7 @@ static void TexcomReverseCode(const uint8_t *code, int length, uint8_t *reverse_ } }; -static int texkom_get_type(texkom_card_select_t* card, bool verbose) { +static int texkom_get_type(texkom_card_select_t *card, bool verbose) { if (card == NULL) { return PM3_EINVARG; @@ -474,7 +474,7 @@ static int texkom_get_type(texkom_card_select_t* card, bool verbose) { if (verbose) TexcomGeneralDecode(implengths, implengthslen, genbitstring, verbose); } - + if (found != TexkomModError) { for (uint32_t i = 0; i < strlen(cbitstring); i++) { @@ -483,7 +483,7 @@ static int texkom_get_type(texkom_card_select_t* card, bool verbose) { TexcomReverseCode(card->tcode, sizeof(card->tcode), card->rtcode); return PM3_SUCCESS; - } + } return PM3_ESOFT; } @@ -524,20 +524,20 @@ int read_texkom_uid(bool loop, bool verbose) { if (loop == false) { PrintAndLogEx(NORMAL, ""); } - + bool crc = (TexcomTK13CRC(&card.tcode[3]) == card.tcode[7]); if (card.tcode[2] == 0x63) { PrintAndLogEx(INFO, "TYPE..... TK13"); PrintAndLogEx(INFO, "UID...... " _GREEN_("%s"), sprint_hex(&card.tcode[3], 4)); if (verbose) { - PrintAndLogEx(INFO, "CRC...... %s", (crc) ? _GREEN_("ok") : _RED_("fail")); + PrintAndLogEx(INFO, "CRC...... %s", (crc) ? _GREEN_("ok") : _RED_("fail")); } } else if (card.tcode[2] == 0xCA) { PrintAndLogEx(INFO, "TYPE..... TK17"); PrintAndLogEx(INFO, "UID...... " _GREEN_("%s"), sprint_hex(&card.tcode[3], 4)); if (verbose) { - PrintAndLogEx(INFO, "CRC...... %s", (crc) ? _GREEN_("ok") : _RED_("fail")); + PrintAndLogEx(INFO, "CRC...... %s", (crc) ? _GREEN_("ok") : _RED_("fail")); } } if (verbose) { @@ -557,7 +557,7 @@ static int CmdHFTexkomReader(const char *Cmd) { "Read a texkom tag", "hf texkom reader\n" "hf texkom reader -@ -> continuous reader mode" - ); + ); void *argtable[] = { arg_param_begin, @@ -813,7 +813,7 @@ static int CmdHFTexkomSim(const char *Cmd) { memcpy(payload.data, rawdata, 8); clearCommandBuffer(); - SendCommandNG(CMD_HF_TEXKOM_SIMULATE, (uint8_t*)&payload, sizeof(payload)); + SendCommandNG(CMD_HF_TEXKOM_SIMULATE, (uint8_t *)&payload, sizeof(payload)); if (payload.timeout > 0 && payload.timeout < 2800) { PrintAndLogEx(INFO, "simulate command started"); diff --git a/client/src/cmdhfxerox.c b/client/src/cmdhfxerox.c index 505aace8e..ac2c3b75f 100644 --- a/client/src/cmdhfxerox.c +++ b/client/src/cmdhfxerox.c @@ -298,7 +298,7 @@ void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, c2l(iv, tout0); c2l(iv, tout1); iv -= 8; - + for (l -= 8; l >= 0; l -= 8) { c2l(in, tin0); c2l(in, tin1); @@ -414,7 +414,7 @@ static int findXerox(iso14b_card_select_t *card, bool disconnect) { static uint8_t info_blocks[] = { 0x15, 0x16, 0x17, 0x18, 0x22 }; static const char *c_type[] = { "drum", "yellow", "magenta", "cyan", "black" }; -static inline char dec_digit(uint8_t dig) { +static inline char dec_digit(uint8_t dig) { return (dig <= 9) ? dig + '0' : '?'; } @@ -569,7 +569,7 @@ static int CmdHFXeroxDump(const char *Cmd) { iso14b_card_select_t card; int status = findXerox(&card, false); // remain RF on if (status != PM3_SUCCESS) { - free(packet); + free(packet); switch_off_field(); return PM3_ERFTRANS; } diff --git a/client/src/crypto/asn1utils.c b/client/src/crypto/asn1utils.c index 55aa0d0f9..4618c5028 100644 --- a/client/src/crypto/asn1utils.c +++ b/client/src/crypto/asn1utils.c @@ -37,7 +37,7 @@ int ecdsa_asn1_get_signature(uint8_t *signature, size_t signaturelen, uint8_t *r if (p == NULL) { return PM3_EMALLOC; } - + memcpy(p, signature, signaturelen); uint8_t *p_tmp = p; const uint8_t *end = p + signaturelen; diff --git a/client/src/pm3line_vocabulory.h b/client/src/pm3line_vocabulory.h index c8619f164..982cbd734 100644 --- a/client/src/pm3line_vocabulory.h +++ b/client/src/pm3line_vocabulory.h @@ -156,6 +156,7 @@ const static vocabulory_t vocabulory[] = { { 0, "hf 14b sniff" }, { 0, "hf 14b rdbl" }, { 0, "hf 14b sriwrite" }, + { 1, "hf 14b view" }, { 1, "hf 15 help" }, { 1, "hf 15 list" }, { 1, "hf 15 demod" }, @@ -427,6 +428,7 @@ const static vocabulory_t vocabulory[] = { { 0, "hf topaz raw" }, { 1, "hf texkom help" }, { 0, "hf texkom reader" }, + { 0, "hf texkom sim" }, { 1, "hf xerox help" }, { 0, "hf xerox info" }, { 0, "hf xerox dump" }, diff --git a/client/src/util.c b/client/src/util.c index 9f564d58f..421cc84a3 100644 --- a/client/src/util.c +++ b/client/src/util.c @@ -94,13 +94,19 @@ static char b2s(uint8_t v, bool uppercase) { // clear higher bits v &= 0xF; - switch(v) { - case 0xA : return (uppercase ? 'A' : 'a') ; - case 0xB : return (uppercase ? 'B' : 'b') ; - case 0xC : return (uppercase ? 'C' : 'c') ; - case 0xD : return (uppercase ? 'D' : 'd') ; - case 0xE : return (uppercase ? 'E' : 'e') ; - case 0xF : return (uppercase ? 'F' : 'f') ; + switch (v) { + case 0xA : + return (uppercase ? 'A' : 'a') ; + case 0xB : + return (uppercase ? 'B' : 'b') ; + case 0xC : + return (uppercase ? 'C' : 'c') ; + case 0xD : + return (uppercase ? 'D' : 'd') ; + case 0xE : + return (uppercase ? 'E' : 'e') ; + case 0xF : + return (uppercase ? 'F' : 'f') ; default: return (char)(v + 0x30); } @@ -201,12 +207,12 @@ void hex_to_buffer(uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, if (buf == NULL || hex_len < 1) return; - // 1. hex string length. + // 1. hex string length. // 2. byte array to be converted to string // size_t max_byte_len = (hex_len > hex_max_len) ? hex_max_len : hex_len; - size_t max_str_len = (max_byte_len * ( 2 + spaces_between )) + 1; + size_t max_str_len = (max_byte_len * (2 + spaces_between)) + 1; char *tmp_base = (char *)buf; char *tmp = tmp_base; @@ -291,7 +297,7 @@ static void print_buffer_ex(const uint8_t *data, const size_t len, int level, ui hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, breaks, (sizeof(buf) - strlen(buf) - 1), 0, 1, true); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "| %s", sprint_ascii(data + i, breaks)); - + PrintAndLogEx(INFO, "%s", buf); } @@ -453,13 +459,13 @@ char *sprint_bin(const uint8_t *data, const size_t len) { char *sprint_hex_ascii(const uint8_t *data, const size_t len) { static char buf[UTIL_BUFFER_SIZE_SPRINT + 20] = {0}; - memset(buf, 0x00, sizeof(buf)); + memset(buf, 0x00, sizeof(buf)); char *tmp = buf; size_t max_len = (len > 1010) ? 1010 : len; int ret = snprintf(buf, sizeof(buf) - 1, "%s| ", sprint_hex(data, max_len)); - if ( ret < 0) { + if (ret < 0) { goto out; } @@ -767,7 +773,7 @@ int param_gethex_to_eol(const char *line, int paramnum, uint8_t *data, int maxda int bg, en; - if (param_getptr(line, &bg, &en, paramnum)) + if (param_getptr(line, &bg, &en, paramnum)) return 1; *datalen = 0; diff --git a/doc/commands.json b/doc/commands.json index dfc8a4647..7b0472464 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1295,7 +1295,7 @@ }, "hf 14b help": { "command": "hf 14b help", - "description": "help This help list List ISO-14443-B history", + "description": "help This help list List ISO-14443-B history view Display content from tag dump file", "notes": [], "offline": true, "options": [], @@ -1446,6 +1446,20 @@ ], "usage": "hf 14b sriwrite [-h] [-b ] -d [--512] [--4k] [--sb]" }, + "hf 14b view": { + "command": "hf 14b view", + "description": "Print a ISO14443-B dump file (bin/eml/json)", + "notes": [ + "hf 14b view -f hf-14b-01020304-dump.bin" + ], + "offline": true, + "options": [ + "-h, --help This help", + "-f, --file filename of dump", + "-v, --verbose verbose output" + ], + "usage": "hf 14b view [-hv] -f " + }, "hf 15 csetuid": { "command": "hf 15 csetuid", "description": "Set UID for magic Chinese card (only works with such cards)", @@ -6315,14 +6329,16 @@ "command": "hf texkom reader", "description": "Read a texkom tag", "notes": [ - "hf texkom reader" + "hf texkom reader", + "hf texkom reader -@ -> continuous reader mode" ], "offline": false, "options": [ "-h, --help This help", - "-v, --verbose Verbose scan and output" + "-v, --verbose Verbose scan and output", + "-@ optional - continuous reader mode" ], - "usage": "hf texkom reader [-hv]" + "usage": "hf texkom reader [-hv@]" }, "hf texkom sim": { "command": "hf texkom sim", @@ -6341,9 +6357,10 @@ "-v, --verbose Verbose work", "-t, --tk17 Use TK-17 modulation (TK-13 by default)", "--raw Raw data for texkom card, 8 bytes. Manual modulation select.", - "--id Raw data for texkom card, 8 bytes. Manual modulation select." + "--id Raw data for texkom card, 8 bytes. Manual modulation select.", + "--timeout Simulation timeout in the ms. If not specified or 0 - infinite. Command can be skipped by pressing the button" ], - "usage": "hf texkom sim [-hvt] [--raw ] [--id ]" + "usage": "hf texkom sim [-hvt] [--raw ] [--id ] [--timeout ]" }, "hf thinfilm help": { "command": "hf thinfilm help", @@ -11076,8 +11093,8 @@ } }, "metadata": { - "commands_extracted": 699, + "commands_extracted": 700, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2022-07-03T21:31:15" + "extracted_on": "2022-07-07T21:17:54" } } \ No newline at end of file diff --git a/doc/commands.md b/doc/commands.md index 4f03dee72..3ff0c57cf 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -207,6 +207,7 @@ Check column "offline" for their availability. |`hf 14b sniff `|N |`Eavesdrop ISO-14443-B` |`hf 14b rdbl `|N |`Read SRI512/SRIX4x block` |`hf 14b sriwrite `|N |`Write data to a SRI512 or SRIX4K tag` +|`hf 14b view `|Y |`Display content from tag dump file` ### hf 15