From 0d1f8ca957c0ae6f3039237889cdabe5921afe2d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 30 Apr 2021 11:18:14 +0200 Subject: [PATCH] making a 14a select fct reachable, in order to do a test in desfire code without repeating same ftc --- client/src/cmdhf14a.c | 4 ++-- client/src/cmdhf14a.h | 1 + client/src/cmdhfmfdes.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 2516ac8b8..93b7e23e8 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -843,7 +843,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav return 0; } -static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) { +int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) { PacketResponseNG resp; frameLength = 0; @@ -862,7 +862,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) { // check result if (resp.oldarg[0] == 0) { - PrintAndLogEx(ERR, "No card in fiel."); + PrintAndLogEx(ERR, "No card in field"); return PM3_ECARDEXCHANGE; } diff --git a/client/src/cmdhf14a.h b/client/src/cmdhf14a.h index a1a2279a0..49017c142 100644 --- a/client/src/cmdhf14a.h +++ b/client/src/cmdhf14a.h @@ -34,4 +34,5 @@ int Hf14443_4aGetCardData(iso14a_card_select_t *card); int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen); int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, bool silentMode); +int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card); #endif diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index b2f5d79ee..7717954a7 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -3604,6 +3604,22 @@ static int CmdHF14ADesInfo(const char *Cmd) { } PrintAndLogEx(INFO, "-------------------------------------------------------------"); } + + + iso14a_card_select_t card; + res = SelectCard14443_4(true, &card); + if (res == PM3_SUCCESS) { + static const char STANDALONE_DESFIRE[] = { 0x75, 0x77, 0x81, 0x02}; + static const char JCOP_DESFIRE[] = { 0x75, 0xf7, 0xb1, 0x02 }; + + if (str_startswith((const char*)card.ats + 1, STANDALONE_DESFIRE)) { + PrintAndLogEx(INFO, "Standalone DESFire"); + } + if (str_startswith((const char*)card.ats + 1, JCOP_DESFIRE)) { + PrintAndLogEx(INFO, "JCOP DESFire"); + } + } + /* Card Master key (CMK) 0x00 AID = 00 00 00 (card level) Application Master Key (AMK) 0x00 AID != 00 00 00