rename hts read/write commands to rdbl/wrbl to match rest of the client. added a lf hitag hts reader comamnd, modified the lf search to identify hitag2/s/82xx in the chipset detection
This commit is contained in:
1 parent
dd32fceb54
commit
db1b28f327
17 files changed
+394
-164
No files matched your search
+131
-33
@@ -36,27 +36,84 @@
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static const char *hts_get_type_str(uint32_t uid) {
|
||||
//uid s/n ********
|
||||
uint8_t type = (uid >> 4) & 0xF;
|
||||
switch (type) {
|
||||
case 1:
|
||||
return "PCF 7936";
|
||||
case 2:
|
||||
return "PCF 7946";
|
||||
case 3:
|
||||
return "PCF 7947";
|
||||
case 4:
|
||||
return "PCF 7942/44";
|
||||
case 5:
|
||||
return "PCF 7943";
|
||||
case 6:
|
||||
return "PCF 7941";
|
||||
case 7:
|
||||
return "PCF 7952";
|
||||
case 9:
|
||||
return "PCF 7945";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
static bool hts_get_uid(uint32_t *uid) {
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_HITAGS_UID, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_LF_HITAGS_UID, &resp, 1500) == false) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - failed getting UID");
|
||||
PrintAndLogEx(WARNING, "got false");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uid) {
|
||||
*uid = bytes_to_num(resp.data.asBytes, HITAG_UID_SIZE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int read_hts_uid(void) {
|
||||
uint32_t uid = 0;
|
||||
if (hts_get_uid(&uid) == false) {
|
||||
PrintAndLogEx(WARNING, "got false");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
||||
PrintAndLogEx(SUCCESS, "TYPE... " _GREEN_("%s"), hts_get_type_str(uid));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdLFHitagSRead(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf hitag hts read",
|
||||
CLIParserInit(&ctx, "lf hitag hts rdbl",
|
||||
"Read Hitag S memory.\n\n"
|
||||
" Crypto mode: \n"
|
||||
" - key format ISK high + ISK low\n"
|
||||
" - default key 4F4E4D494B52 (ONMIKR)\n\n"
|
||||
" 8268/8310 password mode: \n"
|
||||
" - default password BBDD3399\n",
|
||||
" lf hitag hts read -> Hitag S/8211, plain mode\n"
|
||||
" lf hitag hts read --8 -k BBDD3399 -> 8268/8310, password mode\n"
|
||||
" 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"
|
||||
" lf hitag hts rdbl -> Hitag S/8211, plain mode\n"
|
||||
" lf hitag hts rdbl --8 -k BBDD3399 -> 8268/8310, password mode\n"
|
||||
" lf hitag hts rdbl --nrar 0102030411223344 -> Hitag S, challenge mode\n"
|
||||
" lf hitag hts rdbl --crypto -> Hitag S, crypto mode, def key\n"
|
||||
" lf hitag hts rdbl -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, "8", "8268/8310 mode"),
|
||||
arg_lit0("8", "82xx", "8268/8310 mode"),
|
||||
arg_lit0(NULL, "crypto", "crypto mode"),
|
||||
arg_str0("k", "key", "<hex>", "pwd or key, 4 or 6 hex bytes"),
|
||||
arg_param_end
|
||||
@@ -103,13 +160,16 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
if (key_len == 4) {
|
||||
use_82xx = true;
|
||||
}
|
||||
|
||||
if (key_len == 6) {
|
||||
use_crypto = true;
|
||||
}
|
||||
|
||||
if ((key_len == 0) && use_82xx) {
|
||||
memcpy(key, (uint8_t[]) {0xBB, 0xDD, 0x33, 0x99}, 4);
|
||||
memcpy(key, "\xBB\xDD\x33\x99", 4);
|
||||
key_len = 4;
|
||||
}
|
||||
|
||||
if ((key_len == 0) && use_crypto) {
|
||||
memcpy(key, "ONMIKR", 6);
|
||||
key_len = 6;
|
||||
@@ -120,7 +180,9 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
if (auth_methods > 1) {
|
||||
PrintAndLogEx(WARNING, "Specify only one authentication mode");
|
||||
return PM3_EINVARG;
|
||||
} else if (auth_methods == 0) {
|
||||
}
|
||||
|
||||
if (auth_methods == 0) {
|
||||
use_plain = true;
|
||||
}
|
||||
|
||||
@@ -176,7 +238,8 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Data") " ----------------------------------");
|
||||
|
||||
uint32_t size = (const int[]) {4, 32, 256, 0}[config.memory_type];
|
||||
const int hts_mem_sizes[] = {4, 32, 256, 0};
|
||||
uint32_t size = hts_mem_sizes[config.memory_type];
|
||||
|
||||
print_hex_break(data, size, HITAGS_PAGE_SIZE);
|
||||
|
||||
@@ -185,18 +248,18 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
|
||||
static int CmdLFHitagSWrite(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf hitag hts write",
|
||||
CLIParserInit(&ctx, "lf hitag hts wrbl",
|
||||
"Write a page in Hitag S memory.\n"
|
||||
" Crypto mode: \n"
|
||||
" - key format ISK high + ISK low\n"
|
||||
" - default key 4F4E4D494B52 (ONMIKR)\n\n"
|
||||
" 8268/8310 password mode: \n"
|
||||
" - default password BBDD3399\n",
|
||||
" lf hitag hts write -p 6 -d 01020304 -> Hitag S/8211, plain mode\n"
|
||||
" lf hitag hts write -p 6 -d 01020304 --8 -k BBDD3399 -> 8268/8310, password mode\n"
|
||||
" 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"
|
||||
" lf hitag hts wrbl -p 6 -d 01020304 -> Hitag S/8211, plain mode\n"
|
||||
" lf hitag hts wrbl -p 6 -d 01020304 --8 -k BBDD3399 -> 8268/8310, password mode\n"
|
||||
" lf hitag hts wrbl -p 6 -d 01020304 --nrar 0102030411223344 -> Hitag S, challenge mode\n"
|
||||
" lf hitag hts wrbl -p 6 -d 01020304 --crypto -> Hitag S, crypto mode, default key\n"
|
||||
" lf hitag hts wrbl -p 6 -d 01020304 -k 4F4E4D494B52 -> Hitag S, crypto mode\n\n"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
@@ -327,28 +390,40 @@ static int CmdLFHitagSWrite(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdLFHitagSList(const char *Cmd) {
|
||||
return CmdTraceListAlias(Cmd, "lf hitag hts", "hitags");
|
||||
}
|
||||
static int CmdLFHitagSReader(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf hitag hts reader",
|
||||
"Act as a Hitag S reader. Look for Hitag S tags until Enter or the pm3 button is pressed\n",
|
||||
"lf hitag hts reader\n"
|
||||
"lf hitag hts reader -@ -> Continuous mode"
|
||||
);
|
||||
|
||||
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}
|
||||
};
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("@", NULL, "continuous reader mode"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool cm = arg_get_lit(ctx, 1);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (cm) {
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
||||
}
|
||||
|
||||
do {
|
||||
// read UID
|
||||
uint32_t uid = 0;
|
||||
if (hts_get_uid(&uid)) {
|
||||
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
||||
}
|
||||
} while (cm && kbd_enter_pressed() == false);
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void) Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFHitagS(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
static int CmdLFHitagSList(const char *Cmd) {
|
||||
return CmdTraceListAlias(Cmd, "lf hitag hts", "hitags");
|
||||
}
|
||||
|
||||
hitags_config_t hitags_config_unpack(const uint8_t *config_bytes) {
|
||||
@@ -391,3 +466,26 @@ void hitags_config_print(hitags_config_t config) {
|
||||
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"));
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"list", CmdLFHitagSList, AlwaysAvailable, "List Hitag S trace history"},
|
||||
{"-----------", CmdHelp, IfPm3Hitag, "----------------------- " _CYAN_("General") " ------------------------"},
|
||||
{"reader", CmdLFHitagSReader, IfPm3Hitag, "Act like a Hitag S reader"},
|
||||
{"rdbl", CmdLFHitagSRead, IfPm3Hitag, "Read Hitag S memory"},
|
||||
{"wrbl", CmdLFHitagSWrite, IfPm3Hitag, "Write Hitag S page"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static int CmdHelp(const char *Cmd) {
|
||||
(void) Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFHitagS(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user