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
@@ -4130,7 +4130,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
||||
SendCommandNG(CMD_HF_ISO14443A_GET_CONFIG, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_HF_ISO14443A_GET_CONFIG, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
return PM3_ETIMEOUT;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
memcpy(&config, resp.data.asBytes, sizeof(hf14a_config));
|
||||
int8_t oldconfig_bcc = config.forcebcc;
|
||||
|
||||
+28
-14
@@ -40,6 +40,7 @@
|
||||
#include "cmdlfem4x70.h" // for em4x70
|
||||
#include "cmdlfhid.h" // for hid menu
|
||||
#include "cmdlfhitag.h" // for hitag menu
|
||||
#include "cmdlfhitaghts.h" // for hitag S sub commands
|
||||
#include "cmdlfidteck.h" // for idteck menu
|
||||
#include "cmdlfio.h" // for ioprox menu
|
||||
#include "cmdlfcotag.h" // for COTAG menu
|
||||
@@ -1555,7 +1556,9 @@ static bool check_chiptype(bool getDeviceData) {
|
||||
|
||||
bool retval = false;
|
||||
|
||||
if (!getDeviceData) return retval;
|
||||
if (getDeviceData == false) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
//Save the state of the Graph and Demod Buffers
|
||||
buffer_savestate_t saveState_gb = save_bufferS32(g_GraphBuffer, g_GraphTraceLen);
|
||||
@@ -1566,7 +1569,7 @@ static bool check_chiptype(bool getDeviceData) {
|
||||
|
||||
//check for em4x05/em4x69 chips first
|
||||
uint32_t word = 0;
|
||||
if (IfPm3EM4x50() && em4x05_isblock0(&word)) {
|
||||
if (em4x05_isblock0(&word)) {
|
||||
PrintAndLogEx(SUCCESS, "Chipset detection: " _GREEN_("EM4x05 / EM4x69"));
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf em 4x05`") " commands");
|
||||
retval = true;
|
||||
@@ -1581,6 +1584,27 @@ static bool check_chiptype(bool getDeviceData) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
if (IfPm3Hitag()) {
|
||||
|
||||
// Hitag 2
|
||||
if (ht2_read_uid() == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Chipset detection: " _GREEN_("Hitag 2"));
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf hitag`") " commands");
|
||||
retval = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Hitag S
|
||||
if (read_hts_uid() == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "Chipset detection: " _GREEN_("Hitag S / 82xx"));
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf hitag hts`") " commands");
|
||||
retval = true;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !defined ICOPYX
|
||||
// check for em4x50 chips
|
||||
if (IfPm3EM4x50() && detect_4x50_block()) {
|
||||
@@ -1675,8 +1699,9 @@ int CmdLFfind(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
int found = 0;
|
||||
bool is_online = (g_session.pm3_present && (use_gb == false));
|
||||
if (is_online)
|
||||
if (is_online) {
|
||||
lf_read(false, 30000);
|
||||
}
|
||||
|
||||
size_t min_length = 2000;
|
||||
if (g_GraphTraceLen < min_length) {
|
||||
@@ -1697,17 +1722,6 @@ int CmdLFfind(const char *Cmd) {
|
||||
// only run these tests if device is online
|
||||
if (is_online) {
|
||||
|
||||
if (IfPm3Hitag()) {
|
||||
if (readHitagUid() == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Hitag") " found!");
|
||||
if (search_cont) {
|
||||
found++;
|
||||
} else {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined ICOPYX
|
||||
if (IfPm3EM4x50()) {
|
||||
if (read_em4x50_uid() == PM3_SUCCESS) {
|
||||
|
||||
+14
-13
@@ -794,7 +794,7 @@ static const char *identify_transponder_hitag2(uint32_t uid) {
|
||||
return "";
|
||||
}
|
||||
|
||||
static bool getHitag2Uid(uint32_t *uid) {
|
||||
static bool ht2_get_uid(uint32_t *uid) {
|
||||
|
||||
lf_hitag_data_t packet;
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
@@ -835,7 +835,7 @@ static int CmdLFHitagInfo(const char *Cmd) {
|
||||
|
||||
// read UID
|
||||
uint32_t uid = 0;
|
||||
if (getHitag2Uid(&uid) == false) {
|
||||
if (ht2_get_uid(&uid) == false) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
// how to determine Hitag types?
|
||||
@@ -886,7 +886,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||
do {
|
||||
// read UID
|
||||
uint32_t uid = 0;
|
||||
if (getHitag2Uid(&uid)) {
|
||||
if (ht2_get_uid(&uid)) {
|
||||
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
||||
}
|
||||
} while (cm && kbd_enter_pressed() == false);
|
||||
@@ -2475,6 +2475,17 @@ static int CmdLFHitag2Selftest(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int ht2_read_uid(void) {
|
||||
uint32_t uid = 0;
|
||||
if (ht2_get_uid(&uid) == false) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
||||
PrintAndLogEx(SUCCESS, "TYPE... " _GREEN_("%s"), getHitagTypeStr(uid));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"list", CmdLFHitagList, AlwaysAvailable, "List Hitag trace history"},
|
||||
@@ -2515,14 +2526,4 @@ int CmdLFHitag(const char *Cmd) {
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
int readHitagUid(void) {
|
||||
uint32_t uid = 0;
|
||||
if (getHitag2Uid(&uid) == false) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "UID.... " _GREEN_("%08X"), uid);
|
||||
PrintAndLogEx(SUCCESS, "TYPE... " _GREEN_("%s"), getHitagTypeStr(uid));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
int CmdLFHitag(const char *Cmd);
|
||||
|
||||
int readHitagUid(void);
|
||||
int ht2_read_uid(void);
|
||||
void annotateHitag1(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response);
|
||||
void annotateHitag2(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, uint8_t bits, bool is_response, const uint64_t *keys, uint32_t keycount, bool isdecrypted);
|
||||
void annotateHitagS(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response);
|
||||
|
||||
+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);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,9 @@ typedef struct {
|
||||
|
||||
int CmdLFHitagS(const char *Cmd);
|
||||
|
||||
int read_hts_uid(void);
|
||||
hitags_config_t hitags_config_unpack(const uint8_t *config_bytes);
|
||||
|
||||
void hitags_config_pack(hitags_config_t config, uint8_t *out);
|
||||
|
||||
void hitags_config_print(hitags_config_t config);
|
||||
|
||||
#endif //CMDLFHITAGS_H__
|
||||
@@ -210,7 +210,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
||||
|
||||
int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t *keyBlock, uint64_t *key) {
|
||||
if (key) {
|
||||
*key = -1;
|
||||
*key = -1;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||
|
||||
@@ -273,6 +273,7 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 0, "hf iclass reader" },
|
||||
{ 0, "hf iclass restore" },
|
||||
{ 0, "hf iclass sniff" },
|
||||
{ 0, "hf iclass spoof" },
|
||||
{ 1, "hf iclass view" },
|
||||
{ 0, "hf iclass wrbl" },
|
||||
{ 0, "hf iclass creditepurse" },
|
||||
@@ -671,8 +672,9 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 0, "lf hitag ta" },
|
||||
{ 1, "lf hitag hts help" },
|
||||
{ 1, "lf hitag hts list" },
|
||||
{ 0, "lf hitag hts read" },
|
||||
{ 0, "lf hitag hts write" },
|
||||
{ 0, "lf hitag hts reader" },
|
||||
{ 0, "lf hitag hts rdbl" },
|
||||
{ 0, "lf hitag hts wrbl" },
|
||||
{ 1, "lf idteck help" },
|
||||
{ 1, "lf idteck demod" },
|
||||
{ 0, "lf idteck reader" },
|
||||
|
||||
Reference in new issue
Block a user