style
This commit is contained in:
1 parent
b5ecdde19e
commit
7f40ad7f9d
11 files changed
+183
-102
No files matched your search
+29
-29
@@ -419,7 +419,7 @@ static int CmdHf14AConfig(const char *Cmd) {
|
||||
return hf14a_setconfig(&config, verbose);
|
||||
}
|
||||
|
||||
static const char* get_uid_type(iso14a_card_select_t *card) {
|
||||
static const char *get_uid_type(iso14a_card_select_t *card) {
|
||||
|
||||
static char s[60] = {0};
|
||||
memset(s, 0, sizeof(s));
|
||||
@@ -2296,14 +2296,14 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
int16_t fsci = card.ats[1] & 0x0f;
|
||||
|
||||
PrintAndLogEx(INFO, " " _YELLOW_("%02X") "............ T0 TA1 is%s present, TB1 is%s present, "
|
||||
"TC1 is%s present, FSCI is %d (FSC = %d)",
|
||||
card.ats[1],
|
||||
(ta1 ? "" : _RED_(" NOT")),
|
||||
(tb1 ? "" : _RED_(" NOT")),
|
||||
(tc1 ? "" : _RED_(" NOT")),
|
||||
fsci,
|
||||
fsci < ARRAYLEN(atsFSC) ? atsFSC[fsci] : -1
|
||||
);
|
||||
"TC1 is%s present, FSCI is %d (FSC = %d)",
|
||||
card.ats[1],
|
||||
(ta1 ? "" : _RED_(" NOT")),
|
||||
(tb1 ? "" : _RED_(" NOT")),
|
||||
(tc1 ? "" : _RED_(" NOT")),
|
||||
fsci,
|
||||
fsci < ARRAYLEN(atsFSC) ? atsFSC[fsci] : -1
|
||||
);
|
||||
}
|
||||
int pos = 2;
|
||||
if (ta1 && (card.ats_len > pos + 2)) {
|
||||
@@ -2318,12 +2318,12 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
if (strlen(ds) != 0) ds[strlen(ds) - 2] = '\0';
|
||||
if (strlen(dr) != 0) dr[strlen(dr) - 2] = '\0';
|
||||
PrintAndLogEx(INFO, " " _YELLOW_("%02X") "......... TA1 different divisors are%s supported, "
|
||||
"DR: [%s], DS: [%s]",
|
||||
card.ats[pos],
|
||||
((card.ats[pos] & 0x80) ? _RED_(" NOT") : ""),
|
||||
dr,
|
||||
ds
|
||||
);
|
||||
"DR: [%s], DS: [%s]",
|
||||
card.ats[pos],
|
||||
((card.ats[pos] & 0x80) ? _RED_(" NOT") : ""),
|
||||
dr,
|
||||
ds
|
||||
);
|
||||
|
||||
pos++;
|
||||
}
|
||||
@@ -2333,22 +2333,22 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
uint32_t fwi = card.ats[pos] >> 4;
|
||||
|
||||
PrintAndLogEx(INFO, " " _YELLOW_("%02X") "...... TB1 SFGI = %d (SFGT = %s%d/fc), FWI = " _YELLOW_("%d") " (FWT = %d/fc)",
|
||||
card.ats[pos],
|
||||
(sfgi),
|
||||
sfgi ? "" : "(not needed) ",
|
||||
sfgi ? (1 << 12) << sfgi : 0,
|
||||
fwi,
|
||||
(1 << 12) << fwi
|
||||
);
|
||||
card.ats[pos],
|
||||
(sfgi),
|
||||
sfgi ? "" : "(not needed) ",
|
||||
sfgi ? (1 << 12) << sfgi : 0,
|
||||
fwi,
|
||||
(1 << 12) << fwi
|
||||
);
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (tc1 && (card.ats_len > pos + 2)) {
|
||||
PrintAndLogEx(INFO, " " _YELLOW_("%02X") "... TC1 NAD is%s supported, CID is%s supported",
|
||||
card.ats[pos],
|
||||
(card.ats[pos] & 0x01) ? "" : _RED_(" NOT"),
|
||||
(card.ats[pos] & 0x02) ? "" : _RED_(" NOT")
|
||||
);
|
||||
card.ats[pos],
|
||||
(card.ats[pos] & 0x01) ? "" : _RED_(" NOT"),
|
||||
(card.ats[pos] & 0x02) ? "" : _RED_(" NOT")
|
||||
);
|
||||
pos++;
|
||||
}
|
||||
|
||||
@@ -2479,9 +2479,9 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
get_compact_tlv(card.ats + pos, calen);
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "%s - %s"
|
||||
, sprint_hex_inrow(card.ats + pos, calen)
|
||||
, sprint_ascii(card.ats + pos, calen)
|
||||
);
|
||||
, sprint_hex_inrow(card.ats + pos, calen)
|
||||
, sprint_ascii(card.ats + pos, calen)
|
||||
);
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
@@ -9565,13 +9565,13 @@ static int CmdHF14AMfInfo(const char *Cmd) {
|
||||
|
||||
uint8_t k08s[6] = {0xA3, 0x96, 0xEF, 0xA4, 0xE2, 0x4F};
|
||||
if (mfReadBlock(0, 4, k08s, blockdata) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Backdoor key..... " _YELLOW_("%s"), sprint_hex_inrow(k08s, sizeof(k08s)));
|
||||
PrintAndLogEx(SUCCESS, "Backdoor key..... " _YELLOW_("%s"), sprint_hex_inrow(k08s, sizeof(k08s)));
|
||||
fKeyType = MF_KEY_BD08S;
|
||||
}
|
||||
|
||||
uint8_t k08[6] = {0xA3, 0x16, 0x67, 0xA8, 0xCE, 0xC1};
|
||||
if (mfReadBlock(0, 4, k08, blockdata) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Backdoor key..... " _YELLOW_("%02X%02X%02X%02X%02X%02X"), k08[0], k08[1], k08[2], k08[3], k08[4], k08[5]);
|
||||
PrintAndLogEx(SUCCESS, "Backdoor key..... " _YELLOW_("%02X%02X%02X%02X%02X%02X"), k08[0], k08[1], k08[2], k08[3], k08[4], k08[5]);
|
||||
fKeyType = MF_KEY_BD08;
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -270,7 +270,7 @@ static int get_ulc_3des_key_magic(uint64_t magic_type, uint8_t *key) {
|
||||
reverse_array(d, 8);
|
||||
reverse_array(d + 8, 8);
|
||||
memcpy(key, d, MFBLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
return resp.status;
|
||||
}
|
||||
@@ -2770,10 +2770,10 @@ static int CmdHF14AMfUWrBl(const char *Cmd) {
|
||||
int res = 0;
|
||||
if (datalen == 16) {
|
||||
// Comp write may take 16bytes, but only write 4bytes. See UL-C datasheet
|
||||
for (uint8_t i = 0; i < 4; i++ ) {
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
|
||||
res = mfu_write_block(d, 4, has_auth_key, has_pwd, auth_key_ptr, blockno + i);
|
||||
if ( res == PM3_SUCCESS) {
|
||||
if (res == PM3_SUCCESS) {
|
||||
d += 4;
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Write ( %s )", _RED_("fail"));
|
||||
@@ -2788,23 +2788,23 @@ static int CmdHF14AMfUWrBl(const char *Cmd) {
|
||||
|
||||
} else {
|
||||
res = mfu_write_block(data, datalen, has_auth_key, has_pwd, auth_key_ptr, blockno);
|
||||
switch (res) {
|
||||
case PM3_SUCCESS: {
|
||||
PrintAndLogEx(SUCCESS, "Write ( " _GREEN_("ok") " )");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf mfu rdbl -b %u") "` to verify ", blockno);
|
||||
break;
|
||||
switch (res) {
|
||||
case PM3_SUCCESS: {
|
||||
PrintAndLogEx(SUCCESS, "Write ( " _GREEN_("ok") " )");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf mfu rdbl -b %u") "` to verify ", blockno);
|
||||
break;
|
||||
}
|
||||
case PM3_ESOFT: {
|
||||
PrintAndLogEx(FAILED, "Write ( " _RED_("fail") " )");
|
||||
PrintAndLogEx(HINT, "Check password / key!");
|
||||
break;
|
||||
}
|
||||
case PM3_ETIMEOUT:
|
||||
default: {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
break;
|
||||
}
|
||||
}
|
||||
case PM3_ESOFT: {
|
||||
PrintAndLogEx(FAILED, "Write ( " _RED_("fail") " )");
|
||||
PrintAndLogEx(HINT, "Check password / key!");
|
||||
break;
|
||||
}
|
||||
case PM3_ETIMEOUT:
|
||||
default: {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
+43
-35
@@ -48,14 +48,14 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
" lf hitag hts read --nrar 0102030411223344 -> Hitag S, challenge mode\n"
|
||||
" lf hitag hts read --crypto -> Hitag S, crypto mode, def key\n"
|
||||
" lf hitag hts read -k 4F4E4D494B52 -> Hitag S, crypto mode\n\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
|
||||
arg_lit0(NULL, "crypto", "crypto mode"),
|
||||
arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_param_end
|
||||
arg_param_begin,
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
|
||||
arg_lit0(NULL, "crypto", "crypto mode"),
|
||||
arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
|
||||
@@ -173,16 +173,16 @@ static int CmdLFHitagSWrite(const char *Cmd) {
|
||||
" lf hitag hts write -p 6 -d 01020304 --nrar 0102030411223344 -> Hitag S, challenge mode\n"
|
||||
" lf hitag hts write -p 6 -d 01020304 --crypto -> Hitag S, crypto mode, default key\n"
|
||||
" lf hitag hts write -p 6 -d 01020304 -k 4F4E4D494B52 -> Hitag S, crypto mode\n\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
|
||||
arg_lit0(NULL, "crypto", "crypto mode"),
|
||||
arg_str0("k", "key", "<hex>", "key, 6 hex bytes"),
|
||||
arg_int1("p", "page", "<dec>", "page address to write to"),
|
||||
arg_str1("d", "data", "<hex>", "data, 4 hex bytes"),
|
||||
arg_param_end
|
||||
arg_param_begin,
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
|
||||
arg_lit0(NULL, "crypto", "crypto mode"),
|
||||
arg_str0("k", "key", "<hex>", "key, 6 hex bytes"),
|
||||
arg_int1("p", "page", "<dec>", "page address to write to"),
|
||||
arg_str1("d", "data", "<hex>", "data, 4 hex bytes"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
||||
@@ -290,13 +290,15 @@ static int CmdLFHitagSList(const char *Cmd) {
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"list", CmdLFHitagSList, AlwaysAvailable, "List Hitag S trace history"},
|
||||
{"-----------", CmdHelp, IfPm3Hitag, "----------------------- " _CYAN_(
|
||||
"General") " ------------------------"},
|
||||
{"read", CmdLFHitagSRead, IfPm3Hitag, "Read Hitag S memory"},
|
||||
{"write", CmdLFHitagSWrite, IfPm3Hitag, "Write Hitag S page"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"list", CmdLFHitagSList, AlwaysAvailable, "List Hitag S trace history"},
|
||||
{
|
||||
"-----------", CmdHelp, IfPm3Hitag, "----------------------- " _CYAN_(
|
||||
"General") " ------------------------"
|
||||
},
|
||||
{"read", CmdLFHitagSRead, IfPm3Hitag, "Read Hitag S memory"},
|
||||
{"write", CmdLFHitagSWrite, IfPm3Hitag, "Write Hitag S page"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
@@ -312,34 +314,40 @@ int CmdLFHitagS(const char *Cmd) {
|
||||
|
||||
hitags_config_t hitags_config_unpack(const uint8_t *config_bytes) {
|
||||
hitags_config_t result = {
|
||||
.memory_type = (config_bytes[0] >> 0) & 0x03,
|
||||
.authentication = (config_bytes[1] >> 7) & 0x01,
|
||||
.ttf_coding = (config_bytes[1] >> 6) & 0x01,
|
||||
.ttf_data_rate = (config_bytes[1] >> 4) & 0x03,
|
||||
.ttf_mode = (config_bytes[1] >> 2) & 0x03,
|
||||
.lock_config = (config_bytes[1] >> 1) & 0x01,
|
||||
.lock_key = (config_bytes[1] >> 0) & 0x01
|
||||
.memory_type = (config_bytes[0] >> 0) & 0x03,
|
||||
.authentication = (config_bytes[1] >> 7) & 0x01,
|
||||
.ttf_coding = (config_bytes[1] >> 6) & 0x01,
|
||||
.ttf_data_rate = (config_bytes[1] >> 4) & 0x03,
|
||||
.ttf_mode = (config_bytes[1] >> 2) & 0x03,
|
||||
.lock_config = (config_bytes[1] >> 1) & 0x01,
|
||||
.lock_key = (config_bytes[1] >> 0) & 0x01
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
void hitags_config_print(hitags_config_t config) {
|
||||
PrintAndLogEx(INFO, " Memory type...... " _GREEN_("%s"),
|
||||
(const char *[]) {"Hitag S 32", "Hitag S 256", "Hitag S 2048",
|
||||
"Unknown Hitag S/8211"}[config.memory_type]);
|
||||
(const char *[]) {
|
||||
"Hitag S 32", "Hitag S 256", "Hitag S 2048",
|
||||
"Unknown Hitag S/8211"
|
||||
}[config.memory_type]);
|
||||
|
||||
PrintAndLogEx(INFO, " Authenticaion.... %s", config.authentication ? _YELLOW_("Yes") : "No");
|
||||
|
||||
PrintAndLogEx(INFO, " TTF coding....... %s",
|
||||
(const char *[]) {"Manchester", "Biphase"}[config.ttf_coding]);
|
||||
(const char *[]) {"Manchester", "Biphase"}[config.ttf_coding]);
|
||||
|
||||
PrintAndLogEx(INFO, " TTF data rate.... %s",
|
||||
(const char *[]) {"4 kBit", "8 kBit", "2 kBit",
|
||||
"2 kBit and Pigeon Race Standard"}[config.ttf_data_rate]);
|
||||
(const char *[]) {
|
||||
"4 kBit", "8 kBit", "2 kBit",
|
||||
"2 kBit and Pigeon Race Standard"
|
||||
}[config.ttf_data_rate]);
|
||||
|
||||
PrintAndLogEx(INFO, " TTF mode......... %s",
|
||||
(const char *[]) {"TTF Mode disabled (= RTF Mode)", "Page 4, Page 5",
|
||||
"Page 4, Page 5, Page 6, Page 7", "Page 4"}[config.ttf_mode]);
|
||||
(const char *[]) {
|
||||
"TTF Mode disabled (= RTF Mode)", "Page 4, Page 5",
|
||||
"Page 4, Page 5, Page 6, Page 7", "Page 4"
|
||||
}[config.ttf_mode]);
|
||||
|
||||
PrintAndLogEx(INFO, " Config locked.... %s", config.lock_config ? _RED_("Yes") : _GREEN_("No"));
|
||||
PrintAndLogEx(INFO, " Key/PWD locked... %s", config.lock_key ? _RED_("Yes") : _GREEN_("No"));
|
||||
|
||||
@@ -2519,7 +2519,7 @@ static int CmdT55xxDump(const char *Cmd) {
|
||||
arg_str0("f", "file", "<fn>", "filename (default is generated on blk 0)"),
|
||||
arg_lit0("o", "override", "override, force pwd read despite danger to card"),
|
||||
arg_str0("p", "pwd", "<hex>", "password (4 hex bytes)"),
|
||||
arg_lit0(NULL, "ns", "no save"),
|
||||
arg_lit0(NULL, "ns", "no save to file"),
|
||||
};
|
||||
uint8_t idx = 5;
|
||||
arg_add_t55xx_downloadlink(argtable, &idx, T55XX_DLMODE_SINGLE, T55XX_DLMODE_SINGLE);
|
||||
|
||||
@@ -669,6 +669,10 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 0, "lf hitag chk" },
|
||||
{ 1, "lf hitag lookup" },
|
||||
{ 0, "lf hitag ta" },
|
||||
{ 1, "lf hitag hts help" },
|
||||
{ 1, "lf hitag hts list" },
|
||||
{ 0, "lf hitag hts read" },
|
||||
{ 0, "lf hitag hts write" },
|
||||
{ 1, "lf idteck help" },
|
||||
{ 1, "lf idteck demod" },
|
||||
{ 0, "lf idteck reader" },
|
||||
|
||||
Reference in new issue
Block a user