From ae6580f65b0c027257f28745c85aafc546714a04 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Fri, 28 May 2021 19:05:00 +0300 Subject: [PATCH] check cipurse via `hf search` --- client/src/cmdhf.c | 9 +++++++++ client/src/cmdhfcipurse.c | 9 +++++++++ client/src/cmdhfcipurse.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index 94384c580..ca4753d7c 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -128,6 +128,15 @@ int CmdHFSearch(const char *Cmd) { res = PM3_SUCCESS; } } + + PROMPT_CLEARLINE; + PrintAndLogEx(INPLACE, " Searching for Cipurse tag..."); + if (IfPm3Iso14443a()) { + if (CheckCardCipurse()) { + PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Cipurse tag") " found\n"); + res = PM3_SUCCESS; + } + } // 14b is the longest test PROMPT_CLEARLINE; diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index f519a4be9..1a1cd7770 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -84,6 +84,15 @@ static int CmdHFCipurseInfo(const char *Cmd) { +bool CheckCardCipurse(void) { + uint8_t buf[APDU_RES_LEN] = {0}; + size_t len = 0; + uint16_t sw = 0; + int res = CIPURSESelect(true, false, buf, sizeof(buf), &len, &sw); + + return (res == 0 && sw == 0x9000); +} + static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help."}, {"info", CmdHFCipurseInfo, IfPm3Iso14443a, "Info about Cipurse tag."}, diff --git a/client/src/cmdhfcipurse.h b/client/src/cmdhfcipurse.h index 86d0f63be..85e98ed60 100644 --- a/client/src/cmdhfcipurse.h +++ b/client/src/cmdhfcipurse.h @@ -20,4 +20,6 @@ int CmdHFCipurse(const char *Cmd); +bool CheckCardCipurse(void); + #endif