diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6ceef796e..46628163e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -220,7 +220,7 @@ set (TARGET_SOURCES ${PM3_ROOT}/client/src/mifare/mifare4.c ${PM3_ROOT}/client/src/mifare/mifaredefault.c ${PM3_ROOT}/client/src/mifare/mifarehost.c - ${PM3_ROOT}/client/src/mifare/ndef.c + ${PM3_ROOT}/client/src/nfc/ndef.c ${PM3_ROOT}/client/src/mifare/desfire_crypto.c ${PM3_ROOT}/client/src/uart/uart_posix.c ${PM3_ROOT}/client/src/uart/uart_win32.c @@ -291,6 +291,7 @@ set (TARGET_SOURCES ${PM3_ROOT}/client/src/cmdlfviking.c ${PM3_ROOT}/client/src/cmdlfvisa2000.c ${PM3_ROOT}/client/src/cmdmain.c + ${PM3_ROOT}/client/src/cmdnfc.c ${PM3_ROOT}/client/src/cmdparser.c ${PM3_ROOT}/client/src/cmdscript.c ${PM3_ROOT}/client/src/cmdsmartcard.c diff --git a/client/Makefile b/client/Makefile index f865e608f..726351cdc 100644 --- a/client/Makefile +++ b/client/Makefile @@ -523,6 +523,7 @@ SRCS = aiddesfire.c \ cmdlfviking.c \ cmdlfvisa2000.c \ cmdmain.c \ + cmdnfc.c \ cmdparser.c \ cmdscript.c \ cmdsmartcard.c \ @@ -570,7 +571,7 @@ SRCS = aiddesfire.c \ mifare/mifare4.c \ mifare/mifaredefault.c \ mifare/mifarehost.c \ - mifare/ndef.c \ + nfc/ndef.c \ pm3.c \ pm3_binlib.c \ pm3_bitlib.c \ diff --git a/client/android/CMakeLists.txt b/client/android/CMakeLists.txt index fd98323fa..2197052b1 100644 --- a/client/android/CMakeLists.txt +++ b/client/android/CMakeLists.txt @@ -88,7 +88,7 @@ add_library(pm3rrg_rdv4 SHARED ${PM3_ROOT}/client/src/mifare/mifare4.c ${PM3_ROOT}/client/src/mifare/mifaredefault.c ${PM3_ROOT}/client/src/mifare/mifarehost.c - ${PM3_ROOT}/client/src/mifare/ndef.c + ${PM3_ROOT}/client/src/nfc/ndef.c ${PM3_ROOT}/client/src/mifare/desfire_crypto.c ${PM3_ROOT}/client/src/uart/uart_posix.c ${PM3_ROOT}/client/src/uart/uart_win32.c @@ -158,6 +158,7 @@ add_library(pm3rrg_rdv4 SHARED ${PM3_ROOT}/client/src/cmdlfviking.c ${PM3_ROOT}/client/src/cmdlfvisa2000.c ${PM3_ROOT}/client/src/cmdmain.c + ${PM3_ROOT}/client/src/cmdnfc.c ${PM3_ROOT}/client/src/cmdparser.c ${PM3_ROOT}/client/src/cmdscript.c ${PM3_ROOT}/client/src/cmdsmartcard.c diff --git a/client/experimental_lib/CMakeLists.txt b/client/experimental_lib/CMakeLists.txt index 1aeea30e2..4b0f0f174 100644 --- a/client/experimental_lib/CMakeLists.txt +++ b/client/experimental_lib/CMakeLists.txt @@ -220,7 +220,7 @@ set (TARGET_SOURCES ${PM3_ROOT}/client/src/mifare/mifare4.c ${PM3_ROOT}/client/src/mifare/mifaredefault.c ${PM3_ROOT}/client/src/mifare/mifarehost.c - ${PM3_ROOT}/client/src/mifare/ndef.c + ${PM3_ROOT}/client/src/nfc/ndef.c ${PM3_ROOT}/client/src/mifare/desfire_crypto.c ${PM3_ROOT}/client/src/uart/uart_posix.c ${PM3_ROOT}/client/src/uart/uart_win32.c @@ -290,6 +290,7 @@ set (TARGET_SOURCES ${PM3_ROOT}/client/src/cmdlfviking.c ${PM3_ROOT}/client/src/cmdlfvisa2000.c ${PM3_ROOT}/client/src/cmdmain.c + ${PM3_ROOT}/client/src/cmdnfc.c ${PM3_ROOT}/client/src/cmdparser.c ${PM3_ROOT}/client/src/cmdscript.c ${PM3_ROOT}/client/src/cmdsmartcard.c diff --git a/client/src/cmddata.c b/client/src/cmddata.c index e61c1808c..2a715325c 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -25,7 +25,6 @@ #include "loclass/cipherutils.h" // for decimating samples in getsamples #include "cmdlfem410x.h" // askem410xdecode #include "fileutils.h" // searchFile -#include "mifare/ndef.h" #include "cliparser.h" #include "cmdlft55xx.h" // print... #include "crypto/asn1utils.h" // ASN1 decode / print @@ -2692,44 +2691,6 @@ static int CmdDataIIR(const char *Cmd) { return PM3_SUCCESS; } -static int CmdDataNDEF(const char *Cmd) { - -#ifndef MAX_NDEF_LEN -#define MAX_NDEF_LEN 2048 -#endif - - CLIParserContext *ctx; - CLIParserInit(&ctx, "data ndef", - "Decode and print NFC Data Exchange Format (NDEF)", - "data ndef -d 9101085402656e48656c6c6f5101085402656e576f726c64\n" - "data ndef -d 0103d020240203e02c040300fe\n" - ); - - void *argtable[] = { - arg_param_begin, - arg_strx0("d", "data", "", "NDEF data to decode"), - arg_lit0("v", "verbose", "verbose mode"), - arg_param_end - }; - CLIExecWithReturn(ctx, Cmd, argtable, false); - - int datalen = 0; - uint8_t data[MAX_NDEF_LEN] = {0}; - CLIGetHexWithReturn(ctx, 1, data, &datalen); - bool verbose = arg_get_lit(ctx, 2); - - CLIParserFree(ctx); - if (datalen == 0) - return PM3_EINVARG; - - int res = NDEFDecodeAndPrint(data, datalen, verbose); - if (res != PM3_SUCCESS) { - PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header"); - res = NDEFRecordsDecodeAndPrint(data, datalen); - } - return res; -} - typedef struct { t55xx_modulation modulation; int bitrate; @@ -2951,7 +2912,6 @@ static command_t CommandTable[] = { {"hexsamples", CmdHexsamples, IfPm3Present, "Dump big buffer as hex bytes"}, {"hex2bin", Cmdhex2bin, AlwaysAvailable, "Converts hexadecimal to binary"}, {"load", CmdLoad, AlwaysAvailable, "Load contents of file into graph window"}, - {"ndef", CmdDataNDEF, AlwaysAvailable, "Decode NDEF records"}, {"print", CmdPrintDemodBuff, AlwaysAvailable, "Print the data in the DemodBuffer"}, {"samples", CmdSamples, IfPm3Present, "Get raw samples for graph window (GraphBuffer)"}, {"save", CmdSave, AlwaysAvailable, "Save signal trace data (from graph window)"}, diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 81e7cf825..9f3ce0190 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -29,7 +29,7 @@ #include "cliparser.h" #include "protocols.h" // definitions of ISO14A/7816 protocol, MAGIC_GEN_1A #include "emv/apduinfo.h" // GetAPDUCodeDescription -#include "mifare/ndef.h" // NDEFRecordsDecodeAndPrint +#include "nfc/ndef.h" // NDEFRecordsDecodeAndPrint bool APDUInFramingEnable = true; @@ -2346,11 +2346,11 @@ static void print_cc_info(uint8_t *d, uint8_t n) { PrintAndLogEx(NORMAL, ""); } -static int CmdHF14ANdef(const char *Cmd) { +int CmdHF14ANdefRead(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "hf 14a ndef", + CLIParserInit(&ctx, "hf 14a ndefread", "Read NFC Data Exchange Format (NDEF) file on Type 4 NDEF tag", - "hf 14a ndef\n"); + "hf 14a ndefread\n"); void *argtable[] = { arg_param_begin, @@ -2539,7 +2539,7 @@ static command_t CommandTable[] = { {"list", CmdHF14AList, AlwaysAvailable, "List ISO 14443-a history"}, {"info", CmdHF14AInfo, IfPm3Iso14443a, "Tag information"}, {"reader", CmdHF14AReader, IfPm3Iso14443a, "Act like an ISO14443-a reader"}, - {"ndef", CmdHF14ANdef, IfPm3Iso14443a, "Read an NDEF file from ISO 14443-A Type 4 tag"}, + {"ndefread", CmdHF14ANdefRead, IfPm3Iso14443a, "Read an NDEF file from ISO 14443-A Type 4 tag"}, {"cuids", CmdHF14ACUIDs, IfPm3Iso14443a, "Collect n>0 ISO14443-a UIDs in one go"}, {"sim", CmdHF14ASim, IfPm3Iso14443a, "Simulate ISO 14443-a tag"}, {"sniff", CmdHF14ASniff, IfPm3Iso14443a, "sniff ISO 14443-a traffic"}, diff --git a/client/src/cmdhf14a.h b/client/src/cmdhf14a.h index 49017c142..a6791dfe5 100644 --- a/client/src/cmdhf14a.h +++ b/client/src/cmdhf14a.h @@ -25,6 +25,7 @@ typedef struct { int CmdHF14A(const char *Cmd); int CmdHF14ASniff(const char *Cmd); // used by hf topaz sniff int CmdHF14ASim(const char *Cmd); // used by hf mfu sim +int CmdHF14ANdefRead(const char *Cmd); int hf14a_getconfig(hf14a_config *config); int hf14a_setconfig(hf14a_config *config, bool verbose); diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 309cd7ce3..ada329bd7 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -23,7 +23,7 @@ #include "cmdhf14a.h" #include "protocols.h" // definitions of ISO14B/7816 protocol #include "emv/apduinfo.h" // GetAPDUCodeDescription -#include "mifare/ndef.h" // NDEFRecordsDecodeAndPrint +#include "nfc/ndef.h" // NDEFRecordsDecodeAndPrint #include "aidsearch.h" #define MAX_14B_TIMEOUT_MS (4949U) @@ -1915,12 +1915,12 @@ static int CmdHF14BAPDU(const char *Cmd) { return PM3_SUCCESS; } -static int CmdHF14BNdef(const char *Cmd) { +int CmdHF14BNdefRead(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "hf 14b ndef", + CLIParserInit(&ctx, "hf 14b ndefread", "Print NFC Data Exchange Format (NDEF)", - "hf 14b ndef" + "hf 14b ndefread" ); void *argtable[] = { arg_param_begin, @@ -2023,7 +2023,7 @@ static command_t CommandTable[] = { {"dump", CmdHF14BDump, IfPm3Iso14443b, "Read all memory pages of an ISO-14443-B tag, save to file"}, {"info", CmdHF14Binfo, IfPm3Iso14443b, "Tag information"}, {"list", CmdHF14BList, AlwaysAvailable, "List ISO-14443-B history"}, - {"ndef", CmdHF14BNdef, IfPm3Iso14443b, "Read NDEF file on tag"}, + {"ndefread", CmdHF14BNdefRead, IfPm3Iso14443b, "Read NDEF file on tag"}, {"raw", CmdHF14BCmdRaw, IfPm3Iso14443b, "Send raw hex data to tag"}, {"reader", CmdHF14BReader, IfPm3Iso14443b, "Act as a ISO-14443-B reader to identify a tag"}, // {"restore", CmdHF14BRestore, IfPm3Iso14443b, "Restore from file to all memory pages of an ISO-14443-B tag"}, diff --git a/client/src/cmdhf14b.h b/client/src/cmdhf14b.h index ca05bc02e..25f94eabf 100644 --- a/client/src/cmdhf14b.h +++ b/client/src/cmdhf14b.h @@ -14,6 +14,7 @@ #include "common.h" int CmdHF14B(const char *Cmd); +int CmdHF14BNdefRead(const char *Cmd); int exchange_14b_apdu(uint8_t *datain, int datainlen, bool activate_field, bool leave_signal_on, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, int user_timeout); diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index 39a4d4286..2758a7cb2 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -14,7 +14,7 @@ #include "cmdparser.h" #include "generator.h" #include "base64.h" -#include "mifare/ndef.h" // print decode ndef +#include "nfc/ndef.h" // print decode ndef #include "mifare/mifarehost.h" // mfemlsetmem_xt #include "cliparser.h" #include "cmdhfmfu.h" @@ -651,7 +651,7 @@ static int CmdHF14AJookiClone(const char *Cmd) { } PrintAndLogEx(INFO, "Done"); - PrintAndLogEx(HINT, "Try `" _YELLOW_("hf mfu ndef") "` to view"); + PrintAndLogEx(HINT, "Try `" _YELLOW_("hf mfu ndefread") "` to view"); return PM3_SUCCESS; } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 3324ba3dc..089a51fa0 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -20,7 +20,7 @@ #include "cliparser.h" // argtable #include "hardnested_bf_core.h" // SetSIMDInstr #include "mifare/mad.h" -#include "mifare/ndef.h" +#include "nfc/ndef.h" #include "protocols.h" #include "util_posix.h" // msclock #include "cmdhfmfhard.h" @@ -5320,14 +5320,14 @@ static int CmdHF14AMfMAD(const char *Cmd) { return PM3_SUCCESS; } -static int CmdHFMFNDEF(const char *Cmd) { +int CmdHFMFNDEFRead(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "hf mf ndef", + CLIParserInit(&ctx, "hf mf ndefread", "Prints NFC Data Exchange Format (NDEF)", - "hf mf ndef -> shows NDEF parsed data\n" - "hf mf ndef -vv -> shows NDEF parsed and raw data\n" - "hf mf ndef --aid e103 -k ffffffffffff -b -> shows NDEF data with custom AID, key and with key B\n"); + "hf mf ndefread -> shows NDEF parsed data\n" + "hf mf ndefread -vv -> shows NDEF parsed and raw data\n" + "hf mf ndefread --aid e103 -k ffffffffffff -b -> shows NDEF data with custom AID, key and with key B\n"); void *argtable[] = { arg_param_begin, @@ -5371,7 +5371,7 @@ static int CmdHFMFNDEF(const char *Cmd) { if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector0)) { PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't have MAD on default keys"); - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -k `") " with your custom key"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -k `") " with your custom key"); return PM3_ESOFT; } @@ -5388,7 +5388,7 @@ static int CmdHFMFNDEF(const char *Cmd) { if (mfReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector10)) { PrintAndLogEx(ERR, "error, read sector 0x10. card don't have MAD or don't have MAD on default keys"); - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -k `") " with your custom key"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -k `") " with your custom key"); return PM3_ESOFT; } } @@ -5431,7 +5431,7 @@ static int CmdHFMFNDEF(const char *Cmd) { NDEFDecodeAndPrint(data, datalen, verbose); - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -vv`") " for more details"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -vv`") " for more details"); return PM3_SUCCESS; } @@ -6026,7 +6026,7 @@ static command_t CommandTable[] = { {"auth4", CmdHF14AMfAuth4, IfPm3Iso14443a, "ISO14443-4 AES authentication"}, {"dump", CmdHF14AMfDump, IfPm3Iso14443a, "Dump MIFARE Classic tag to binary file"}, {"mad", CmdHF14AMfMAD, IfPm3Iso14443a, "Checks and prints MAD"}, - {"ndef", CmdHFMFNDEF, IfPm3Iso14443a, "Prints NDEF records from card"}, + {"ndefread", CmdHFMFNDEFRead, IfPm3Iso14443a, "Prints NDEF records from card"}, {"personalize", CmdHFMFPersonalize, IfPm3Iso14443a, "Personalize UID (MIFARE Classic EV1 only)"}, {"rdbl", CmdHF14AMfRdBl, IfPm3Iso14443a, "Read MIFARE Classic block"}, {"rdsc", CmdHF14AMfRdSc, IfPm3Iso14443a, "Read MIFARE Classic sector"}, diff --git a/client/src/cmdhfmf.h b/client/src/cmdhfmf.h index a4258bc67..e887efa38 100644 --- a/client/src/cmdhfmf.h +++ b/client/src/cmdhfmf.h @@ -18,6 +18,7 @@ int CmdHFMF(const char *Cmd); int CmdHF14AMfELoad(const char *Cmd); // used by cmd hf mfu eload int CmdHF14AMfDbg(const char *Cmd); // used by cmd hf mfu dbg +int CmdHFMFNDEFRead(const char *Cmd); void showSectorTable(sector_t *k_sector, uint8_t k_sectorsCount); void readerAttack(sector_t *k_sector, uint8_t k_sectorsCount, nonces_t data, bool setEmulatorMem, bool verbose); diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 5626e8855..e1ca0c9ca 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -31,7 +31,7 @@ #include "crapto1/crapto1.h" #include "fileutils.h" #include "mifare/mifaredefault.h" // default keys -#include "mifare/ndef.h" // NDEF +#include "nfc/ndef.h" // NDEF #include "mifare/mad.h" #include "generator.h" #include "aiddesfire.h" @@ -4887,15 +4887,15 @@ static int CmdHF14ADesList(const char *Cmd) { } /* -static int CmdHF14aDesNDEF(const char *Cmd) { +static int CmdHF14aDesNDEFRead(const char *Cmd) { DropFieldDesfire(); CLIParserContext *ctx; - CLIParserInit(&ctx, "hf mfdes ndef", + CLIParserInit(&ctx, "hf mfdes ndefread", "Prints NFC Data Exchange Format (NDEF)", - "hf mfdes ndef -> shows NDEF data\n" - "hf mfdes ndef -v -> shows NDEF parsed and raw data\n" - "hf mfdes ndef -a e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7 -> shows NDEF data with custom AID and key"); + "hf mfdes ndefread -> shows NDEF data\n" + "hf mfdes ndefread -v -> shows NDEF parsed and raw data\n" + "hf mfdes ndefread -a e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7 -> shows NDEF data with custom AID and key"); void *argtable[] = { arg_param_begin, @@ -4984,7 +4984,7 @@ static int CmdHF14aDesNDEF(const char *Cmd) { print_buffer(data, datalen, 1); } - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes ndef -vv`") " for more details"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes ndefread -vv`") " for more details"); return PM3_SUCCESS; } */ @@ -5050,7 +5050,7 @@ static command_t CommandTable[] = { {"getuid", CmdHF14ADesGetUID, IfPm3Iso14443a, "Get random uid"}, {"info", CmdHF14ADesInfo, IfPm3Iso14443a, "Tag information"}, {"list", CmdHF14ADesList, AlwaysAvailable, "List DESFire (ISO 14443A) history"}, -// {"ndef", CmdHF14aDesNDEF, IfPm3Iso14443a, "Prints NDEF records from card"}, +// {"ndefread", CmdHF14aDesNDEFRead, IfPm3Iso14443a, "Prints NDEF records from card"}, // {"mad", CmdHF14aDesMAD, IfPm3Iso14443a, "Prints MAD records from card"}, {"-----------", CmdHelp, IfPm3Iso14443a, "-------------------- " _CYAN_("Applications") " -------------------"}, {"bruteaid", CmdHF14ADesBruteApps, IfPm3Iso14443a, "Recover AIDs by bruteforce"}, diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index 37a17c395..9318abadb 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -19,7 +19,7 @@ #include "cmdhf14a.h" #include "mifare/mifare4.h" #include "mifare/mad.h" -#include "mifare/ndef.h" +#include "nfc/ndef.h" #include "cliparser.h" #include "mifare/mifaredefault.h" #include "util_posix.h" @@ -1458,14 +1458,14 @@ static int CmdHFMFPMAD(const char *Cmd) { return PM3_SUCCESS; } -static int CmdHFMFPNDEF(const char *Cmd) { +int CmdHFMFPNDEFRead(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "hf mfp ndef", + CLIParserInit(&ctx, "hf mfp ndefread", "Prints NFC Data Exchange Format (NDEF)", - "hf mfp ndef -> shows NDEF data\n" - "hf mfp ndef -vv -> shows NDEF parsed and raw data\n" - "hf mfp ndef -a e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7 -> shows NDEF data with custom AID and key"); + "hf mfp ndefread -> shows NDEF data\n" + "hf mfp ndefread -vv -> shows NDEF parsed and raw data\n" + "hf mfp ndefread -a e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7 -> shows NDEF data with custom AID and key"); void *argtable[] = { arg_param_begin, @@ -1509,7 +1509,7 @@ static int CmdHFMFPNDEF(const char *Cmd) { if (mfpReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector0, verbose)) { PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't have MAD on default keys"); - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndef -k `") " with your custom key"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndefread -k `") " with your custom key"); return PM3_ESOFT; } @@ -1527,7 +1527,7 @@ static int CmdHFMFPNDEF(const char *Cmd) { if (mfpReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector10, verbose)) { PrintAndLogEx(ERR, "error, read sector 0x10. card don't have MAD or don't have MAD on default keys"); - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -k `") " with your custom key"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndefread -k `") " with your custom key"); return PM3_ESOFT; } } @@ -1569,7 +1569,7 @@ static int CmdHFMFPNDEF(const char *Cmd) { } NDEFDecodeAndPrint(data, datalen, verbose); - PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndef -vv`") " for more details"); + PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndefread -vv`") " for more details"); return PM3_SUCCESS; } @@ -1585,7 +1585,7 @@ static command_t CommandTable[] = { {"wrbl", CmdHFMFPWrbl, IfPm3Iso14443a, "Write blocks"}, {"chk", CmdHFMFPChk, IfPm3Iso14443a, "Check keys"}, {"mad", CmdHFMFPMAD, IfPm3Iso14443a, "Checks and prints MAD"}, - {"ndef", CmdHFMFPNDEF, IfPm3Iso14443a, "Prints NDEF records from card"}, + {"ndefread", CmdHFMFPNDEFRead, IfPm3Iso14443a, "Prints NDEF records from card"}, {NULL, NULL, 0, NULL} }; diff --git a/client/src/cmdhfmfp.h b/client/src/cmdhfmfp.h index a26aeab87..14c1e65c7 100644 --- a/client/src/cmdhfmfp.h +++ b/client/src/cmdhfmfp.h @@ -13,5 +13,6 @@ #include "common.h" int CmdHFMFP(const char *Cmd); +int CmdHFMFPNDEFRead(const char *Cmd); #endif diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 56f1c53f2..171e7c477 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -20,7 +20,7 @@ #include "fileutils.h" #include "protocols.h" #include "generator.h" -#include "mifare/ndef.h" +#include "nfc/ndef.h" #include "cliparser.h" #include "cmdmain.h" #include "amiibo.h" // amiiboo fcts @@ -3765,7 +3765,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) { // 2. magic bytes in the readable payload -static int CmdHF14MfuNDEF(const char *Cmd) { +int CmdHF14MfuNDEFRead(const char *Cmd) { int keylen; int maxsize = 16, status; @@ -3779,10 +3779,10 @@ static int CmdHF14MfuNDEF(const char *Cmd) { uint8_t pack[4] = {0, 0, 0, 0}; CLIParserContext *ctx; - CLIParserInit(&ctx, "hf mfu ndef", + CLIParserInit(&ctx, "hf mfu ndefread", "Prints NFC Data Exchange Format (NDEF)", - "hf mfu ndef -> shows NDEF data\n" - "hf mfu ndef -k ffffffff -> shows NDEF data with key"); + "hf mfu ndefread -> shows NDEF data\n" + "hf mfu ndefread -k ffffffff -> shows NDEF data with key"); void *argtable[] = { arg_param_begin, @@ -4014,7 +4014,7 @@ static command_t CommandTable[] = { {"cauth", CmdHF14AMfUCAuth, IfPm3Iso14443a, "Authentication - Ultralight-C"}, {"dump", CmdHF14AMfUDump, IfPm3Iso14443a, "Dump MIFARE Ultralight family tag to binary file"}, {"info", CmdHF14AMfUInfo, IfPm3Iso14443a, "Tag information"}, - {"ndef", CmdHF14MfuNDEF, IfPm3Iso14443a, "Prints NDEF records from card"}, + {"ndefread",CmdHF14MfuNDEFRead, IfPm3Iso14443a, "Prints NDEF records from card"}, {"rdbl", CmdHF14AMfURdBl, IfPm3Iso14443a, "Read block"}, {"restore", CmdHF14AMfURestore, IfPm3Iso14443a, "Restore a dump onto a MFU MAGIC tag"}, {"wrbl", CmdHF14AMfUWrBl, IfPm3Iso14443a, "Write block"}, diff --git a/client/src/cmdhfmfu.h b/client/src/cmdhfmfu.h index 7b120115c..c4ac2f815 100644 --- a/client/src/cmdhfmfu.h +++ b/client/src/cmdhfmfu.h @@ -26,6 +26,7 @@ void printMFUdumpEx(mfu_dump_t *card, uint16_t pages, uint8_t startpage); int ul_read_uid(uint8_t *uid); int CmdHFMFUltra(const char *Cmd); +int CmdHF14MfuNDEFRead(const char *Cmd); uint16_t ul_ev1_packgen_VCNEW(uint8_t *uid, uint32_t pwd); uint32_t ul_ev1_otpgenA(uint8_t *uid); diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 80bfd6beb..c5395ba0e 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -38,7 +38,7 @@ static int seos_select(void) { uint8_t response[PM3_CMD_DATA_SIZE]; int resplen = 0; - // --------------- Select NDEF Tag application ---------------- + // --------------- Select SEOS applet ---------------- uint8_t aSELECT_AID[80]; int aSELECT_AID_n = 0; param_gethex_to_eol("00a404000aa000000440000101000100", 0, aSELECT_AID, sizeof(aSELECT_AID), &aSELECT_AID_n); diff --git a/client/src/cmdhfst.c b/client/src/cmdhfst.c index ad768598e..9cb241882 100644 --- a/client/src/cmdhfst.c +++ b/client/src/cmdhfst.c @@ -19,7 +19,7 @@ #include "cmdhf14a.h" #include "protocols.h" // definitions of ISO14A/7816 protocol #include "emv/apduinfo.h" // GetAPDUCodeDescription -#include "mifare/ndef.h" // NDEFRecordsDecodeAndPrint +#include "nfc/ndef.h" // NDEFRecordsDecodeAndPrint #define TIMEOUT 2000 @@ -203,7 +203,7 @@ static uint16_t get_sw(uint8_t *d, uint8_t n) { } // ST rothult -int infoHFST(void) { +static int infoHFST(void) { bool activate_field = true; bool keep_field_on = true; @@ -361,15 +361,15 @@ static int CmdHFSTSim(const char *Cmd) { return CmdHF14ASim(param); } -static int CmdHFSTNdef(const char *Cmd) { +int CmdHFSTNdefRead(const char *Cmd) { int pwdlen = 0; uint8_t pwd[16] = {0}; bool with_pwd = false; CLIParserContext *ctx; - CLIParserInit(&ctx, "hf st ndef", + CLIParserInit(&ctx, "hf st ndefread", "Read NFC Data Exchange Format (NDEF) file on ST25TA", - "hf st ndef -p 82E80053D4CA5C0B656D852CC696C8A1\n"); + "hf st ndefread -p 82E80053D4CA5C0B656D852CC696C8A1\n"); void *argtable[] = { arg_param_begin, @@ -795,7 +795,7 @@ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"info", CmdHFSTInfo, IfPm3Iso14443a, "Tag information"}, {"list", CmdHFSTList, AlwaysAvailable, "List ISO 14443A/7816 history"}, - {"ndef", CmdHFSTNdef, AlwaysAvailable, "read NDEF file on tag"}, + {"ndefread",CmdHFSTNdefRead, AlwaysAvailable, "read NDEF file on tag"}, {"protect", CmdHFSTProtect, IfPm3Iso14443a, "change protection on tag"}, {"pwd", CmdHFSTPwd, IfPm3Iso14443a, "change password on tag"}, {"sim", CmdHFSTSim, IfPm3Iso14443a, "Fake ISO 14443A/ST tag"}, diff --git a/client/src/cmdhfst.h b/client/src/cmdhfst.h index cd73fffd0..2bc1277dc 100644 --- a/client/src/cmdhfst.h +++ b/client/src/cmdhfst.h @@ -14,6 +14,6 @@ #include "common.h" int CmdHFST(const char *Cmd); +int CmdHFSTNdefRead(const char *Cmd); -int infoHFST(void); #endif diff --git a/client/src/cmdhfthinfilm.c b/client/src/cmdhfthinfilm.c index 20fe64d84..0630fe620 100644 --- a/client/src/cmdhfthinfilm.c +++ b/client/src/cmdhfthinfilm.c @@ -96,7 +96,7 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len, bool verbos return PM3_SUCCESS; } -static int CmdHfThinFilmInfo(const char *Cmd) { +int CmdHfThinFilmInfo(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf thinfilm info", "Get info from Thinfilm tags", @@ -138,7 +138,7 @@ int infoThinFilm(bool verbose) { return resp.status; } -static int CmdHfThinFilmSim(const char *Cmd) { +int CmdHfThinFilmSim(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf thinfilm sim", "Simulate Thinfilm tag", diff --git a/client/src/cmdhfthinfilm.h b/client/src/cmdhfthinfilm.h index ce7534759..48130f962 100644 --- a/client/src/cmdhfthinfilm.h +++ b/client/src/cmdhfthinfilm.h @@ -16,5 +16,7 @@ int infoThinFilm(bool verbose); int CmdHFThinfilm(const char *Cmd); +int CmdHfThinFilmInfo(const char *Cmd); +int CmdHfThinFilmSim(const char *Cmd); #endif diff --git a/client/src/cmdhftopaz.c b/client/src/cmdhftopaz.c index 608f2f589..4f986c212 100644 --- a/client/src/cmdhftopaz.c +++ b/client/src/cmdhftopaz.c @@ -22,7 +22,7 @@ #include "ui.h" #include "crc16.h" #include "protocols.h" -#include "mifare/ndef.h" +#include "nfc/ndef.h" #define TOPAZ_STATIC_MEMORY (0x0f * 8) // 15 blocks with 8 Bytes each @@ -412,7 +412,7 @@ static int CmdHFTopazReader(const char *Cmd) { } // read a Topaz tag and print some useful information -static int CmdHFTopazInfo(const char *Cmd) { +int CmdHFTopazInfo(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf topaz info", "Get info from Topaz tags", diff --git a/client/src/cmdhftopaz.h b/client/src/cmdhftopaz.h index c1802b583..c76d1a366 100644 --- a/client/src/cmdhftopaz.h +++ b/client/src/cmdhftopaz.h @@ -14,6 +14,7 @@ #include "common.h" int CmdHFTopaz(const char *Cmd); +int CmdHFTopazInfo(const char *Cmd); int readTopazUid(bool verbose); #endif diff --git a/client/src/cmdmain.c b/client/src/cmdmain.c index b31b14836..f291b6dfb 100644 --- a/client/src/cmdmain.c +++ b/client/src/cmdmain.c @@ -25,6 +25,7 @@ #include "cmddata.h" #include "cmdhw.h" #include "cmdlf.h" +#include "cmdnfc.h" #include "cmdtrace.h" #include "cmdscript.h" #include "cmdcrc.h" @@ -315,6 +316,7 @@ static command_t CommandTable[] = { {"hw", CmdHW, AlwaysAvailable, "{ Hardware commands... }"}, {"lf", CmdLF, AlwaysAvailable, "{ Low frequency commands... }"}, {"mem", CmdFlashMem, IfPm3Flash, "{ Flash memory manipulation... }"}, + {"nfc", CmdNFC, AlwaysAvailable, "{ NFC commands... }"}, {"reveng", CmdRev, AlwaysAvailable, "{ CRC calculations from RevEng software... }"}, {"smart", CmdSmartcard, AlwaysAvailable, "{ Smart card ISO-7816 commands... }"}, {"script", CmdScript, AlwaysAvailable, "{ Scripting commands... }"}, diff --git a/client/src/cmdnfc.c b/client/src/cmdnfc.c new file mode 100644 index 000000000..ba854cf4e --- /dev/null +++ b/client/src/cmdnfc.c @@ -0,0 +1,330 @@ +//----------------------------------------------------------------------------- +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// NFC commands +//----------------------------------------------------------------------------- +#include "cmdnfc.h" +#include "nfc/ndef.h" +#include "cliparser.h" +#include "ui.h" +#include "cmdparser.h" +#include "cmdhf14a.h" +#include "cmdhf14b.h" +#include "cmdhfmf.h" +#include "cmdhfmfp.h" +#include "cmdhfmfu.h" +#include "cmdhfst.h" +#include "cmdhfthinfilm.h" +#include "cmdhftopaz.h" + +static int CmdNfcDecode(const char *Cmd) { + +#ifndef MAX_NDEF_LEN +#define MAX_NDEF_LEN 2048 +#endif + + CLIParserContext *ctx; + CLIParserInit(&ctx, "nfc decode", + "Decode and print NFC Data Exchange Format (NDEF)", + "nfc decode -d 9101085402656e48656c6c6f5101085402656e576f726c64\n" + "nfc decode -d 0103d020240203e02c040300fe\n" + ); + + void *argtable[] = { + arg_param_begin, + arg_strx0("d", "data", "", "NDEF data to decode"), + arg_lit0("v", "verbose", "verbose mode"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, false); + + int datalen = 0; + uint8_t data[MAX_NDEF_LEN] = {0}; + CLIGetHexWithReturn(ctx, 1, data, &datalen); + bool verbose = arg_get_lit(ctx, 2); + + CLIParserFree(ctx); + if (datalen == 0) + return PM3_EINVARG; + + int res = NDEFDecodeAndPrint(data, datalen, verbose); + if (res != PM3_SUCCESS) { + PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header"); + res = NDEFRecordsDecodeAndPrint(data, datalen); + } + return res; +} + +static int CmdNFCType1Read(const char *Cmd) { + return CmdHFTopazInfo(Cmd); +} + +static int CmdNFCType1Help(const char *Cmd); + +static command_t CommandNFCType1Table[] = { + + {"--------", CmdNFCType1Help, AlwaysAvailable, "-------------- " _CYAN_("NFC Forum Tag Type 1") " ---------------"}, + {"read", CmdNFCType1Read, IfPm3Iso14443a, "read NFC Forum Tag Type 1"}, +// {"write", CmdNFCType1Write, IfPm3Iso14443a, "write NFC Forum Tag Type 1"}, + {"--------", CmdNFCType1Help, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCType1Help, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCType1(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandNFCType1Table, Cmd); +} + +static int CmdNFCType1Help(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandNFCType1Table); + return PM3_SUCCESS; +} + +static int CmdNFCType2Read(const char *Cmd) { + return CmdHF14MfuNDEFRead(Cmd); +} + +static int CmdNFCType2Help(const char *Cmd); + +static command_t CommandNFCType2Table[] = { + + {"--------", CmdNFCType2Help, AlwaysAvailable, "-------------- " _CYAN_("NFC Forum Tag Type 2") " ---------------"}, + {"read", CmdNFCType2Read, IfPm3Iso14443a, "read NFC Forum Tag Type 2"}, +// {"write", CmdNFCType2Write, IfPm3Iso14443a, "write NFC Forum Tag Type 2"}, + {"--------", CmdNFCType2Help, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCType2Help, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCType2(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandNFCType2Table, Cmd); +} + +static int CmdNFCType2Help(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandNFCType2Table); + return PM3_SUCCESS; +} + +/* +static int CmdNFCType3Read(const char *Cmd) { + return CmdHFFelicaXXX(Cmd); +} + +static int CmdNFCType3Help(const char *Cmd); + +static command_t CommandNFCType3Table[] = { + + {"--------", CmdNFCType3Help, AlwaysAvailable, "-------------- " _CYAN_("NFC Forum Tag Type 3") " ---------------"}, + {"read", CmdNFCType3Read, IfPm3Felica, "read NFC Forum Tag Type 3"}, + {"write", CmdNFCType3Write, IfPm3Felica, "write NFC Forum Tag Type 3"}, + {"--------", CmdNFCType3Help, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCType3Help, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCType3(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandNFCType3Table, Cmd); +} + +static int CmdNFCType3Help(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandNFCType3Table); + return PM3_SUCCESS; +} +*/ + +static int CmdNFCType4ARead(const char *Cmd) { + return CmdHF14ANdefRead(Cmd); +} + +static int CmdNFCST25TARead(const char *Cmd) { + return CmdHFSTNdefRead(Cmd); +} + +static int CmdNFCType4AHelp(const char *Cmd); + +static command_t CommandNFCType4ATable[] = { + + {"--------", CmdNFCType4AHelp, AlwaysAvailable, "--------- " _CYAN_("NFC Forum Tag Type 4 ISO14443A") " ----------"}, + {"read", CmdNFCType4ARead, IfPm3Iso14443a, "read NFC Forum Tag Type 4 A"}, +// {"write", CmdNFCType4AWrite, IfPm3Iso14443a, "write NFC Forum Tag Type 4 A"}, +// {"mfdesread", CmdNFCMFDESRead, IfPm3Iso14443a, "read NDEF from MIFARE DESfire"}, // hf mfdes ndefread +// {"mfdesformat", CmdNFCMFDESFormat, IfPm3Iso14443a, "format MIFARE DESfire as NFC Forum Tag Type 4"}, + {"st25taread", CmdNFCST25TARead, IfPm3Iso14443a, "read ST25TA as NFC Forum Tag Type 4"}, + + {"--------", CmdNFCType4AHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCType4AHelp, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCType4A(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandNFCType4ATable, Cmd); +} + +static int CmdNFCType4AHelp(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandNFCType4ATable); + return PM3_SUCCESS; +} + +static int CmdNFCType4BRead(const char *Cmd) { + return CmdHF14BNdefRead(Cmd); +} + +static int CmdNFCType4BHelp(const char *Cmd); + +static command_t CommandNFCType4BTable[] = { + + {"--------", CmdNFCType4BHelp, AlwaysAvailable, "--------- " _CYAN_("NFC Forum Tag Type 4 ISO14443B") " -------------"}, + {"read", CmdNFCType4BRead, IfPm3Iso14443b, "read NFC Forum Tag Type 4 B"}, +// {"write", CmdNFCType4BWrite, IfPm3Iso14443b, "write NFC Forum Tag Type 4 B"}, + {"--------", CmdNFCType4BHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCType4BHelp, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCType4B(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandNFCType4BTable, Cmd); +} + +static int CmdNFCType4BHelp(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandNFCType4BTable); + return PM3_SUCCESS; +} + +/* +static int CmdNFCType5Read(const char *Cmd) { + return CmdHF15XXX(Cmd); +} + +static int CmdNFCType5Help(const char *Cmd); + +static command_t CommandNFCType5Table[] = { + + {"--------", CmdNFCType5Help, AlwaysAvailable, "-------------- " _CYAN_("NFC Forum Tag Type 5") " ---------------"}, + {"read", CmdNFCType5Read, IfPm3Iso15693, "read NFC Forum Tag Type 5"}, + {"write", CmdNFCType5Write, IfPm3Iso15693, "write NFC Forum Tag Type 5"}, + {"--------", CmdNFCType5Help, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCType5Help, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCType5(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandNFCType5Table, Cmd); +} + +static int CmdNFCType5Help(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandNFCType5Table); + return PM3_SUCCESS; +} +*/ + +static int CmdNFCMFCRead(const char *Cmd) { + return CmdHFMFNDEFRead(Cmd); +} + +static int CmdNFCMFPRead(const char *Cmd) { + return CmdHFMFPNDEFRead(Cmd); +} + +static int CmdNFCMFHelp(const char *Cmd); + +static command_t CommandMFTable[] = { + + {"--------", CmdNFCMFHelp, AlwaysAvailable, "--------- " _CYAN_("NFC Type MIFARE Classic/Plus Tag") " --------"}, + {"cread", CmdNFCMFCRead, IfPm3Iso14443a, "read NFC Type MIFARE Classic Tag"}, +// {"cwrite", CmdNFCMFCWrite, IfPm3Iso14443a, "write NFC Type MIFARE Classic Tag"}, +// {"cformat", CmdNFCMFCFormat, IfPm3Iso14443a, "format MIFARE Classic Tag as NFC Tag"}, + {"pread", CmdNFCMFPRead, IfPm3Iso14443a, "read NFC Type MIFARE Plus Tag"}, + {"--------", CmdNFCMFHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCMFHelp, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCMF(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandMFTable, Cmd); +} + +static int CmdNFCMFHelp(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandMFTable); + return PM3_SUCCESS; +} + +static int CmdNFCBarcodeRead(const char *Cmd) { + return CmdHfThinFilmInfo(Cmd); +} + +static int CmdNFCBarcodeSim(const char *Cmd) { + return CmdHfThinFilmSim(Cmd); +} + +static int CmdNFCBarcodeHelp(const char *Cmd); + +static command_t CommandBarcodeTable[] = { + + {"--------", CmdNFCBarcodeHelp, AlwaysAvailable, "------------------ " _CYAN_("NFC Barcode") " --------------------"}, + {"read", CmdNFCBarcodeRead, IfPm3Iso14443a, "read NFC Barcode"}, + {"sim", CmdNFCBarcodeSim, IfPm3Iso14443a, "simulate NFC Barcode"}, + {"--------", CmdNFCBarcodeHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdNFCBarcodeHelp, AlwaysAvailable, "This help"}, + {NULL, NULL, NULL, NULL} +}; + +static int CmdNFCBarcode(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandBarcodeTable, Cmd); +} + +static int CmdNFCBarcodeHelp(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandBarcodeTable); + return PM3_SUCCESS; +} + +static int CmdHelp(const char *Cmd); + +static command_t CommandTable[] = { + + {"--------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("NFC Tags") " --------------------"}, + {"type1", CmdNFCType1, AlwaysAvailable, "{ NFC Forum Tag Type 1... }"}, + {"type2", CmdNFCType2, AlwaysAvailable, "{ NFC Forum Tag Type 2... }"}, +// {"type3", CmdNFCType3, AlwaysAvailable, "{ NFC Forum Tag Type 3... }"}, + {"type4a", CmdNFCType4A, AlwaysAvailable, "{ NFC Forum Tag Type 4 ISO14443A... }"}, + {"type4b", CmdNFCType4B, AlwaysAvailable, "{ NFC Forum Tag Type 4 ISO14443B... }"}, +// {"type5", CmdNFCType5, AlwaysAvailable, "{ NFC Forum Tag Type 5... }"}, + {"mf", CmdNFCMF, AlwaysAvailable, "{ NFC Type MIFARE Classic/Plus Tag... }"}, + {"barcode", CmdNFCBarcode, AlwaysAvailable, "{ NFC Barcode Tag... }"}, +// {"--------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("NFC peer-to-peer") " ------------"}, +// {"isodep", CmdISODEP, AlwaysAvailable, "{ ISO-DEP protocol... }"}, +// {"llcp", CmdNFCLLCP, AlwaysAvailable, "{ Logical Link Control Protocol... }"}, +// {"snep", CmdNFCSNEP, AlwaysAvailable, "{ Simple NDEF Exchange Protocol... }"}, + {"--------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdHelp, AlwaysAvailable, "This help"}, + {"decode", CmdNfcDecode, AlwaysAvailable, "Decode NDEF records"}, + {NULL, NULL, NULL, NULL} +}; + +int CmdNFC(const char *Cmd) { + clearCommandBuffer(); + return CmdsParse(CommandTable, Cmd); +} + +int CmdHelp(const char *Cmd) { + (void)Cmd; // Cmd is not used so far + CmdsHelp(CommandTable); + return PM3_SUCCESS; +} diff --git a/client/src/cmdnfc.h b/client/src/cmdnfc.h new file mode 100644 index 000000000..1064dbe56 --- /dev/null +++ b/client/src/cmdnfc.h @@ -0,0 +1,16 @@ +//----------------------------------------------------------------------------- +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// NFC commands +//----------------------------------------------------------------------------- + +#ifndef CMDNFC_H__ +#define CMDNFC_H__ + +#include "common.h" + +int CmdNFC(const char *Cmd); + +#endif diff --git a/client/src/mifare/ndef.c b/client/src/nfc/ndef.c similarity index 100% rename from client/src/mifare/ndef.c rename to client/src/nfc/ndef.c diff --git a/client/src/mifare/ndef.h b/client/src/nfc/ndef.h similarity index 100% rename from client/src/mifare/ndef.h rename to client/src/nfc/ndef.h diff --git a/client/src/scripting.c b/client/src/scripting.c index e64276767..37769bffe 100644 --- a/client/src/scripting.c +++ b/client/src/scripting.c @@ -27,7 +27,7 @@ #include "cmdhfmfhard.h" #include "cmdhfmfu.h" #include "cmdlft55xx.h" // read t55xx etc -#include "mifare/ndef.h" // ndef parsing +#include "nfc/ndef.h" // ndef parsing #include "commonutil.h" #include "ui.h" diff --git a/doc/jooki_notes.md b/doc/jooki_notes.md index 1e1cd5552..418a2bc38 100644 --- a/doc/jooki_notes.md +++ b/doc/jooki_notes.md @@ -78,7 +78,7 @@ or use the base64 encoded parameter to clone: `hf jooki clone -b A5wlbrkq6QoKh9w1 -Note: Jooki doesn't like more than one NDEF record, so make sure you just have one. Check with `hf mfu ndef` +Note: Jooki doesn't like more than one NDEF record, so make sure you just have one. Check with `hf mfu ndefread` ### List of known figurine types `Value`|`Figurine Type`|