hf iclass reader - unified to support -@

This commit is contained in:
iceman1001 2020-12-02 15:24:11 +01:00
commit effe02d1d3

View file

@ -587,7 +587,7 @@ int read_iclass_csn(bool loop, bool verbose) {
uint32_t flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE); uint32_t flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE);
int res = PM3_SUCCESS; int res = PM3_SUCCESS;
while (kbd_enter_pressed() == false) { do {
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_HF_ICLASS_READER, flags, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ICLASS_READER, flags, 0, 0, NULL, 0);
@ -596,27 +596,23 @@ int read_iclass_csn(bool loop, bool verbose) {
uint8_t status = resp.oldarg[0] & 0xff; uint8_t status = resp.oldarg[0] & 0xff;
if (loop == false) { if (loop) {
if (status == 0xFF) {
continue;
}
} else {
if (status == 0 || status == 0xFF) { if (status == 0 || status == 0xFF) {
if (verbose) PrintAndLogEx(WARNING, "iCLASS / ISO15693 card select failed"); if (verbose) PrintAndLogEx(WARNING, "iCLASS / ISO15693 card select failed");
res = PM3_EOPABORTED; res = PM3_EOPABORTED;
break; break;
} }
} else {
if (status == 0xFF)
continue;
} }
picopass_hdr *hdr = (picopass_hdr *)resp.data.asBytes; picopass_hdr *hdr = (picopass_hdr *)resp.data.asBytes;
PrintAndLogEx(SUCCESS, "iCLASS / Picopass CSN: " _GREEN_("%s"), sprint_hex(hdr->csn, sizeof(hdr->csn)));
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;
}
} }
} while (loop && kbd_enter_pressed() == false);
DropField(); DropField();
return res; return res;
@ -626,22 +622,24 @@ static int CmdHFiClassReader(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "hf iclass reader", CLIParserInit(&ctx, "hf iclass reader",
"Act as a iCLASS reader. Look for iCLASS tags until Enter or the pm3 button is pressed\n", "Act as a iCLASS reader. Look for iCLASS tags until Enter or the pm3 button is pressed",
"hf iclass reader\n" "hf iclass reader -@ -> continuous reader mode"
"hf iclass reader -1"); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("1", "one", "read once"), arg_lit0("@", NULL, "optional - continuous reader mode"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
bool read_once = arg_get_lit(ctx, 1); bool cm = arg_get_lit(ctx, 1);
CLIParserFree(ctx); CLIParserFree(ctx);
PrintAndLogEx(INFO, "Starting iCLASS reader mode"); if (cm) {
PrintAndLogEx(INFO, "press " _YELLOW_("`enter`") " to cancel"); PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
return read_iclass_csn(!read_once, true); }
return read_iclass_csn(cm, true);
} }
static int CmdHFiClassELoad(const char *Cmd) { static int CmdHFiClassELoad(const char *Cmd) {