make style
This commit is contained in:
1 parent
8a602ed99d
commit
4ed57c7c4d
57 files changed
+878
-878
No files matched your search
+10
-10
@@ -86,7 +86,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
char *cmd = (char *) ((*env)->GetStringUTFChars(env, cmd_, 0));
|
||||
char *cmd = (char *)((*env)->GetStringUTFChars(env, cmd_, 0));
|
||||
int ret = CommandReceived(cmd);
|
||||
if (ret == 99) {
|
||||
// exit / quit
|
||||
@@ -102,7 +102,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||
* Is client running!
|
||||
* */
|
||||
jboolean IsClientRunning(JNIEnv *env, jobject instance) {
|
||||
return (jboolean) ((jboolean) conn.run);
|
||||
return (jboolean)((jboolean) conn.run);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -114,7 +114,7 @@ jboolean TestPm3(JNIEnv *env, jobject instance) {
|
||||
return false;
|
||||
}
|
||||
bool ret = (TestProxmark() == PM3_SUCCESS);
|
||||
return (jboolean) (ret);
|
||||
return (jboolean)(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -141,18 +141,18 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
}
|
||||
jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4");
|
||||
JNINativeMethod methods[] = {
|
||||
{"startExecute", "(Ljava/lang/String;)I", (void *) Console},
|
||||
{"stopExecute", "()V", (void *) ClosePm3},
|
||||
{"isExecuting", "()Z", (void *) IsClientRunning}
|
||||
{"startExecute", "(Ljava/lang/String;)I", (void *) Console},
|
||||
{"stopExecute", "()V", (void *) ClosePm3},
|
||||
{"isExecuting", "()Z", (void *) IsClientRunning}
|
||||
};
|
||||
|
||||
JNINativeMethod methods1[] = {
|
||||
{"testPm3", "()Z", (void *) TestPm3},
|
||||
{"closePm3", "()V", ClosePm3}
|
||||
{"testPm3", "()Z", (void *) TestPm3},
|
||||
{"closePm3", "()V", ClosePm3}
|
||||
};
|
||||
|
||||
if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) !=
|
||||
JNI_OK) {
|
||||
JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -164,4 +164,4 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
(*jniEnv)->DeleteLocalRef(jniEnv, clazz);
|
||||
(*jniEnv)->DeleteLocalRef(jniEnv, clz_test);
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
}
|
||||
@@ -2317,7 +2317,7 @@ static int CmdDataNDEF(const char *Cmd) {
|
||||
"Samples:\n"
|
||||
_YELLOW_("\tdata ndef -d 9101085402656e48656c6c6f5101085402656e576f726c64\n")
|
||||
_YELLOW_("\tdata ndef -d 0103d020240203e02c040300fe\n")
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
||||
@@ -339,7 +339,7 @@ static int CmdFlashMemSpiFFSDump(const char *Cmd) {
|
||||
saveFile(filename, ".bin", dump, len);
|
||||
if (eml) {
|
||||
uint8_t eml_len = 16;
|
||||
|
||||
|
||||
if (strstr(filename, "class") != NULL)
|
||||
eml_len = 8;
|
||||
else if (strstr(filename, "mfu") != NULL)
|
||||
@@ -421,12 +421,12 @@ out:
|
||||
}
|
||||
|
||||
static int CmdFlashMemSpiFFSWipe(const char *Cmd) {
|
||||
|
||||
|
||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') {
|
||||
return usage_flashmemspiffs_wipe();
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "Wiping all files from SPIFFS FileSystem");
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
|
||||
+3
-3
@@ -285,16 +285,16 @@ int CmdHFSniff(const char *Cmd) {
|
||||
uint16_t len;
|
||||
} PACKED;
|
||||
struct r *retval = (struct r *)resp.data.asBytes;
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "HF sniff (%u samples)", retval->len);
|
||||
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data hpf") "` to remove offset");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data plot") "` to view");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data save") "` to save");
|
||||
|
||||
// download bigbuf_malloc:d.
|
||||
// download bigbuf_malloc:d.
|
||||
// it reserve memory from the higher end.
|
||||
// At the moment, sniff takes all free memory in bigbuff. If this changes,
|
||||
// At the moment, sniff takes all free memory in bigbuff. If this changes,
|
||||
// we can't start from beginning idx 0 but from that hi-to-start-of-allocated.
|
||||
uint32_t start = pm3_capabilities.bigbuf_size - retval->len;
|
||||
int res = getSamplesEx(start, start, false);
|
||||
|
||||
+149
-149
@@ -384,8 +384,8 @@ static inline uint32_t countones(uint64_t a) {
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
const char * card_types[] = {
|
||||
|
||||
const char *card_types[] = {
|
||||
"PicoPass 16K / 16", // 000
|
||||
"PicoPass 32K with current book 16K / 16", // 001
|
||||
"Unknown Card Type!", // 010
|
||||
@@ -435,7 +435,7 @@ static void fuse_config(const picopass_hdr *hdr) {
|
||||
else
|
||||
PrintAndLogEx(SUCCESS, "Coding: " _YELLOW_("ISO 14443-B only"));
|
||||
}
|
||||
|
||||
|
||||
uint8_t pagemap = get_pagemap(hdr);
|
||||
switch (pagemap) {
|
||||
case 0x0:
|
||||
@@ -458,25 +458,25 @@ static void fuse_config(const picopass_hdr *hdr) {
|
||||
PrintAndLogEx(INFO, " RA: Read access not enabled");
|
||||
|
||||
PrintAndLogEx(INFO,
|
||||
"App limit " _YELLOW_("0x%02X") ", OTP " _YELLOW_("0x%02X%02X") ", Block write lock " _YELLOW_("0x%02X")
|
||||
, hdr->conf.app_limit
|
||||
, hdr->conf.otp[1]
|
||||
, hdr->conf.otp[0]
|
||||
, hdr->conf.block_writelock
|
||||
);
|
||||
"App limit " _YELLOW_("0x%02X") ", OTP " _YELLOW_("0x%02X%02X") ", Block write lock " _YELLOW_("0x%02X")
|
||||
, hdr->conf.app_limit
|
||||
, hdr->conf.otp[1]
|
||||
, hdr->conf.otp[0]
|
||||
, hdr->conf.block_writelock
|
||||
);
|
||||
PrintAndLogEx(INFO,
|
||||
" Chip " _YELLOW_("0x%02X") ", Mem " _YELLOW_("0x%02X") ", EAS " _YELLOW_("0x%02X") ", Fuses " _YELLOW_("0x%02X")
|
||||
, hdr->conf.chip_config
|
||||
, hdr->conf.mem_config
|
||||
, hdr->conf.eas
|
||||
, hdr->conf.fuses
|
||||
);
|
||||
" Chip " _YELLOW_("0x%02X") ", Mem " _YELLOW_("0x%02X") ", EAS " _YELLOW_("0x%02X") ", Fuses " _YELLOW_("0x%02X")
|
||||
, hdr->conf.chip_config
|
||||
, hdr->conf.mem_config
|
||||
, hdr->conf.eas
|
||||
, hdr->conf.fuses
|
||||
);
|
||||
}
|
||||
|
||||
static void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *app_areas, uint8_t *kb) {
|
||||
// How to determine chip type
|
||||
// How to determine chip type
|
||||
|
||||
// mem-bit 7 = 16K
|
||||
// mem-bit 7 = 16K
|
||||
// mem-bit 5 = Book
|
||||
// mem-bit 4 = 2K
|
||||
// chip-bit 4 = Multi App
|
||||
@@ -532,7 +532,7 @@ static void mem_app_config(const picopass_hdr *hdr) {
|
||||
uint8_t pagemap = get_pagemap(hdr);
|
||||
|
||||
PrintAndLogEx(INFO, "------ " _CYAN_("Memory") " ------");
|
||||
|
||||
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
PrintAndLogEx(INFO, " %u KBits (%u bytes)", kb, app2_limit * 8);
|
||||
PrintAndLogEx(INFO, " Tag has not App Areas");
|
||||
@@ -540,7 +540,7 @@ static void mem_app_config(const picopass_hdr *hdr) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, " %u KBits/%u App Areas (%u bytes)", kb, app_areas, (app2_limit + 1) * 8);
|
||||
PrintAndLogEx(INFO, " AA1 blocks %u { 0x06 - 0x%02X (06 - %02d) }", app1_limit , app1_limit + 5, app1_limit + 5);
|
||||
PrintAndLogEx(INFO, " AA1 blocks %u { 0x06 - 0x%02X (06 - %02d) }", app1_limit, app1_limit + 5, app1_limit + 5);
|
||||
PrintAndLogEx(INFO, " AA2 blocks %u { 0x%02X - 0x%02X (%02d - %02d) }", app2_limit - app1_limit, app1_limit + 5 + 1, app2_limit, app1_limit + 5 + 1, app2_limit);
|
||||
|
||||
PrintAndLogEx(INFO, "------ " _CYAN_("KeyAccess") " ------");
|
||||
@@ -592,18 +592,18 @@ static int CmdHFiClassSniff(const char *Cmd) {
|
||||
"Usage:\n"
|
||||
_YELLOW_("\thf iclass sniff") "\n"
|
||||
_YELLOW_("\thf iclass sniff -j") " -> jam e-purse updates\n"
|
||||
);
|
||||
|
||||
void* argtable[] = {
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("j", "jam", "Jam (prevent) e-purse updates"),
|
||||
arg_param_end
|
||||
};
|
||||
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool jam_epurse_update = arg_get_lit(ctx, 1);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
const uint8_t update_epurse_sequence[2] = {0x87, 0x02};
|
||||
|
||||
struct {
|
||||
@@ -611,17 +611,17 @@ static int CmdHFiClassSniff(const char *Cmd) {
|
||||
uint8_t jam_search_string[2];
|
||||
} PACKED payload;
|
||||
|
||||
if (jam_epurse_update) {
|
||||
if (jam_epurse_update) {
|
||||
payload.jam_search_len = sizeof(update_epurse_sequence);
|
||||
memcpy(payload.jam_search_string, update_epurse_sequence, sizeof(payload.jam_search_string));
|
||||
}
|
||||
|
||||
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_SNIFF, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
|
||||
WaitForResponse(CMD_HF_ICLASS_SNIFF, &resp);
|
||||
|
||||
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass list") "` to look at the collected trace");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("trace save h") "` to save tracelog for later analysing");
|
||||
return PM3_SUCCESS;
|
||||
@@ -790,7 +790,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
}
|
||||
saveFile("iclass_mac_attack_keyroll_B", ".bin", dump, datalen);
|
||||
free(dump);
|
||||
|
||||
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass loclass h") "` to recover elite key");
|
||||
break;
|
||||
}
|
||||
@@ -801,7 +801,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
uint8_t numberOfCSNs = 0;
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_ICLASS_SIMULATE, sim_type, numberOfCSNs, 1, CSN, 8);
|
||||
|
||||
|
||||
if (sim_type == ICLASS_SIM_MODE_FULL)
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass esave h") "` to save the emulator memory to file");
|
||||
break;
|
||||
@@ -819,7 +819,7 @@ int read_iclass_csn(bool loop, bool verbose) {
|
||||
uint32_t flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE);
|
||||
int res = PM3_SUCCESS;
|
||||
|
||||
while (kbd_enter_pressed() == false) {
|
||||
while (kbd_enter_pressed() == false) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_ICLASS_READER, flags, 0, 0, NULL, 0);
|
||||
@@ -840,17 +840,17 @@ int read_iclass_csn(bool loop, bool verbose) {
|
||||
}
|
||||
|
||||
picopass_hdr *hdr = (picopass_hdr *)resp.data.asBytes;
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, " CSN: " _GREEN_("%s"), sprint_hex(hdr->csn, sizeof(hdr->csn)));
|
||||
PrintAndLogEx(SUCCESS, " Config: " _GREEN_("%s"), sprint_hex((uint8_t *)&hdr->conf, sizeof(hdr->conf)));
|
||||
|
||||
|
||||
if (loop == false)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DropField();
|
||||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ static int CmdHFiClassReader(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_iclass_reader();
|
||||
bool loop_read = (cmdp == '1') ? false : true;
|
||||
|
||||
|
||||
return read_iclass_csn(loop_read, true);
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ static int CmdHFiClassReader_Replay(const char *Cmd) {
|
||||
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_REPLAY, (uint8_t *)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_ICLASS_REPLAY, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
while (true) {
|
||||
printf(".");
|
||||
@@ -980,7 +980,7 @@ static int CmdHFiClassReader_Replay(const char *Cmd) {
|
||||
saveFile(filename, ".bin", tag_data, bytes_got);
|
||||
saveFileEML(filename, tag_data, bytes_got, 8);
|
||||
saveFileJSON(filename, jsfIclass, tag_data, bytes_got, NULL);
|
||||
|
||||
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass decrypt") "` to decrypt dump file");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass view") "` to view dump file");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -1157,9 +1157,9 @@ static int CmdHFiClassESave(const char *Cmd) {
|
||||
saveFileEML(filename, dump, bytes, 8);
|
||||
saveFileJSON(filename, jsfIclass, dump, bytes, NULL);
|
||||
free(dump);
|
||||
|
||||
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass readtagfile ") "` to view dump file");
|
||||
return PM3_SUCCESS;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
@@ -1351,7 +1351,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "No credential found.");
|
||||
}
|
||||
|
||||
|
||||
// decode block 9
|
||||
if (memcmp(decrypted + (8 * 9), empty, 8) != 0) {
|
||||
|
||||
@@ -1363,9 +1363,9 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
uint8_t pinsize = 0;
|
||||
if (use_sc) {
|
||||
pinsize = GetPinSize(decrypted + (8 * 6));
|
||||
|
||||
|
||||
if (pinsize > 0) {
|
||||
|
||||
|
||||
uint64_t pin = bytes_to_num(decrypted + (8 * 9), 5);
|
||||
char tmp[17] = {0};
|
||||
sprintf(tmp, "%."PRIu64, BCD2DEC(pin));
|
||||
@@ -1502,17 +1502,17 @@ static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool verbose) {
|
||||
}
|
||||
|
||||
static bool select_and_auth(uint8_t *KEY, uint8_t *MAC, uint8_t *div_key, bool use_credit_key, bool elite, bool rawkey, bool verbose) {
|
||||
|
||||
|
||||
iclass_auth_req_t payload = {
|
||||
.use_raw = rawkey,
|
||||
.use_elite = elite,
|
||||
.use_credit_key = use_credit_key
|
||||
};
|
||||
memcpy(payload.key, KEY, 8);
|
||||
|
||||
SendCommandNG(CMD_HF_ICLASS_AUTH, (uint8_t*)&payload, sizeof(payload));
|
||||
|
||||
SendCommandNG(CMD_HF_ICLASS_AUTH, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
clearCommandBuffer();
|
||||
if (WaitForResponseTimeout(CMD_HF_ICLASS_AUTH, &resp, 2000) == 0) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
return false;
|
||||
@@ -1529,14 +1529,14 @@ static bool select_and_auth(uint8_t *KEY, uint8_t *MAC, uint8_t *div_key, bool u
|
||||
if (verbose) PrintAndLogEx(FAILED, "authentication error");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (div_key)
|
||||
memcpy(div_key, packet->div_key, sizeof(packet->div_key));
|
||||
|
||||
|
||||
if (MAC)
|
||||
memcpy(MAC, packet->mac, sizeof(packet->mac));
|
||||
|
||||
if (verbose)
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(SUCCESS, "authing with %s: %s", rawkey ? "raw key" : "diversified key", sprint_hex(div_key, 8));
|
||||
|
||||
return true;
|
||||
@@ -1658,7 +1658,7 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
uint8_t pagemap = get_pagemap(hdr);
|
||||
|
||||
if (readStatus & (FLAG_ICLASS_CSN | FLAG_ICLASS_CONF | FLAG_ICLASS_CC)) {
|
||||
|
||||
|
||||
memcpy(tag_data, hdr, 24);
|
||||
|
||||
uint8_t type = get_mem_config(hdr);
|
||||
@@ -1667,22 +1667,22 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
|
||||
PrintAndLogEx(INFO, "Card in non-secure page mode detected");
|
||||
|
||||
|
||||
app_limit1 = card_app2_limit[type];
|
||||
app_limit2 = 0;
|
||||
} else {
|
||||
app_limit1 = hdr->conf.app_limit;
|
||||
app_limit2 = card_app2_limit[type];
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, "failed to read block 0,1,2");
|
||||
DropField();
|
||||
return PM3_ESOFT;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
PrintAndLogEx(INFO, "Dumping all available memory, block 3 - %u (0x%02x)",app_limit1 , app_limit1);
|
||||
PrintAndLogEx(INFO, "Dumping all available memory, block 3 - %u (0x%02x)", app_limit1, app_limit1);
|
||||
if (auth) {
|
||||
PrintAndLogEx(INFO, "No keys needed, ignoring user supplied key");
|
||||
}
|
||||
@@ -1703,7 +1703,7 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
.end_block = app_limit1,
|
||||
};
|
||||
memcpy(payload.req.key, KEY, 8);
|
||||
|
||||
|
||||
// tags configured for NON SECURE PAGE, acts different
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
payload.start_block = 3;
|
||||
@@ -1711,9 +1711,9 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
} else {
|
||||
payload.start_block = 6;
|
||||
}
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_DUMP, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_ICLASS_DUMP, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
while (true) {
|
||||
printf(".");
|
||||
@@ -1757,20 +1757,20 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
// all memory available
|
||||
memcpy(tag_data + (8 * 3), tempbuf + (8 * 3), (blocks_read * 8) );
|
||||
memcpy(tag_data + (8 * 3), tempbuf + (8 * 3), (blocks_read * 8));
|
||||
} else {
|
||||
// div key KD
|
||||
memcpy(tag_data + (8 * 3), tempbuf + (8 * 3), 8);
|
||||
// AIA data
|
||||
memcpy(tag_data + (8 * 5), tempbuf + (8 * 5), 8);
|
||||
// AA1 data
|
||||
memcpy(tag_data + (8 * 6), tempbuf + (8 * 6), (blocks_read * 8) );
|
||||
memcpy(tag_data + (8 * 6), tempbuf + (8 * 6), (blocks_read * 8));
|
||||
}
|
||||
|
||||
uint16_t bytes_got = (app_limit1 + 1) * 8;
|
||||
|
||||
|
||||
// try AA2 Kc, Credit
|
||||
bool aa2_success = false;
|
||||
|
||||
@@ -1778,14 +1778,14 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
|
||||
// AA2 authenticate credit key
|
||||
memcpy(payload.req.key, CreditKEY, 8);
|
||||
|
||||
|
||||
payload.req.use_credit_key = true;
|
||||
payload.start_block = app_limit1 + 1;
|
||||
payload.end_block = app_limit2;
|
||||
payload.req.do_auth = true;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_DUMP, (uint8_t*)&payload, sizeof(payload));
|
||||
SendCommandNG(CMD_HF_ICLASS_DUMP, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
while (true) {
|
||||
printf(".");
|
||||
@@ -1825,20 +1825,20 @@ static int CmdHFiClassDump(const char *Cmd) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
goto write_dump;
|
||||
}
|
||||
|
||||
|
||||
// div key KC
|
||||
memcpy(tag_data + (8 * 4), tempbuf + (8 * 4), 8);
|
||||
|
||||
// AA2 data
|
||||
memcpy(tag_data + (8 * (app_limit1 + 1)), tempbuf + (8 * (app_limit1 + 1)), (blocks_read * 8) );
|
||||
memcpy(tag_data + (8 * (app_limit1 + 1)), tempbuf + (8 * (app_limit1 + 1)), (blocks_read * 8));
|
||||
|
||||
bytes_got = (blocks_read * 8);
|
||||
|
||||
|
||||
aa2_success = true;
|
||||
}
|
||||
|
||||
write_dump:
|
||||
|
||||
|
||||
if (have_credit_key && pagemap != 0x01 && aa2_success == false)
|
||||
PrintAndLogEx(INFO, "Reading AA2 failed. dumping AA1 data to file");
|
||||
|
||||
@@ -1859,7 +1859,7 @@ write_dump:
|
||||
saveFile(filename, ".bin", tag_data, bytes_got);
|
||||
saveFileEML(filename, tag_data, bytes_got, 8);
|
||||
saveFileJSON(filename, jsfIclass, tag_data, bytes_got, NULL);
|
||||
|
||||
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass decrypt") "` to decrypt dump file");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass view") "` to view dump file");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -1867,55 +1867,55 @@ write_dump:
|
||||
}
|
||||
|
||||
static int iclass_write_block(uint8_t blockno, uint8_t *bldata, uint8_t *KEY, bool use_credit_key, bool elite, bool rawkey, bool verbose) {
|
||||
/*
|
||||
uint8_t MAC[4] = {0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t div_key[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
if (select_and_auth(KEY, MAC, div_key, use_credit_key, elite, rawkey, verbose) == false) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
/*
|
||||
uint8_t MAC[4] = {0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t div_key[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
if (select_and_auth(KEY, MAC, div_key, use_credit_key, elite, rawkey, verbose) == false) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
calc_wb_mac(blockno, bldata, div_key, MAC);
|
||||
calc_wb_mac(blockno, bldata, div_key, MAC);
|
||||
|
||||
struct p {
|
||||
struct p {
|
||||
uint8_t blockno;
|
||||
uint8_t data[12];
|
||||
} PACKED payload;
|
||||
payload.blockno = blockno;
|
||||
|
||||
memcpy(payload.data, bldata, 8);
|
||||
memcpy(payload.data + 8, MAC, 4);
|
||||
|
||||
|
||||
//
|
||||
typedef struct {
|
||||
uint8_t key[8];
|
||||
bool use_raw;
|
||||
bool use_elite;
|
||||
bool use_credit_key;
|
||||
bool send_reply;
|
||||
bool do_auth;
|
||||
uint8_t blockno;
|
||||
uint8_t data[12];
|
||||
} PACKED payload;
|
||||
payload.blockno = blockno;
|
||||
} PACKED iclass_auth_req_t;
|
||||
|
||||
memcpy(payload.data, bldata, 8);
|
||||
memcpy(payload.data + 8, MAC, 4);
|
||||
|
||||
|
||||
//
|
||||
typedef struct {
|
||||
uint8_t key[8];
|
||||
bool use_raw;
|
||||
bool use_elite;
|
||||
bool use_credit_key;
|
||||
bool send_reply;
|
||||
bool do_auth;
|
||||
uint8_t blockno;
|
||||
} PACKED iclass_auth_req_t;
|
||||
// iCLASS write block request data structure
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_writeblock_req_t;
|
||||
|
||||
// iCLASS write block request data structure
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_writeblock_req_t;
|
||||
|
||||
|
||||
*/
|
||||
iclass_writeblock_req_t payload = {
|
||||
|
||||
*/
|
||||
iclass_writeblock_req_t payload = {
|
||||
.req.use_raw = rawkey,
|
||||
.req.use_elite = elite,
|
||||
.req.use_credit_key = use_credit_key,
|
||||
.req.blockno = blockno,
|
||||
.req.send_reply = true,
|
||||
.req.do_auth = true,
|
||||
.req.do_auth = true,
|
||||
};
|
||||
memcpy(payload.req.key, KEY, 8);
|
||||
memcpy(payload.data, bldata, sizeof(payload.data));
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_WRITEBL, (uint8_t *)&payload, sizeof(payload));
|
||||
PacketResponseNG resp;
|
||||
@@ -2230,26 +2230,26 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||
}
|
||||
|
||||
static int iclass_read_block(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool verbose, bool auth, uint8_t *out) {
|
||||
|
||||
|
||||
iclass_auth_req_t payload = {
|
||||
.use_raw = rawkey,
|
||||
.use_elite = elite,
|
||||
.use_credit_key = (keyType == 0x18),
|
||||
.blockno = blockno,
|
||||
.send_reply = true,
|
||||
.do_auth = auth,
|
||||
.do_auth = auth,
|
||||
};
|
||||
memcpy(payload.key, KEY, 8);
|
||||
|
||||
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_READBL, (uint8_t*)&payload, sizeof(payload));
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ICLASS_READBL, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
if (WaitForResponseTimeout(CMD_HF_ICLASS_READBL, &resp, 2000) == false) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
if (verbose) PrintAndLogEx(ERR, "failed to communicate with card");
|
||||
return PM3_EWRONGANSWER;
|
||||
@@ -2355,24 +2355,24 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
|
||||
if (auth == false && verbose) {
|
||||
PrintAndLogEx(WARNING, "warning: no authentication used with read. Typical for cards configured toin `non-secure page`");
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint8_t data[8] = {0};
|
||||
int res = iclass_read_block(KEY, blockno, keyType, elite, rawkey, verbose, auth, data);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
|
||||
|
||||
if (blockno < 6 || blockno > 7)
|
||||
return PM3_SUCCESS;
|
||||
|
||||
|
||||
if (memcmp(data, empty, 8) == 0)
|
||||
return PM3_SUCCESS;
|
||||
|
||||
bool use_sc = IsCryptoHelperPresent(verbose);
|
||||
if (use_sc == false)
|
||||
if (use_sc == false)
|
||||
return PM3_SUCCESS;
|
||||
|
||||
|
||||
// crypto helper available.
|
||||
PrintAndLogEx(INFO, "----------------------------- " _CYAN_("cardhelper") " -----------------------------");
|
||||
|
||||
@@ -2415,7 +2415,7 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
|
||||
i &= 0x3C;
|
||||
PrintAndLogEx(SUCCESS, " bin : %s", binstr + i);
|
||||
PrintAndLogEx(INFO, "");
|
||||
PrintAndLogEx(INFO, "");
|
||||
PrintAndLogEx(INFO, "------------------------------ " _CYAN_("wiegand") " -------------------------------");
|
||||
wiegand_message_t packed = initialize_message_object(top, mid, bot);
|
||||
HIDTryUnpack(&packed, true);
|
||||
@@ -2465,8 +2465,8 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
|
||||
picopass_hdr *hdr = (picopass_hdr *)iclass_dump;
|
||||
// picopass_ns_hdr *ns_hdr = (picopass_ns_hdr *)iclass_dump;
|
||||
// uint8_t pagemap = get_pagemap(hdr);
|
||||
// if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) { }
|
||||
|
||||
// if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) { }
|
||||
|
||||
uint8_t lock = hdr->conf.block_writelock;
|
||||
|
||||
// is chip in ReadOnly (RO)
|
||||
@@ -2505,11 +2505,11 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
|
||||
PrintAndLogEx(INFO, "------+----+-------------------------+----------");
|
||||
while (i <= endblock) {
|
||||
uint8_t *blk = iclass_dump + (i * 8);
|
||||
|
||||
|
||||
bool bl_lock = false;
|
||||
if ( ro == false ) {
|
||||
switch(i) {
|
||||
case 12: {
|
||||
if (ro == false) {
|
||||
switch (i) {
|
||||
case 12: {
|
||||
bl_lock = ((lock & 0x40) == 0);
|
||||
break;
|
||||
}
|
||||
@@ -2541,7 +2541,7 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
|
||||
} else {
|
||||
bl_lock = true;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, " %c |0x%02X| %s", (bl_lock) ? 'x' : ' ', i, sprint_hex_ascii(blk, 8));
|
||||
i++;
|
||||
}
|
||||
@@ -2600,7 +2600,7 @@ static int CmdHFiClassView(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "Printing blocks from");
|
||||
PrintAndLogEx(INFO, "start " _YELLOW_("0x%02x") " end " _YELLOW_("0x%02x"), (startblock == 0) ? 6 : startblock, endblock);
|
||||
}
|
||||
|
||||
|
||||
print_picopass_header((picopass_hdr *) dump);
|
||||
print_picopass_info((picopass_hdr *) dump);
|
||||
|
||||
@@ -2666,7 +2666,7 @@ static int CmdHFiClassCalcNewKey(const char *Cmd) {
|
||||
bool elite = false;
|
||||
bool errors = false;
|
||||
uint8_t cmdp = 0;
|
||||
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
@@ -2737,7 +2737,7 @@ static int CmdHFiClassCalcNewKey(const char *Cmd) {
|
||||
}
|
||||
|
||||
HFiClassCalcNewKey(CSN, OLDKEY, NEWKEY, xor_div_key, elite, old_elite, true);
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -3045,7 +3045,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_ICLASS_CHKKEYS, flags, keys, 0, pre + key_offset, 4 * keys);
|
||||
PacketResponseNG resp;
|
||||
|
||||
|
||||
bool looped = false;
|
||||
while (!WaitForResponseTimeout(CMD_HF_ICLASS_CHKKEYS, &resp, 2000)) {
|
||||
timeout++;
|
||||
@@ -3252,7 +3252,7 @@ static int CmdHFiClassLookUp(const char *Cmd) {
|
||||
|
||||
// binsearch
|
||||
item = (iclass_prekey_t *) bsearch(&lookup, prekey, keycount, sizeof(iclass_prekey_t), cmp_uint32);
|
||||
|
||||
|
||||
if (item != NULL) {
|
||||
PrintAndLogEx(SUCCESS, "Found valid key " _GREEN_("%s"), sprint_hex(item->key, 8));
|
||||
add_key(item->key);
|
||||
@@ -3453,15 +3453,15 @@ static command_t CommandTable[] = {
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("recovery") " ---------------------"},
|
||||
{"chk", CmdHFiClassCheckKeys, AlwaysAvailable, "[options..] Check keys"},
|
||||
{"loclass", CmdHFiClass_loclass, AlwaysAvailable, "[options..] Use loclass to perform bruteforce reader attack"},
|
||||
{"lookup", CmdHFiClassLookUp, AlwaysAvailable, "[options..] Uses authentication trace to check for key in dictionary file"},
|
||||
{"lookup", CmdHFiClassLookUp, AlwaysAvailable, "[options..] Uses authentication trace to check for key in dictionary file"},
|
||||
{"replay", CmdHFiClassReader_Replay, IfPm3Iclass, "<mac> Read Picopass / iCLASS tag via replay attack"},
|
||||
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("simulation") " ---------------------"},
|
||||
{"sim", CmdHFiClassSim, IfPm3Iclass, "[options..] Simulate iCLASS tag"},
|
||||
{"eload", CmdHFiClassELoad, IfPm3Iclass, "[f <fn> ] Load Picopass / iCLASS dump file into emulator memory"},
|
||||
{"esave", CmdHFiClassESave, IfPm3Iclass, "[f <fn> ] Save emulator memory to file"},
|
||||
{"esave", CmdHFiClassESave, IfPm3Iclass, "[f <fn> ] Save emulator memory to file"},
|
||||
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("utils") " ---------------------"},
|
||||
{"-----------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("utils") " ---------------------"},
|
||||
{"calcnewkey", CmdHFiClassCalcNewKey, AlwaysAvailable, "[options..] Calc diversified keys (blocks 3 & 4) to write new keys"},
|
||||
{"encrypt", CmdHFiClassEncryptBlk, AlwaysAvailable, "[options..] Encrypt given block data"},
|
||||
{"decrypt", CmdHFiClassDecrypt, AlwaysAvailable, "[options..] Decrypt given block data or tag dump file" },
|
||||
@@ -3484,16 +3484,16 @@ int CmdHFiClass(const char *Cmd) {
|
||||
}
|
||||
|
||||
//static void test_credential_type(void) {
|
||||
// need AA1 key
|
||||
// Block 5 -> tells if its a legacy or SIO, also tells which key to use.
|
||||
|
||||
// tech | blocks used | desc | num of payloads
|
||||
// -------+-----------------------+-----------------------------------+------
|
||||
// legacy | 6,7,8,9 | AA!, Access control payload | 1
|
||||
// SE | 6,7,8,9,10,11,12 | AA1, Secure identity object (SIO) | 1
|
||||
// SR | 6,7,8,9, | AA1, Access control payload | 2
|
||||
// | 10,11,12,13,14,15,16 | AA1, Secure identity object (SIO) |
|
||||
// SEOS | | |
|
||||
// need AA1 key
|
||||
// Block 5 -> tells if its a legacy or SIO, also tells which key to use.
|
||||
|
||||
// tech | blocks used | desc | num of payloads
|
||||
// -------+-----------------------+-----------------------------------+------
|
||||
// legacy | 6,7,8,9 | AA!, Access control payload | 1
|
||||
// SE | 6,7,8,9,10,11,12 | AA1, Secure identity object (SIO) | 1
|
||||
// SR | 6,7,8,9, | AA1, Access control payload | 2
|
||||
// | 10,11,12,13,14,15,16 | AA1, Secure identity object (SIO) |
|
||||
// SEOS | | |
|
||||
//}
|
||||
|
||||
int info_iclass(void) {
|
||||
@@ -3528,32 +3528,32 @@ int info_iclass(void) {
|
||||
if (readStatus & FLAG_ICLASS_CONF) {
|
||||
PrintAndLogEx(SUCCESS, " Config: %s (Card configuration)", sprint_hex((uint8_t *)&hdr->conf, sizeof(hdr->conf)));
|
||||
}
|
||||
|
||||
|
||||
// page mapping. If fuse0|1 == 0x01, card is in non-secure mode, with CSN, CONF, AIA as top 3 blocks.
|
||||
// page9 in http://www.proxmark.org/files/Documents/13.56%20MHz%20-%20iClass/DS%20Picopass%202KS%20V1-0.pdf
|
||||
uint8_t pagemap = get_pagemap(hdr);
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||
PrintAndLogEx(SUCCESS, " AIA: %s (Application Issuer area)", sprint_hex(ns_hdr->app_issuer_area, sizeof(ns_hdr->app_issuer_area)));
|
||||
} else {
|
||||
} else {
|
||||
|
||||
if (readStatus & FLAG_ICLASS_CC) {
|
||||
PrintAndLogEx(SUCCESS, "E-purse: %s (Card challenge, CC)", sprint_hex(hdr->epurse, sizeof(hdr->epurse)));
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Kd: %s (Debit key, hidden)", sprint_hex(hdr->key_d, sizeof(hdr->key_d)));
|
||||
PrintAndLogEx(SUCCESS, " Kc: %s (Credit key, hidden)", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
|
||||
|
||||
if (readStatus & FLAG_ICLASS_AIA) {
|
||||
PrintAndLogEx(SUCCESS, " AIA: %s (Application Issuer area)", sprint_hex(hdr->app_issuer_area, sizeof(hdr->app_issuer_area)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (readStatus & FLAG_ICLASS_CONF) {
|
||||
print_picopass_info(hdr);
|
||||
print_picopass_info(hdr);
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "------ " _CYAN_("Fingerprint") " ------");
|
||||
|
||||
|
||||
uint8_t aia[8];
|
||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE)
|
||||
memcpy(aia, ns_hdr->app_issuer_area, sizeof(aia));
|
||||
@@ -3565,7 +3565,7 @@ int info_iclass(void) {
|
||||
|
||||
bool legacy = (memcmp(aia, "\xff\xff\xff\xff\xff\xff\xff\xff", 8) == 0);
|
||||
bool se_enabled = (memcmp(aia, "\xff\xff\xff\x00\x06\xff\xff\xff", 8) == 0);
|
||||
|
||||
|
||||
if (isHidRange) {
|
||||
PrintAndLogEx(SUCCESS, "CSN is in HID range");
|
||||
if (legacy)
|
||||
|
||||
@@ -1720,7 +1720,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
}
|
||||
cmdp++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 't':
|
||||
tests = param_get32ex(Cmd, cmdp + 1, 100, 10);
|
||||
if (!param_gethex(Cmd, cmdp + 2, trgkey, 12)) {
|
||||
@@ -1858,8 +1858,8 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
trgKeyType ? 'B' : 'A',
|
||||
trgkey[0], trgkey[1], trgkey[2], trgkey[3], trgkey[4], trgkey[5],
|
||||
know_target_key ? "" : " (not set)"
|
||||
);
|
||||
PrintAndLogEx(INFO , "File action: %s, Slow: %s, Tests: %d ",
|
||||
);
|
||||
PrintAndLogEx(INFO, "File action: %s, Slow: %s, Tests: %d ",
|
||||
nonce_file_write ? "write" : nonce_file_read ? "read" : "none",
|
||||
slow ? "Yes" : "No",
|
||||
tests);
|
||||
@@ -1867,7 +1867,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
uint64_t foundkey = 0;
|
||||
int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key ? trgkey : NULL, nonce_file_read, nonce_file_write, slow, tests, &foundkey, filename);
|
||||
|
||||
if (tests == 0)
|
||||
if (tests == 0)
|
||||
DropField();
|
||||
|
||||
if (isOK) {
|
||||
|
||||
@@ -1864,7 +1864,7 @@ static int getKeySettings(uint8_t *aid) {
|
||||
// KEY Settings - AMK
|
||||
uint8_t num_keys = 0;
|
||||
uint8_t key_setting = 0;
|
||||
mifare_des_authalgo_t algo=MFDES_ALGO_DES;
|
||||
mifare_des_authalgo_t algo = MFDES_ALGO_DES;
|
||||
res = key_setting_to_algo(aid, &key_setting, &algo, &num_keys);
|
||||
|
||||
if (res == PM3_SUCCESS) {
|
||||
@@ -1916,7 +1916,7 @@ static int getKeySettings(uint8_t *aid) {
|
||||
// KEY Settings - AMK
|
||||
uint8_t num_keys = 0;
|
||||
uint8_t key_setting = 0;
|
||||
mifare_des_authalgo_t algo=MFDES_ALGO_DES;
|
||||
mifare_des_authalgo_t algo = MFDES_ALGO_DES;
|
||||
res = key_setting_to_algo(aid, &key_setting, &algo, &num_keys);
|
||||
if (res == PM3_SUCCESS) {
|
||||
desfire_print_keysetting(key_setting, num_keys, algo);
|
||||
@@ -2669,7 +2669,7 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
||||
|
||||
if (res_flen) {
|
||||
PrintAndLogEx(ERR, "File size input error");
|
||||
return PM3_EINVARG;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
swap24(filesize);
|
||||
@@ -2859,7 +2859,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
||||
// with 2char hex, 512bytes could be input.
|
||||
// Instead large binary inputs should be BINARY files and written to card.
|
||||
int dlength = 512;
|
||||
uint8_t data[512] = {0};
|
||||
uint8_t data[512] = {0};
|
||||
int res_data = CLIParamHexToBuf(arg_get_str(ctx, 3), data, 512, &dlength);
|
||||
|
||||
int type = arg_get_int(ctx, 4);
|
||||
@@ -3767,12 +3767,12 @@ static int CmdHF14ADesChangeKey(const char *Cmd) {
|
||||
uint8_t key[24] = {0};
|
||||
int keylen = 0;
|
||||
int res_klen = CLIParamHexToBuf(arg_get_str(ctx, 3), key, 24, &keylen);
|
||||
|
||||
|
||||
uint8_t newcmdAuthAlgo = arg_get_int_def(ctx, 4, 0);
|
||||
uint8_t newkey[24] = {0};
|
||||
int newkeylen = 0;
|
||||
int res_newklen = CLIParamHexToBuf(arg_get_str(ctx, 5), newkey, 24, &newkeylen);
|
||||
|
||||
|
||||
uint8_t aesversion = arg_get_int_def(ctx, 6, 0);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -4535,7 +4535,7 @@ static int CmdHF14aDesNDEF(const char *Cmd) {
|
||||
if (res == PM3_SUCCESS) {
|
||||
uint32_t len = le24toh(fdata.length);
|
||||
NDEFDecodeAndPrint(data, datalen, verbose);
|
||||
|
||||
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Couldn't read value. Error %d", res);
|
||||
res = handler_desfire_select_application(aid);
|
||||
|
||||
+3
-3
@@ -1206,7 +1206,7 @@ static bool CheckChipType(bool getDeviceData) {
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf t55xx`") " commands");
|
||||
retval = true;
|
||||
}
|
||||
|
||||
|
||||
// check for em4x50 chips
|
||||
if (detect_4x50_block()) {
|
||||
PrintAndLogEx(SUCCESS, "Chipset detection: " _GREEN_("EM4x50"));
|
||||
@@ -1293,7 +1293,7 @@ int CmdLFfind(const char *Cmd) {
|
||||
if (demodParadox() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Paradox ID") " found!"); goto out;}
|
||||
if (demodNexWatch() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("NexWatch ID") " found!"); goto out;}
|
||||
if (demodIndala() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Indala ID") " found!"); goto out;}
|
||||
|
||||
|
||||
if (demodEM410x() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("EM410x ID") " found!"); goto out;}
|
||||
if (demodFDX() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("FDX-B ID") " found!"); goto out;}
|
||||
if (demodGuard() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Guardall G-Prox II ID") " found!"); goto out; }
|
||||
@@ -1310,7 +1310,7 @@ int CmdLFfind(const char *Cmd) {
|
||||
if (demodSecurakey() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Securakey ID") " found!"); goto out;}
|
||||
if (demodViking() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Viking ID") " found!"); goto out;}
|
||||
if (demodGallagher() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("GALLAGHER ID") " found!"); goto out;}
|
||||
|
||||
|
||||
// if (demodTI() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Texas Instrument ID") " found!"); goto out;}
|
||||
//if (demodFermax() == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Fermax ID") " found!"); goto out;}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ static int usage_lf_em410x_brute(void) {
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt c 32"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_( " lf em 410x_brute ids.txt d 3000"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt d 3000"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt d 3000 c 32"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -408,7 +408,7 @@ int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
|
||||
static int CmdEM410xWatch(const char *Cmd) {
|
||||
uint8_t c = tolower(param_getchar(Cmd, 0));
|
||||
if (c == 'h') return usage_lf_em410x_watch();
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Watching for EM410x cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading cards");
|
||||
clearCommandBuffer();
|
||||
@@ -639,7 +639,7 @@ static int CmdEM410xWrite(const char *Cmd) {
|
||||
} else if (card == 0) {
|
||||
PrintAndLogEx(SUCCESS, "Writing %s tag with UID 0x%010" PRIx64 "(clock rate: %d)", _GREEN_("T5555"), id, clock1);
|
||||
}
|
||||
|
||||
|
||||
struct {
|
||||
uint8_t card;
|
||||
uint8_t clock;
|
||||
@@ -657,7 +657,7 @@ static int CmdEM410xWrite(const char *Cmd) {
|
||||
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_EM410X_WRITE, &resp);
|
||||
switch(resp.status) {
|
||||
switch (resp.status) {
|
||||
case PM3_SUCCESS: {
|
||||
PrintAndLogEx(SUCCESS, "Done");
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf em 410x_read`") " to verify");
|
||||
|
||||
+52
-52
@@ -114,8 +114,8 @@ static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t
|
||||
c[j] = 0;
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
words[i].byte[j] = byte[i*7+j];
|
||||
words[i].row_parity[j] = (byte[i*7+4] >> (3-j)) & 1;
|
||||
words[i].byte[j] = byte[i * 7 + j];
|
||||
words[i].row_parity[j] = (byte[i * 7 + 4] >> (3 - j)) & 1;
|
||||
|
||||
// collect parities
|
||||
p = 0;
|
||||
@@ -126,7 +126,7 @@ static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t
|
||||
p ^= (words[i].byte[j] >> k) & 1;
|
||||
|
||||
// column parity
|
||||
c[k] ^= (words[i].byte[j] >> (7-k)) & 1;
|
||||
c[k] ^= (words[i].byte[j] >> (7 - k)) & 1;
|
||||
}
|
||||
|
||||
// check row parities
|
||||
@@ -137,17 +137,17 @@ static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t
|
||||
}
|
||||
|
||||
// check column parities
|
||||
words[i].col_parity = byte[i*7+5];
|
||||
words[i].col_parity = byte[i * 7 + 5];
|
||||
|
||||
for (int j = 0; j < 8; j++) {
|
||||
words[i].cparity[j] = (((words[i].col_parity >> (7-j)) & 1) == c[j]) ? true : false;
|
||||
words[i].cparity[j] = (((words[i].col_parity >> (7 - j)) & 1) == c[j]) ? true : false;
|
||||
|
||||
if (!words[i].cparity[j])
|
||||
words[i].parity = false;
|
||||
words[i].parity = false;
|
||||
}
|
||||
|
||||
// check stop bit
|
||||
words[i].stopbit = byte[i*7+6] & 1;
|
||||
words[i].stopbit = byte[i * 7 + 6] & 1;
|
||||
|
||||
if (words[i].stopbit == 1)
|
||||
words[i].stopparity = false;
|
||||
@@ -166,7 +166,7 @@ static void print_result(const em4x50_word_t *words, int fwr, int lwr) {
|
||||
for (int i = fwr; i <= lwr; i++) {
|
||||
|
||||
char s[50] = {0};
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case EM4X50_DEVICE_PASSWORD:
|
||||
sprintf(s, _YELLOW_("password, write only"));
|
||||
break;
|
||||
@@ -191,13 +191,13 @@ static void print_result(const em4x50_word_t *words, int fwr, int lwr) {
|
||||
for (int j = 3; j >= 0; j--) {
|
||||
sprintf(r + strlen(r), "%02x ", reflect8(words[i].byte[j]));
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, " %2i | " _GREEN_("%s") "| %s| %s",
|
||||
i,
|
||||
sprint_hex(words[i].byte, 4),
|
||||
r,
|
||||
s
|
||||
);
|
||||
i,
|
||||
sprint_hex(words[i].byte, 4),
|
||||
r,
|
||||
s
|
||||
);
|
||||
}
|
||||
PrintAndLogEx(INFO, "----+-------------+-------------+--------------------");
|
||||
}
|
||||
@@ -226,14 +226,14 @@ static void print_info_result(uint8_t *data, bool verbose) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, _YELLOW_("EM4x50 data:"));
|
||||
print_result(words, 0, EM4X50_NO_WORDS - 1);
|
||||
|
||||
|
||||
// configuration section
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---- " _CYAN_("Configuration") " ----");
|
||||
|
||||
PrintAndLogEx(INFO, "first word read %3i", fwr);
|
||||
PrintAndLogEx(INFO, "last word read %3i", lwr);
|
||||
PrintAndLogEx(INFO, "password check %3s", (bpwc) ? _RED_("on"): _GREEN_("off"));
|
||||
PrintAndLogEx(INFO, "password check %3s", (bpwc) ? _RED_("on") : _GREEN_("off"));
|
||||
PrintAndLogEx(INFO, "read after write %3s", (braw) ? "on" : "off");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--------- " _CYAN_("Protection") " ---------");
|
||||
@@ -288,9 +288,9 @@ int CmdEM4x50Info(const char *Cmd) {
|
||||
|
||||
case 'p':
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
@@ -308,8 +308,8 @@ int CmdEM4x50Info(const char *Cmd) {
|
||||
}
|
||||
|
||||
// validation
|
||||
if (errors)
|
||||
return usage_lf_em4x50_info();
|
||||
if (errors)
|
||||
return usage_lf_em4x50_info();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_INFO, (uint8_t *)&etd, sizeof(etd));
|
||||
@@ -346,17 +346,17 @@ int CmdEM4x50Write(const char *Cmd) {
|
||||
}
|
||||
case 'p': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
}
|
||||
case 'w': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.word, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n word has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
PrintAndLogEx(FAILED, "\n word has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
bword = true;
|
||||
cmdp += 2;
|
||||
@@ -383,7 +383,7 @@ int CmdEM4x50Write(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (errors || !bword || !baddr)
|
||||
return usage_lf_em4x50_write();
|
||||
return usage_lf_em4x50_write();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_WRITE, (uint8_t *)&etd, sizeof(etd));
|
||||
@@ -428,7 +428,7 @@ static void print_write_password_result(PacketResponseNG *resp, const em4x50_dat
|
||||
sprintf(pstring, "\n writing new password " _GREEN_("ok"));
|
||||
strcat(string, pstring);
|
||||
|
||||
PrintAndLogEx(NORMAL,"%s\n", string);
|
||||
PrintAndLogEx(NORMAL, "%s\n", string);
|
||||
}
|
||||
|
||||
int CmdEM4x50WritePassword(const char *Cmd) {
|
||||
@@ -452,8 +452,8 @@ int CmdEM4x50WritePassword(const char *Cmd) {
|
||||
|
||||
case 'p':
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
bpwd = true;
|
||||
etd.pwd_given = true;
|
||||
@@ -462,9 +462,9 @@ int CmdEM4x50WritePassword(const char *Cmd) {
|
||||
|
||||
case 'n':
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.new_password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
bnpwd = true;
|
||||
etd.newpwd_given = true;
|
||||
cmdp += 2;
|
||||
@@ -478,7 +478,7 @@ int CmdEM4x50WritePassword(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (errors || !bpwd || !bnpwd)
|
||||
return usage_lf_em4x50_write_password();
|
||||
return usage_lf_em4x50_write_password();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_WRITE_PASSWORD, (uint8_t *)&etd, sizeof(etd));
|
||||
@@ -493,7 +493,7 @@ int CmdEM4x50WritePassword(const char *Cmd) {
|
||||
if (success)
|
||||
print_write_password_result(&resp, &etd);
|
||||
else
|
||||
PrintAndLogEx(NORMAL,"\nwriting password " _RED_("failed") "\n");
|
||||
PrintAndLogEx(NORMAL, "\nwriting password " _RED_("failed") "\n");
|
||||
|
||||
return (success) ? PM3_SUCCESS : PM3_ESOFT;
|
||||
}
|
||||
@@ -583,9 +583,9 @@ int CmdEM4x50Read(const char *Cmd) {
|
||||
}
|
||||
case 'p': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
@@ -599,7 +599,7 @@ int CmdEM4x50Read(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (errors || strlen(Cmd) == 0 || etd.addr_given == false)
|
||||
return usage_lf_em4x50_read();
|
||||
return usage_lf_em4x50_read();
|
||||
|
||||
return em4x50_read(&etd, NULL, true);
|
||||
}
|
||||
@@ -627,9 +627,9 @@ int CmdEM4x50Dump(const char *Cmd) {
|
||||
break;
|
||||
case 'p': {
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
PrintAndLogEx(FAILED, "\n password has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
etd.pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
@@ -642,8 +642,8 @@ int CmdEM4x50Dump(const char *Cmd) {
|
||||
}
|
||||
|
||||
// validation
|
||||
if (errors)
|
||||
return usage_lf_em4x50_dump();
|
||||
if (errors)
|
||||
return usage_lf_em4x50_dump();
|
||||
|
||||
PrintAndLogEx(INFO, "reading EM4x50 tag");
|
||||
clearCommandBuffer();
|
||||
@@ -675,8 +675,8 @@ int CmdEM4x50Dump(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint8_t data[EM4X50_NO_WORDS * 4] = {0};
|
||||
for (int i=0; i < EM4X50_NO_WORDS; i++) {
|
||||
memcpy(data + (i*4), words[i].byte, 4);
|
||||
for (int i = 0; i < EM4X50_NO_WORDS; i++) {
|
||||
memcpy(data + (i * 4), words[i].byte, 4);
|
||||
}
|
||||
|
||||
// saveFileEML will add .eml extension to filename
|
||||
@@ -704,8 +704,8 @@ int CmdEM4x50Wipe(const char *Cmd) {
|
||||
|
||||
case 'p':
|
||||
if (param_gethex(Cmd, cmdp + 1, etd.password, 8)) {
|
||||
PrintAndLogEx(FAILED, "\npassword has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
PrintAndLogEx(FAILED, "\npassword has to be 8 hex symbols\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
bpwd = true;
|
||||
cmdp += 2;
|
||||
@@ -719,12 +719,12 @@ int CmdEM4x50Wipe(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (errors || !bpwd)
|
||||
return usage_lf_em4x50_wipe();
|
||||
return usage_lf_em4x50_wipe();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_WIPE, (uint8_t *)&etd, sizeof(etd));
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2*TIMEOUT)) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2 * TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "\ntimeout while waiting for reply.\n");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
@@ -732,9 +732,9 @@ int CmdEM4x50Wipe(const char *Cmd) {
|
||||
// print response
|
||||
bool isOK = resp.status;
|
||||
if (isOK) {
|
||||
PrintAndLogEx(SUCCESS,"\nwiping data " _GREEN_("ok") "\n");
|
||||
PrintAndLogEx(SUCCESS, "\nwiping data " _GREEN_("ok") "\n");
|
||||
} else {
|
||||
PrintAndLogEx(FAILED,"\nwiping data " _RED_("failed") "\n");
|
||||
PrintAndLogEx(FAILED, "\nwiping data " _RED_("failed") "\n");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
@@ -246,10 +246,10 @@ static int CmdHIDDemod(const char *Cmd) {
|
||||
}
|
||||
if (fmtLen == 32 && (lo & 0x40000000)) { //if 32 bit and Kastle bit set
|
||||
PrintAndLogEx(SUCCESS,
|
||||
"HID Prox (Kastle format) - " _GREEN_("%x%08x (%u)") " - len: " _GREEN_("32") " bit CC: " _GREEN_("%u") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u"), hi, lo, (lo >> 1) & 0xFFFF, cc, fc, cardnum);
|
||||
"HID Prox (Kastle format) - " _GREEN_("%x%08x (%u)") " - len: " _GREEN_("32") " bit CC: " _GREEN_("%u") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u"), hi, lo, (lo >> 1) & 0xFFFF, cc, fc, cardnum);
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS,
|
||||
"HID Prox - " _GREEN_("%x%08x (%u)") " - len: " _GREEN_("%u") " bit - OEM: " _GREEN_("%03u") " FC: " _GREEN_("%u")" Card: " _GREEN_("%u"),
|
||||
PrintAndLogEx(SUCCESS,
|
||||
"HID Prox - " _GREEN_("%x%08x (%u)") " - len: " _GREEN_("%u") " bit - OEM: " _GREEN_("%03u") " FC: " _GREEN_("%u")" Card: " _GREEN_("%u"),
|
||||
hi, lo, cardnum, fmtLen, oem, fc, cardnum);
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ static int CmdHIDWatch(const char *Cmd) {
|
||||
PrintAndLogEx(SUCCESS, "Watching for HID Prox cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading cards");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_HID_WATCH, NULL, 0);
|
||||
SendCommandNG(CMD_LF_HID_WATCH, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_HID_WATCH, &resp);
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
|
||||
@@ -738,7 +738,7 @@ void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool
|
||||
}
|
||||
|
||||
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response) {
|
||||
|
||||
|
||||
// iceman: live decrypt of trace?
|
||||
if (is_response) {
|
||||
|
||||
@@ -774,18 +774,18 @@ void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool
|
||||
}
|
||||
|
||||
if (cmdsize == 9) {
|
||||
snprintf(exp, size, "Nr Ar Is response");
|
||||
return;
|
||||
snprintf(exp, size, "Nr Ar Is response");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (cmdsize == 9) {
|
||||
snprintf(exp, size, "Nr Ar");
|
||||
return;
|
||||
snprintf(exp, size, "Nr Ar");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void annotateHitagS(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_reader) {
|
||||
|
||||
@@ -54,7 +54,7 @@ static int usage_lf_indala_demod(void) {
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf indala demod 32") " = demod a Indala tag from GraphBuffer using a clock of RF/32");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf indala demod 32 1") " = demod a Indala tag from GraphBuffer using a clock of RF/32 and inverting data");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf indala demod 64 1 0") " = demod a Indala tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ static int CmdIOProxDemod(const char *Cmd) {
|
||||
char crc_str[36] = {0};
|
||||
|
||||
if (crc == calccrc) {
|
||||
snprintf(crc_str, sizeof(crc_str), "(" _GREEN_("ok") ")" );
|
||||
snprintf(crc_str, sizeof(crc_str), "(" _GREEN_("ok") ")");
|
||||
} else {
|
||||
snprintf(crc_str, sizeof(crc_str), "(" _RED_("fail") ") 0x%02X != 0x%02X", crc, calccrc);
|
||||
retval = PM3_ESOFT;
|
||||
|
||||
@@ -190,7 +190,7 @@ int demodKeri(void) {
|
||||
Might be a hash of FC & CN to generate Internal ID
|
||||
*/
|
||||
|
||||
PrintAndLogEx(SUCCESS, "KERI - Internal ID: " _GREEN_("%u") ", Raw: %08X%08X" , ID, raw1, raw2);
|
||||
PrintAndLogEx(SUCCESS, "KERI - Internal ID: " _GREEN_("%u") ", Raw: %08X%08X", ID, raw1, raw2);
|
||||
/*
|
||||
Descramble Data.
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ static int CmdMotorolaDemod(const char *Cmd) {
|
||||
}
|
||||
|
||||
int demodMotorola(void) {
|
||||
|
||||
|
||||
//PSK1
|
||||
if (PSKDemod("32 1", true) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Motorola: PSK Demod failed");
|
||||
@@ -118,7 +118,7 @@ int demodMotorola(void) {
|
||||
checksum |= DemodBuffer[62] << 1; // b2
|
||||
checksum |= DemodBuffer[63] << 0; // b1
|
||||
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Motorola - fmt: " _GREEN_("26") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u") ", Raw: %08X%08X", fc, csn, raw1, raw2);
|
||||
PrintAndLogEx(DEBUG, "checksum: " _GREEN_("%1d%1d"), checksum >> 1 & 0x01, checksum & 0x01);
|
||||
return PM3_SUCCESS;
|
||||
|
||||
@@ -250,7 +250,7 @@ int demodNexWatch(void) {
|
||||
} else {
|
||||
PrintAndLogEx(DEBUG, " parity : %s (0x%X != 0x%X)", _RED_("fail"), parity, calc_parity);
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(DEBUG, " checksum : %s (0x%02X)", (m_idx < ARRAYLEN(items)) ? _GREEN_("ok") : _RED_("fail"), chk);
|
||||
|
||||
PrintAndLogEx(INFO, " Raw : " _YELLOW_("%"PRIX32"%"PRIX32"%"PRIX32), raw1, raw2, raw3);
|
||||
|
||||
@@ -88,7 +88,7 @@ static int demodbuf_to_pacid(uint8_t *src, const size_t src_size, uint8_t *dst,
|
||||
}
|
||||
|
||||
// overwrite checksum byte with null terminator
|
||||
dst[dataLength - 1] = 0;
|
||||
dst[dataLength - 1] = 0;
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ const uint8_t paradox_lut[] = {
|
||||
0x9F, 0xED, 0x7D, 0x59, 0x22, 0x84, 0x21, 0x4E,
|
||||
0x39, 0x48, 0x12, 0x88, 0x53, 0xDE, 0xBB, 0xE4,
|
||||
0xB4, 0x2D, 0x4D, 0x55, 0xCA, 0xBE, 0xA3, 0xE2
|
||||
};
|
||||
};
|
||||
// FC:108, Card01827
|
||||
// 00000000 01101100 00000111 00100011
|
||||
// hex(0xED xor 0x7D xor 0x22 xor 0x84 xor 0xDE xor 0xBB xor 0xE4 xor 0x4D xor 0xA3 xor 0xE2 xor 0x47) 0xFC
|
||||
@@ -132,7 +132,7 @@ int demodParadox(void) {
|
||||
|
||||
// not manchester data
|
||||
if (bits[i] == bits[i + 1]) {
|
||||
PrintAndLogEx(WARNING, "Error Manchester at %u", i);
|
||||
PrintAndLogEx(WARNING, "Error Manchester at %u", i);
|
||||
error++;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ int demodParadox(void) {
|
||||
lo |= 1; // 10
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setDemodBuff(bits, size, idx);
|
||||
setClockGrid(50, wave_idx + (idx * 50));
|
||||
|
||||
@@ -163,11 +163,11 @@ int demodParadox(void) {
|
||||
// checksum?
|
||||
uint8_t calc_chksum = 0x47;
|
||||
uint8_t pos = 0;
|
||||
for(uint8_t i = 0; i < 8; i++ ) {
|
||||
|
||||
uint8_t ice = rawhex[i+1];
|
||||
for(uint8_t j = 0x80; j > 0; j >>= 2) {
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
|
||||
uint8_t ice = rawhex[i + 1];
|
||||
for (uint8_t j = 0x80; j > 0; j >>= 2) {
|
||||
|
||||
if (ice & j) {
|
||||
calc_chksum ^= paradox_lut[pos];
|
||||
}
|
||||
@@ -178,7 +178,7 @@ int demodParadox(void) {
|
||||
uint32_t crc = CRC8Maxim(rawhex + 1, 8);
|
||||
PrintAndLogEx(DEBUG, " FSK/MAN raw : %s", sprint_hex(rawhex, sizeof(rawhex)));
|
||||
PrintAndLogEx(DEBUG, " raw : %s = (maxim crc8) %02x == %02x", sprint_hex(rawhex + 1, 8), crc, calc_chksum);
|
||||
// PrintAndLogEx(DEBUG, " OTHER sample CRC-8/MAXIM : 55 55 69 A5 55 6A 59 5A = FC");
|
||||
// PrintAndLogEx(DEBUG, " OTHER sample CRC-8/MAXIM : 55 55 69 A5 55 6A 59 5A = FC");
|
||||
|
||||
uint32_t rawLo = bytebits_to_byte(bits + idx + 64, 32);
|
||||
uint32_t rawHi = bytebits_to_byte(bits + idx + 32, 32);
|
||||
|
||||
@@ -1359,8 +1359,8 @@ bool testKnownConfigBlock(uint32_t block0) {
|
||||
case T55X7_NEDAP_128_CONFIG_BLOCK:
|
||||
case T55X7_VISA2000_CONFIG_BLOCK:
|
||||
case T55X7_SECURAKEY_CONFIG_BLOCK:
|
||||
case T55X7_PAC_CONFIG_BLOCK:
|
||||
case T55X7_VERICHIP_CONFIG_BLOCK:
|
||||
case T55X7_PAC_CONFIG_BLOCK:
|
||||
case T55X7_VERICHIP_CONFIG_BLOCK:
|
||||
case T55X7_KERI_CONFIG_BLOCK:
|
||||
case T55X7_NEXWATCH_CONFIG_BLOCK:
|
||||
case T55X7_JABLOTRON_CONFIG_BLOCK:
|
||||
@@ -2109,7 +2109,7 @@ static void printT5x7KnownBlock0(uint32_t b0) {
|
||||
break;
|
||||
case T55X7_NEXWATCH_CONFIG_BLOCK:
|
||||
snprintf(s + strlen(s), sizeof(s) - strlen(s), "NexWatch, Quadrakey ");
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
// and it should actually be "10000" (16)
|
||||
// #define T55X7_FDXB_CONFIG_BLOCK 0x903F8080 // BiPhase, fdx-b - xtended mode, BiPhase ('57), data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_CONFIG_BLOCK 0x903F0082 // BiPhase, fdx-b - xtended mode, BiPhase ('50), invert data, data rate 32, 4 data blocks
|
||||
#define T55X7_FDXB_2_CONFIG_BLOCK 0x00098080 //
|
||||
#define T55X7_FDXB_2_CONFIG_BLOCK 0x00098080 //
|
||||
|
||||
#define T55X7_HID_26_CONFIG_BLOCK 0x00107060 // FSK2a, hid 26 bit - compat mode, data rate 50, 3 data blocks
|
||||
#define T55X7_PARADOX_CONFIG_BLOCK 0x00107060 // FSK2a, hid 26 bit - compat mode, data rate 50, 3 data blocks
|
||||
|
||||
@@ -249,7 +249,7 @@ static int CmdPref(const char *Cmd) {
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
|
||||
{"--------",CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("Technology") " -----------------------"},
|
||||
{"--------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("Technology") " -----------------------"},
|
||||
|
||||
{"analyse", CmdAnalyse, AlwaysAvailable, "{ Analyse utils... }"},
|
||||
{"data", CmdData, AlwaysAvailable, "{ Plot window / data buffer manipulation... }"},
|
||||
@@ -264,7 +264,7 @@ static command_t CommandTable[] = {
|
||||
{"trace", CmdTrace, AlwaysAvailable, "{ Trace manipulation... }"},
|
||||
{"usart", CmdUsart, IfPm3FpcUsartFromUsb, "{ USART commands... }"},
|
||||
{"wiegand", CmdWiegand, AlwaysAvailable, "{ Wiegand format manipulation... }"},
|
||||
{"--------",CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("General") " -----------------------"},
|
||||
{"--------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("General") " -----------------------"},
|
||||
{"auto", CmdAuto, IfPm3Present, "Automated detection process for unknown tags"},
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help. Use " _YELLOW_("'<command> help'") " for details of a particular command."},
|
||||
{"hints", CmdHints, AlwaysAvailable, "Turn hints on / off"},
|
||||
|
||||
@@ -467,7 +467,7 @@ static int CmdSmartRaw(const char *Cmd) {
|
||||
|
||||
uint8_t flags = SC_LOG;
|
||||
if (active || active_select) {
|
||||
|
||||
|
||||
flags |= (SC_CONNECT | SC_CLEARLOG);
|
||||
if (active_select)
|
||||
flags |= SC_SELECT;
|
||||
|
||||
+43
-43
@@ -206,10 +206,10 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
return traceLen;
|
||||
}
|
||||
|
||||
// adjust for different time scales
|
||||
if (protocol == ICLASS || protocol == ISO_15693) {
|
||||
duration *= 32;
|
||||
}
|
||||
// adjust for different time scales
|
||||
if (protocol == ICLASS || protocol == ISO_15693) {
|
||||
duration *= 32;
|
||||
}
|
||||
|
||||
|
||||
uint8_t *frame = hdr->frame;
|
||||
@@ -275,10 +275,10 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
|
||||
if (data_len == 0) {
|
||||
if (protocol == ICLASS && duration == 2048) {
|
||||
sprintf(line[0], "<SOF>");
|
||||
} else if (protocol == ISO_15693 && duration == 512) {
|
||||
sprintf(line[0], "<EOF>");
|
||||
} else {
|
||||
sprintf(line[0], "<SOF>");
|
||||
} else if (protocol == ISO_15693 && duration == 512) {
|
||||
sprintf(line[0], "<EOF>");
|
||||
} else {
|
||||
sprintf(line[0], "<empty trace - possible error>");
|
||||
}
|
||||
}
|
||||
@@ -334,11 +334,11 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
|
||||
uint32_t previous_end_of_transmission_timestamp = 0;
|
||||
if (prev_eot) {
|
||||
if (*prev_eot) {
|
||||
previous_end_of_transmission_timestamp = *prev_eot;
|
||||
} else {
|
||||
previous_end_of_transmission_timestamp = hdr->timestamp;
|
||||
}
|
||||
if (*prev_eot) {
|
||||
previous_end_of_transmission_timestamp = *prev_eot;
|
||||
} else {
|
||||
previous_end_of_transmission_timestamp = hdr->timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
end_of_transmission_timestamp = hdr->timestamp + duration;
|
||||
@@ -355,7 +355,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
|
||||
if (protocol == FELICA)
|
||||
annotateFelica(explanation, sizeof(explanation), frame, data_len);
|
||||
|
||||
|
||||
if (protocol == PROTO_HITAG1) {
|
||||
annotateHitag1(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||
}
|
||||
@@ -405,38 +405,38 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||
if (j == 0) {
|
||||
|
||||
uint32_t time1 = hdr->timestamp - first_hdr->timestamp;
|
||||
uint32_t time2 = end_of_transmission_timestamp - first_hdr->timestamp;
|
||||
if (prev_eot) {
|
||||
time1 = hdr->timestamp - previous_end_of_transmission_timestamp;
|
||||
time2 = duration;
|
||||
}
|
||||
uint32_t time2 = end_of_transmission_timestamp - first_hdr->timestamp;
|
||||
if (prev_eot) {
|
||||
time1 = hdr->timestamp - previous_end_of_transmission_timestamp;
|
||||
time2 = duration;
|
||||
}
|
||||
|
||||
if (use_us) {
|
||||
PrintAndLogEx(NORMAL, " %10.1f | %10.1f | %s |%-72s | %s| %s",
|
||||
(float)time1/13.56,
|
||||
(float)time2/13.56,
|
||||
(hdr->isResponse ? "Tag" : _YELLOW_("Rdr")),
|
||||
line[j],
|
||||
(j == num_lines - 1) ? crc : " ",
|
||||
(j == num_lines - 1) ? explanation : ""
|
||||
);
|
||||
(float)time1 / 13.56,
|
||||
(float)time2 / 13.56,
|
||||
(hdr->isResponse ? "Tag" : _YELLOW_("Rdr")),
|
||||
line[j],
|
||||
(j == num_lines - 1) ? crc : " ",
|
||||
(j == num_lines - 1) ? explanation : ""
|
||||
);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " %10u | %10u | %s |%-72s | %s| %s",
|
||||
(hdr->timestamp - first_hdr->timestamp),
|
||||
(end_of_transmission_timestamp - first_hdr->timestamp),
|
||||
(hdr->isResponse ? "Tag" : _YELLOW_("Rdr")),
|
||||
line[j],
|
||||
(j == num_lines - 1) ? crc : " ",
|
||||
(j == num_lines - 1) ? explanation : ""
|
||||
);
|
||||
(hdr->timestamp - first_hdr->timestamp),
|
||||
(end_of_transmission_timestamp - first_hdr->timestamp),
|
||||
(hdr->isResponse ? "Tag" : _YELLOW_("Rdr")),
|
||||
line[j],
|
||||
(j == num_lines - 1) ? crc : " ",
|
||||
(j == num_lines - 1) ? explanation : ""
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " | | |%-72s | %s| %s",
|
||||
line[j],
|
||||
(j == num_lines - 1) ? crc : " ",
|
||||
(j == num_lines - 1) ? explanation : ""
|
||||
);
|
||||
line[j],
|
||||
(j == num_lines - 1) ? crc : " ",
|
||||
(j == num_lines - 1) ? explanation : ""
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,11 +683,11 @@ int CmdTraceList(const char *Cmd) {
|
||||
}
|
||||
} else {
|
||||
|
||||
if (use_relative) {
|
||||
if (use_relative) {
|
||||
PrintAndLogEx(INFO, _YELLOW_("gap") " = time between transfers. " _YELLOW_("duration") " = duration of data transfer. " _YELLOW_("src") " = source of transfer");
|
||||
} else {
|
||||
} else {
|
||||
PrintAndLogEx(INFO, _YELLOW_("start") " = start of start frame " _YELLOW_("end") " = end of frame. " _YELLOW_("src") " = source of transfer");
|
||||
}
|
||||
}
|
||||
|
||||
if (protocol == ISO_14443A || protocol == PROTO_MIFARE || protocol == MFDES || protocol == TOPAZ || protocol == LTO) {
|
||||
if (use_us)
|
||||
@@ -736,9 +736,9 @@ int CmdTraceList(const char *Cmd) {
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
if (use_relative) {
|
||||
PrintAndLogEx(NORMAL, " Gap | Duration | Src | Data (! denotes parity error, ' denotes short bytes) | CRC | Annotation");
|
||||
} else {
|
||||
if (use_relative) {
|
||||
PrintAndLogEx(NORMAL, " Gap | Duration | Src | Data (! denotes parity error, ' denotes short bytes) | CRC | Annotation");
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation");
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------");
|
||||
|
||||
@@ -497,7 +497,7 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF Message") " ---");
|
||||
if (len == 0) {
|
||||
PrintAndLogEx(SUCCESS, "Found NDEF message w zero length");
|
||||
PrintAndLogEx(SUCCESS, "Found NDEF message w zero length");
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Found NDEF message (%d bytes)", len);
|
||||
|
||||
@@ -505,7 +505,7 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
indx += len;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -909,7 +909,7 @@ static int CmdPrefShow(const char *Cmd) {
|
||||
if (session.preferences_loaded) {
|
||||
char *fn = prefGetFilename();
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "Using "_YELLOW_("%s"), fn);
|
||||
PrintAndLogEx(INFO, "Using "_YELLOW_("%s"), fn);
|
||||
free(fn);
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Preferences not loaded");
|
||||
|
||||
Reference in new issue
Block a user