This commit is contained in:
iceman1001 2022-08-24 07:25:10 +02:00
parent 811f76785d
commit e18194028b
15 changed files with 792 additions and 792 deletions

View file

@ -110,8 +110,8 @@ void RunMod(void) {
// infinite loop
if (i > 15) {
// still no dump file found
if (flag_has_dumpfile == false) {
break;
if (flag_has_dumpfile == false) {
break;
}
// next loop
i = 1;

View file

@ -1646,7 +1646,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint16_t flags, uint8_t *data, uint8_
emlGetMemBt(pwd, (pages - 1) * 4 + MFU_DUMP_PREFIX_LENGTH, sizeof(pwd));
if (memcmp(pwd, "\x00\x00\x00\x00", 4) == 0) {
Uint4byteToMemLe(pwd, ul_ev1_pwdgenB(data));
Dbprintf("Calc pwd... %02X %02X %02X %02X", pwd[0], pwd[1], pwd[2] ,pwd[3]);
Dbprintf("Calc pwd... %02X %02X %02X %02X", pwd[0], pwd[1], pwd[2], pwd[3]);
}
if (memcmp(receivedCmd + 1, pwd, 4) == 0) {

View file

@ -1,4 +1,4 @@
--
--
-- hf_mf_sim_hid.lua - A tool to clone a large number of tags at once.
-- Adapted from lf_hid_bulkclone.lua
-- Created 16.08.2022
@ -110,7 +110,7 @@ end
hex. This should be easy enough to extend to non 26bit formats
]]--
local function cardHex(i, f)
fac = lshift(f, 16)
id = bor(i, fac)
stream = toBits(id, 24)

View file

@ -108,7 +108,7 @@ local function main(args)
-- only deal with missing PWD and PACK, or with 56 emu hdr
if #hex ~= 1064 and #hex ~= 1080 and #hex ~= 1192 then return oops('Expecting either a plain binary or emulator dump') end
local amiibo_offset = (#hex == 1064 or #hex == 1080) and 0 or 112
local amiibo_offset = (#hex == 1064 or #hex == 1080) and 0 or 112
local amiibo_info = hex:sub(amiibo_offset + 169, amiibo_offset + 169 + 15):lower()
local amiibo_game = amiibo_info:sub(1, 3)
local amiibo_type = amiibo_info:sub(7, 8)

View file

@ -223,7 +223,7 @@ static int CmdHFFudanReader(const char *Cmd) {
CLIParserFree(ctx);
if (cm) {
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
}
read_fudan_uid(cm, verbose);

View file

@ -191,7 +191,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
return PM3_SUCCESS;
} else if (cmd[1] == 0x02 && cmdsize == (cmd[2] & 0x0f) + 7) {
// Byte 3 is the reader type
switch(cmd[3]) {
switch (cmd[3]) {
case 0x01:
snprintf(exp, size, "ECP2 (Transit)");
break;

View file

@ -5427,7 +5427,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
return PM3_SUCCESS;
}
if (g_session.pm3_present == false)
if (g_session.pm3_present == false)
return PM3_ENOTTY;
@ -6461,7 +6461,7 @@ static int CmdHF14AMfValue(const char *Cmd) {
if (action < 3) {
if (g_session.pm3_present == false)
if (g_session.pm3_present == false)
return PM3_ENOTTY;
if (action <= 1) { // increment/decrement value

View file

@ -606,7 +606,7 @@ static int ndef_print_CC(uint8_t *data) {
uint8_t mlrule = (data[3] & 0x06) >> 1;
uint8_t mbread = (data[3] & 0x01);
PrintAndLogEx(SUCCESS, " %02X: Additional feature information", data[3]);
PrintAndLogEx(SUCCESS, " %02X: Additional feature information", data[3]);
PrintAndLogEx(SUCCESS, " %s", sprint_bin(&data[3], 1));
PrintAndLogEx(SUCCESS, " xxx..... - %02X: RFU ( %s )", msb3, (msb3 == 0) ? _GREEN_("ok") : _RED_("fail"));
PrintAndLogEx(SUCCESS, " ...x.... - %02X: %s special frame", sf, (sf) ? "support" : "don\'t support");
@ -3243,7 +3243,7 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) {
PrintAndLogEx(INFO, "------------------.---------------");
PrintAndLogEx(INFO, " Using UID 4b: " _YELLOW_("%s"), sprint_hex(uid, 4));
PrintAndLogEx(INFO, " Using UID 7b: " _YELLOW_("%s"), sprint_hex(uid, 7));
PrintAndLogEx(INFO, " Using UID 7b: " _YELLOW_("%s"), sprint_hex(uid, 7));
PrintAndLogEx(INFO, "----------------------------------");
PrintAndLogEx(INFO, " algo | pwd | pack");
PrintAndLogEx(INFO, "-----------------+----------+-----");

View file

@ -238,7 +238,7 @@ static int topaz_write_erase8_block(uint8_t blockno, uint8_t *block_data) {
}
if (memcmp(block_data, response + 1, 8) == 0) {
return PM3_SUCCESS;
return PM3_SUCCESS;
}
return PM3_ESOFT;
}
@ -331,13 +331,13 @@ static int topaz_print_CC(uint8_t *data) {
// b1, b0 write
// 00 always, 01 rfo, 10 proprietary, 11 never
// vs
// vs
// NFC Forum Type 2 docs, where
// b7654 = major version
// b3219 = minor version
// CC write / read access
// CC write / read access
// (data[3] & 0xF0) ? "(RFU)" : "Read access granted without any security",
// (data[3] & 0x0F) == 0 ? "Write access granted without any security" : (data[3] & 0x0F) == 0x0F ? "No write access granted at all" : "(RFU)");
uint8_t cc_major = (data[1] & 0xF0) >> 4;
@ -397,7 +397,7 @@ static int topaz_print_CC(uint8_t *data) {
PrintAndLogEx(SUCCESS, " ....x... - %02X: %s lock block", lb, (lb) ? "support" : "don\'t support");
PrintAndLogEx(SUCCESS, " .....xx. - %02X: RFU ( %s )", mlrule, (mlrule == 0) ? _GREEN_("ok") : _RED_("fail"));
PrintAndLogEx(SUCCESS, " .......x - %02X: IC %s multiple block reads", mbread, (mbread) ? "support" : "don\'t support");
PrintAndLogEx(SUCCESS,"");
PrintAndLogEx(SUCCESS, "");
return PM3_SUCCESS;
}
@ -457,7 +457,7 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
uint16_t next_lockable_byte = 0x0f * 8; // first byte after static memory area
while (*TLV_ptr != 0x03 && *TLV_ptr != 0xFD && *TLV_ptr != 0xFE) {
// all Lock Control TLVs shall be present before the NDEF message TLV, the proprietary TLV (and the Terminator TLV)
get_TLV(&TLV_ptr, &TLV_type, &TLV_length, &TLV_value);
@ -556,7 +556,7 @@ static void topaz_print_dynamic_data(void) {
}
PrintAndLogEx(SUCCESS, "Dynamic Data blocks:");
if (topaz_read_dynamic_data() == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "block# | Data |lck");
@ -587,7 +587,7 @@ static void printTopazDumpContents(uint8_t *dump, size_t size) {
topaz_tag_t *t = (topaz_tag_t *)dump;
// uses a global var for all
// uses a global var for all
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "Static data blocks :");
PrintAndLogEx(SUCCESS, "block# | data |lck| info");
@ -598,7 +598,7 @@ static void printTopazDumpContents(uint8_t *dump, size_t size) {
for (uint8_t i = 0; i <= 0x0C; i++) {
if (i == 0)
if (i == 0)
block_info = topaz_ks[i];
else
block_info = topaz_ks[1];
@ -606,12 +606,12 @@ static void printTopazDumpContents(uint8_t *dump, size_t size) {
const char *lockstr = (topaz_byte_is_locked(i * 8)) ? _RED_("x") : " ";
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| %s | %s",
i,
i,
sprint_hex(&t->data_blocks[i][0], 8),
lockstr,
block_info
);
i,
i,
sprint_hex(&t->data_blocks[i][0], 8),
lockstr,
block_info
);
}
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| | %s", 0x0D, 0x0D, sprint_hex(&t->data_blocks[0x0D][0], 8), topaz_ks[2]);
@ -626,7 +626,7 @@ static int CmdHFTopazReader(const char *Cmd) {
"Read UID from Topaz tags",
"hf topaz reader\n"
"hf topaz reader -@ -> Continuous mode\n"
);
);
void *argtable[] = {
arg_param_begin,
@ -675,7 +675,7 @@ int CmdHFTopazInfo(const char *Cmd) {
CLIParserFree(ctx);
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " ---------------------------");
int status = readTopazUid(false, verbose);
if (status != PM3_SUCCESS) {
return status;
@ -689,15 +689,15 @@ int CmdHFTopazInfo(const char *Cmd) {
PrintAndLogEx(SUCCESS, " %s", sprint_bin(topaz_tag.HR01, 1));
PrintAndLogEx(SUCCESS, " ...x.... - %s / %s",
(topaz_tag.HR01[0] & 0xF0) == 0x10 ? _GREEN_("TOPAZ tag") : "",
(topaz_tag.HR01[0] & 0xF0) == 0x10 ? _GREEN_("Type 1 NDEF") : ""
);
PrintAndLogEx(SUCCESS, " .......x - %s memory map", ((topaz_tag.HR01[0] & 0x0F) == 0x01) ? "Static" : "Dynamic" );
(topaz_tag.HR01[0] & 0xF0) == 0x10 ? _GREEN_("TOPAZ tag") : "",
(topaz_tag.HR01[0] & 0xF0) == 0x10 ? _GREEN_("Type 1 NDEF") : ""
);
PrintAndLogEx(SUCCESS, " .......x - %s memory map", ((topaz_tag.HR01[0] & 0x0F) == 0x01) ? "Static" : "Dynamic");
PrintAndLogEx(SUCCESS, "");
PrintAndLogEx(SUCCESS, " Lock bytes... %02X%02X",
topaz_tag.data_blocks[0x0e][0],
topaz_tag.data_blocks[0x0e][1]
);
topaz_tag.data_blocks[0x0e][0],
topaz_tag.data_blocks[0x0e][1]
);
PrintAndLogEx(SUCCESS, " OTP.......... %s", sprint_hex(&topaz_tag.data_blocks[0x0e][2], 6));
PrintAndLogEx(NORMAL, "");
@ -792,12 +792,12 @@ static int CmdHFTopazDump(const char *Cmd) {
char filename[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
CLIParserFree(ctx);
int status = readTopazUid(false, false);
if (status != PM3_SUCCESS) {
return status;
}
printTopazDumpContents((uint8_t*)&topaz_tag, sizeof(topaz_tag_t));
printTopazDumpContents((uint8_t *)&topaz_tag, sizeof(topaz_tag_t));
bool set_dynamic = false;
if (topaz_set_cc_dynamic(&topaz_tag.data_blocks[1][0]) == PM3_SUCCESS) {
@ -807,10 +807,10 @@ static int CmdHFTopazDump(const char *Cmd) {
topaz_print_lifecycle_state(&topaz_tag.data_blocks[1][0]);
NDEFDecodeAndPrint(&topaz_tag.data_blocks[1][4],
(topaz_tag.HR01[0] == 1) ? (12 * 8) : 476
, true
);
NDEFDecodeAndPrint(&topaz_tag.data_blocks[1][4],
(topaz_tag.HR01[0] == 1) ? (12 * 8) : 476
, true
);
}
PrintAndLogEx(INFO, "-------------------------------------------------------------");
@ -827,7 +827,7 @@ static int CmdHFTopazDump(const char *Cmd) {
pm3_save_dump(filename, (uint8_t *)&topaz_tag, sizeof(topaz_tag_t) + topaz_tag.size, jsfTopaz, TOPAZ_BLOCK_SIZE);
else
pm3_save_dump(filename, (uint8_t *)&topaz_tag, sizeof(topaz_tag_t), jsfTopaz, TOPAZ_BLOCK_SIZE);
if (set_dynamic) {
free(topaz_tag.dynamic_memory);
}
@ -868,12 +868,12 @@ static int CmdHFTopazView(const char *Cmd) {
topaz_print_lifecycle_state(&topaz_tag.data_blocks[1][0]);
NDEFDecodeAndPrint(&topaz_tag.data_blocks[1][4],
(topaz_tag.HR01[0] == 1) ? (12 * 8) : 476
, true
);
NDEFDecodeAndPrint(&topaz_tag.data_blocks[1][4],
(topaz_tag.HR01[0] == 1) ? (12 * 8) : 476
, true
);
PrintAndLogEx(INFO, "%s", sprint_hex(&topaz_tag.data_blocks[1][4], (12*8)));
PrintAndLogEx(INFO, "%s", sprint_hex(&topaz_tag.data_blocks[1][4], (12 * 8)));
free(topaz_tag.dynamic_memory);
}
@ -946,7 +946,7 @@ static int CmdHFTopazWrBl(const char *Cmd) {
return PM3_EINVARG;
}
if (dlen != 8 ) {
if (dlen != 8) {
PrintAndLogEx(WARNING, "Wrong data length. Expect 8, got %d", dlen);
return PM3_EINVARG;
}
@ -957,9 +957,9 @@ static int CmdHFTopazWrBl(const char *Cmd) {
int res = topaz_write_erase8_block(blockno, data);
if (res == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "Write ( " _GREEN_("ok") " )" );
PrintAndLogEx(SUCCESS, "Write ( " _GREEN_("ok") " )");
} else {
PrintAndLogEx(WARNING, "Write ( " _RED_("fail") " )" );
PrintAndLogEx(WARNING, "Write ( " _RED_("fail") " )");
}
topaz_switch_off_field();
@ -977,9 +977,9 @@ static command_t CommandTable[] = {
{"sim", CmdHFTopazSim, IfPm3Iso14443a, "Simulate Topaz tag"},
{"sniff", CmdHFTopazSniff, IfPm3Iso14443a, "Sniff Topaz reader-tag communication"},
{"raw", CmdHFTopazRaw, IfPm3Iso14443a, "Send raw hex data to tag"},
{"rdbl", CmdHFTopazRdBl, IfPm3Iso14443a, "Read block"},
{"rdbl", CmdHFTopazRdBl, IfPm3Iso14443a, "Read block"},
{"view", CmdHFTopazView, AlwaysAvailable, "Display content from tag dump file"},
{"wrbl", CmdHFTopazWrBl, IfPm3Iso14443a, "Write block"},
{"wrbl", CmdHFTopazWrBl, IfPm3Iso14443a, "Write block"},
{NULL, NULL, 0, NULL}
};
@ -1055,20 +1055,20 @@ int readTopazUid(bool loop, bool verbose) {
// printing
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%02X %02X %02X %02X %02X %02X %02X"),
topaz_tag.uid[6],
topaz_tag.uid[5],
topaz_tag.uid[4],
topaz_tag.uid[3],
topaz_tag.uid[2],
topaz_tag.uid[1],
topaz_tag.uid[0]);
topaz_tag.uid[6],
topaz_tag.uid[5],
topaz_tag.uid[4],
topaz_tag.uid[3],
topaz_tag.uid[2],
topaz_tag.uid[1],
topaz_tag.uid[0]);
PrintAndLogEx(SUCCESS, "ATQA: " _GREEN_("%02X %02X"), atqa[1], atqa[0]);
topaz_tag.HR01[0] = rid_response[0];
topaz_tag.HR01[1] = rid_response[1];
} while (loop && kbd_enter_pressed() == false);
} while (loop && kbd_enter_pressed() == false);
topaz_switch_off_field();
return res;

View file

@ -638,14 +638,14 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
JsonSaveStr(root, "FileType", "topaz");
JsonSaveBufAsHexCompact(root, "$.Card.UID", tag->uid, sizeof(tag->uid));
JsonSaveBufAsHexCompact(root, "$.Card.H0R1", tag->HR01, sizeof(tag->HR01));
JsonSaveBufAsHexCompact(root, "$.Card.Size", (uint8_t *)&(tag->size), 2);
JsonSaveBufAsHexCompact(root, "$.Card.Size", (uint8_t *) & (tag->size), 2);
for (size_t i = 0; i < TOPAZ_STATIC_MEMORY / 8; i++) {
char path[PATH_MAX_LENGTH] = {0};
snprintf(path, sizeof(path), "$.blocks.%zu", i);
JsonSaveBufAsHexCompact(root, path, &tag->data_blocks[i][0], TOPAZ_BLOCK_SIZE);
}
// ICEMAN todo: add dynamic memory.
// ICEMAN todo: add dynamic memory.
// uint16_z Size
// uint8_t *dynamic_memory;
@ -1296,13 +1296,13 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
if (!strcmp(ctype, "legic")) {
JsonLoadBufAsHex(root, "$.raw", udata, maxdatalen, datalen);
}
if (!strcmp(ctype, "topaz")) {
topaz_tag_t *mem = (topaz_tag_t *)udata;
JsonLoadBufAsHex(root, "$.Card.UID", mem->uid, sizeof(mem->uid), datalen);
JsonLoadBufAsHex(root, "$.Card.HR01", mem->HR01, sizeof(mem->HR01), datalen);
JsonLoadBufAsHex(root, "$.Card.Size", (uint8_t *)&(mem->size), 2, datalen);
JsonLoadBufAsHex(root, "$.Card.Size", (uint8_t *) & (mem->size), 2, datalen);
size_t sptr = 0;
for (int i = 0; i < (TOPAZ_STATIC_MEMORY / 8); i++) {
@ -1322,7 +1322,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
sptr += len;
// ICEMAN todo: add dynamic memory.
// ICEMAN todo: add dynamic memory.
// uint16_z Size
// uint8_t *dynamic_memory;
}

View file

@ -2440,7 +2440,7 @@ static void DesfirePrintShortFileTypeSettings(FileSettings_t *fsettings) {
fsettings->limitedCredit,
fsettings->value,
fsettings->value
);
);
break;
}
case 0x03:
@ -2450,7 +2450,7 @@ static void DesfirePrintShortFileTypeSettings(FileSettings_t *fsettings) {
fsettings->maxRecordCount,
fsettings->recordSize,
fsettings->recordSize
);
);
break;
}
case 0x05: {
@ -2568,16 +2568,16 @@ static void DesfirePrintFileSettDynPart(uint8_t filetype, uint8_t *data, size_t
if (create) {
PrintAndLogEx(INFO, "Value............ %d / 0x%08X", value, value);
PrintAndLogEx(INFO, "Limited credit... %d - %s"
, limited_credit_enabled
, ((limited_credit_enabled & 1) != 0) ? "enabled" : "disabled"
);
, limited_credit_enabled
, ((limited_credit_enabled & 1) != 0) ? "enabled" : "disabled"
);
} else {
PrintAndLogEx(INFO, "Limited credit... %d - %s %d (0x%08X)"
, limited_credit_enabled
, ((limited_credit_enabled & 1) != 0) ? "enabled" : "disabled"
, value
, value
);
, limited_credit_enabled
, ((limited_credit_enabled & 1) != 0) ? "enabled" : "disabled"
, value
, value
);
}
PrintAndLogEx(INFO, "GetValue access... %s", ((limited_credit_enabled & 0x02) != 0) ? "Free" : "Not Free");

View file

@ -420,4 +420,4 @@ int DetectHID(uint8_t *d, uint16_t manufacture) {
}
return -1;
}
}

View file

@ -1060,7 +1060,7 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
indx++;
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF Memory Control") " ---");
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF Memory Control") " ---");
if (len != 3) {
PrintAndLogEx(WARNING, "NDEF Memory Control block size must be 3 instead of %d", len);
} else {

File diff suppressed because it is too large Load diff

View file

@ -149,15 +149,15 @@ static uint8_t get_length_from_header(wiegand_message_t *data) {
} else {
printf("hid preamble detected\n");
len = 32;
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;}
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 {