diff --git a/armsrc/appmain.c b/armsrc/appmain.c index ae1d112c1..bcf0a656f 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1049,6 +1049,10 @@ static void PacketReceived(PacketCommandNG *packet) { em4x50_reset(); break; } + case CMD_LF_EM4X50_WATCH: { + em4x50_watch(); + break; + } #endif #ifdef WITH_ISO15693 diff --git a/armsrc/em4x50.c b/armsrc/em4x50.c index 39b971411..158bfa4f6 100644 --- a/armsrc/em4x50.c +++ b/armsrc/em4x50.c @@ -1403,3 +1403,48 @@ int em4x50_standalone_read(uint64_t *words) { return now; } + +void em4x50_watch() { + + // reads continuously and displays standard reads of tag + + int now = 0; + + init_tag(); + em4x50_setup_read(); + + while (BUTTON_PRESS() == false) { + + WDT_HIT(); + init_tag(); + now = 0; + + if (get_signalproperties() && find_em4x50_tag()) { + + standard_read(&now); + + if (now > 0) { + + Dbprintf(""); + for (int i = 0; i < now; i++) { + + Dbprintf("EM4x50 TAG ID: " + _GREEN_("%02x%02x%02x%02x") " (msb) - " + _GREEN_("%02x%02x%02x%02x") " (lsb)", + tag.sectors[i][0], + tag.sectors[i][1], + tag.sectors[i][2], + tag.sectors[i][3], + reflect8(tag.sectors[i][3]), + reflect8(tag.sectors[i][2]), + reflect8(tag.sectors[i][1]), + reflect8(tag.sectors[i][0])); + } + } + } + } + + LOW(GPIO_SSC_DOUT); + lf_finalize(); + reply_ng(CMD_ACK, 1, 0, 0); +} diff --git a/armsrc/em4x50.h b/armsrc/em4x50.h index 401e846cd..8c86cfb26 100644 --- a/armsrc/em4x50.h +++ b/armsrc/em4x50.h @@ -31,5 +31,6 @@ void em4x50_wipe(em4x50_data_t *etd); void em4x50_brute(em4x50_data_t *etd); void em4x50_login(em4x50_data_t *etd); void em4x50_reset(void); +void em4x50_watch(void); #endif /* EM4X50_H */ diff --git a/client/src/cmdlfem4x.c b/client/src/cmdlfem4x.c index 291027754..1b0915241 100644 --- a/client/src/cmdlfem4x.c +++ b/client/src/cmdlfem4x.c @@ -1425,6 +1425,7 @@ static command_t CommandTable[] = { {"4x50_brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"}, {"4x50_login", CmdEM4x50Login, IfPm3EM4x50, "login into EM4x50"}, {"4x50_reset", CmdEM4x50Reset, IfPm3EM4x50, "reset EM4x50"}, + {"4x50_watch", CmdEM4x50Watch, IfPm3EM4x50, "read EM4x50 continously"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/src/cmdlfem4x50.c b/client/src/cmdlfem4x50.c index eeb04dc3a..fc6bbb7e6 100644 --- a/client/src/cmdlfem4x50.c +++ b/client/src/cmdlfem4x50.c @@ -133,6 +133,17 @@ static int usage_lf_em4x50_reset(void) { PrintAndLogEx(NORMAL, ""); return PM3_SUCCESS; } +static int usage_lf_em4x50_watch(void) { + PrintAndLogEx(NORMAL, "Watch for EM4x50 tag. Tag must be on antenna. "); + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, "Usage: lf em 4x50_watch [h]"); + PrintAndLogEx(NORMAL, "Options:"); + PrintAndLogEx(NORMAL, " h - this help"); + PrintAndLogEx(NORMAL, "Examples:"); + PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_watch")); + PrintAndLogEx(NORMAL, ""); + return PM3_SUCCESS; +} static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t *words) { @@ -917,3 +928,39 @@ int CmdEM4x50Reset(const char *Cmd) { return PM3_SUCCESS; } + +int CmdEM4x50Watch(const char *Cmd) { + + // continously envoke reading of a EM4x50 tag + + bool errors = false; + uint8_t cmdp = 0; + PacketResponseNG resp; + + while (param_getchar(Cmd, cmdp) != 0x00 && !errors) { + switch (tolower(param_getchar(Cmd, cmdp))) { + + case 'h': + return usage_lf_em4x50_watch(); + + default: + PrintAndLogEx(WARNING, " Unknown parameter '%c'", param_getchar(Cmd, cmdp)); + errors = true; + break; + } + } + + // validation + if (errors) + return usage_lf_em4x50_watch(); + + PrintAndLogEx(SUCCESS, "Watching for EM4x50 cards - place tag on antenna"); + + clearCommandBuffer(); + SendCommandNG(CMD_LF_EM4X50_WATCH, 0, 0); + WaitForResponse(CMD_ACK, &resp); + + PrintAndLogEx(INFO, "Done"); + + return PM3_SUCCESS; +} diff --git a/client/src/cmdlfem4x50.h b/client/src/cmdlfem4x50.h index 6462810d0..32685baaf 100644 --- a/client/src/cmdlfem4x50.h +++ b/client/src/cmdlfem4x50.h @@ -27,5 +27,6 @@ int CmdEM4x50Wipe(const char *Cmd); int CmdEM4x50Brute(const char *Cmd); int CmdEM4x50Login(const char *Cmd); int CmdEM4x50Reset(const char *Cmd); +int CmdEM4x50Watch(const char *Cmd); #endif diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 08207306c..786b3f8bb 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -496,6 +496,7 @@ typedef struct { #define CMD_LF_EM4X50_BRUTE 0x0245 #define CMD_LF_EM4X50_LOGIN 0x0246 #define CMD_LF_EM4X50_RESET 0x0247 +#define CMD_LF_EM4X50_WATCH 0x0248 // Sampling configuration for LF reader/sniffer #define CMD_LF_SAMPLING_SET_CONFIG 0x021D #define CMD_LF_FSK_SIMULATE 0x021E