From 8136decadd9dab8d241c66cdf60b67c12feaa29d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 10 Oct 2017 14:59:58 +0200 Subject: [PATCH] ADD: hooking up the new felica commands --- client/Makefile | 1 + client/cmdhf.c | 21 +++++++++++++++++++++ client/cmdhf.h | 7 ++++--- client/cmdhffelica.c | 16 ++++++---------- client/cmdhffelica.h | 2 +- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/client/Makefile b/client/Makefile index 451bbaedc..938de599d 100644 --- a/client/Makefile +++ b/client/Makefile @@ -129,6 +129,7 @@ CMDSRCS = crapto1/crapto1.c \ cmdhfmfdes.c \ cmdhftopaz.c \ cmdhfemv.c \ + cmdhffelica.c \ cmdhw.c \ cmdlf.c \ cmdlfawid.c \ diff --git a/client/cmdhf.c b/client/cmdhf.c index 6731c48b2..3f59533ae 100644 --- a/client/cmdhf.c +++ b/client/cmdhf.c @@ -404,6 +404,12 @@ void annotateLegic(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize){ } } +void annotateFelica(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize){ + switch(cmd[0]){ + default : snprintf(exp,size ,"?");break; + } +} + /** * @brief iso14443A_CRC_check Checks CRC in command or response * @param isResponse @@ -633,6 +639,7 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui break; case ISO_14443B: case TOPAZ: + case FELICA: crcStatus = iso14443B_CRC_check(isResponse, frame, data_len); break; case ISO_14443A: @@ -701,6 +708,7 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui case TOPAZ: annotateTopaz(explanation,sizeof(explanation),frame,data_len); break; case ISO_7816_4: annotateIso7816(explanation,sizeof(explanation),frame,data_len); break; case ISO_15693: annotateIso15693(explanation,sizeof(explanation),frame,data_len); break; + case FELICA: annotateFelica(explanation,sizeof(explanation),frame,data_len); break; default: break; } } @@ -756,6 +764,7 @@ int usage_hf_list(){ PrintAndLog(" topaz - interpret data as topaz communications"); PrintAndLog(" 7816 - interpret data as iso7816-4 communications"); PrintAndLog(" legic - interpret data as LEGIC communications"); + PrintAndLog(" felica - interpret data as ISO18092 / FeliCa communications"); PrintAndLog(""); PrintAndLog("example: hf list 14a f"); PrintAndLog(" hf list iclass"); @@ -818,6 +827,7 @@ int CmdHFList(const char *Cmd) { else if(strcmp(type, "des")== 0) protocol = MFDES; else if(strcmp(type, "legic")==0) protocol = LEGIC; else if(strcmp(type, "15")==0) protocol = ISO_15693; + else if(strcmp(type, "felica")==0) protocol = FELICA; else if(strcmp(type, "raw")== 0) protocol = -1;//No crc, no annotations else errors = true; @@ -862,6 +872,8 @@ int CmdHFList(const char *Cmd) { PrintAndLog("LEGIC - Timings are in ticks (1us == 1.5ticks)"); if ( protocol == ISO_15693 ) PrintAndLog("ISO15693 - Timings are not as accurate"); + if ( protocol == FELICA ) + PrintAndLog("ISO18092 / FeliCa - Timings are not as accurate"); PrintAndLog(""); PrintAndLog(" Start | End | Src | Data (! denotes parity error) | CRC | Annotation |"); @@ -912,6 +924,14 @@ int CmdHFSearch(const char *Cmd){ PrintAndLog("\nValid iClass Tag (or PicoPass Tag) Found - Quiting Search\n"); return ans; } + + /* + ans = CmdHFFelicaReader("s"); + if (ans) { + PrintAndLog("\nValid ISO18092 / FeliCa Found - Quiting Search\n"); + return ans; + } + */ PrintAndLog("\nno known/supported 13.56 MHz tags found\n"); return 0; @@ -939,6 +959,7 @@ static command_t CommandTable[] = { #ifdef WITH_EMV {"emv", CmdHFEmv, 1, "{ EMV RFIDs... }"}, #endif + {"felica", CmdHFFelica, 1, "{ ISO18092 / Felica RFIDs... }"}, {"legic", CmdHFLegic, 1, "{ LEGIC RFIDs... }"}, {"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"}, {"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"}, diff --git a/client/cmdhf.h b/client/cmdhf.h index 7697f6da1..7f5d80a04 100644 --- a/client/cmdhf.h +++ b/client/cmdhf.h @@ -18,8 +18,8 @@ #include "graph.h" #include "ui.h" #include "cmdparser.h" -#include "cmdhf14a.h" // 14443 a -#include "cmdhf14b.h" // 14443 b +#include "cmdhf14a.h" // ISO14443-A +#include "cmdhf14b.h" // ISO14443-B #include "cmdhf15.h" // ISO15693 #include "cmdhfepa.h" #include "cmdhflegic.h" // LEGIC @@ -29,9 +29,10 @@ #include "cmdhfmfdes.h" // DESFIRE #include "cmdhftopaz.h" // TOPAZ #include "cmdhfemv.h" // EMV +#include "cmdhffelica.h" // ISO18092 / FeliCa #include "protocols.h" #include "parity.h" // oddparity -#include "iso15693tools.h" // iso15693 crc +#include "iso15693tools.h" // ISO15693 crc extern int CmdHF(const char *Cmd); extern int CmdHFTune(const char *Cmd); diff --git a/client/cmdhffelica.c b/client/cmdhffelica.c index 12930dcef..aeebd919b 100644 --- a/client/cmdhffelica.c +++ b/client/cmdhffelica.c @@ -96,10 +96,7 @@ int CmdHFFelicaSim(const char *Cmd) { uint8_t cmdp = 0; uint8_t uid[10] = {0,0,0,0,0,0,0,0,0,0}; int uidlen = 0; - bool useUIDfromEML = true; - bool setEmulatorMem = false; - bool verbose = false; - nonces_t data[1]; + bool verbose = false; while(param_getchar(Cmd, cmdp) != 0x00 && !errors) { switch(param_getchar(Cmd, cmdp)) { @@ -120,7 +117,6 @@ int CmdHFFelicaSim(const char *Cmd) { param_gethex_ex(Cmd, cmdp+1, uid, &uidlen); if (!errors) { PrintAndLog("Emulating ISO18092/FeliCa tag with %d byte UID (%s)", uidlen>>1, sprint_hex(uid, uidlen>>1)); - useUIDfromEML = false; } cmdp += 2; break; @@ -131,7 +127,6 @@ int CmdHFFelicaSim(const char *Cmd) { break; case 'e': case 'E': - setEmulatorMem = true; cmdp++; break; default: @@ -150,7 +145,8 @@ int CmdHFFelicaSim(const char *Cmd) { SendCommand(&c); UsbCommand resp; - PrintAndLog("Press pm3-button to abort simulation"); + if ( verbose ) + PrintAndLog("Press pm3-button to abort simulation"); while( !ukbhit() ){ if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500) ) continue; @@ -304,14 +300,14 @@ int CmdHFFelicaCmdRaw(const char *cmd) { if (reply) { if (active_select) - waitCmd(1); + waitCmdFelica(1); if (datalen > 0) - waitCmd(0); + waitCmdFelica(0); } return 0; } -void waitCmd(uint8_t iSelect) { +void waitCmdFelica(uint8_t iSelect) { UsbCommand resp; uint16_t len = 0; diff --git a/client/cmdhffelica.h b/client/cmdhffelica.h index 82a206d82..62786c193 100644 --- a/client/cmdhffelica.h +++ b/client/cmdhffelica.h @@ -37,5 +37,5 @@ extern int usage_hf_felica_sim(void); extern int usage_hf_felica_sniff(void); extern int usage_hf_fFelica_raw(void); -void waitCmd(uint8_t iSelect); +void waitCmdFelica(uint8_t iSelect); #endif