added function 4x50_watch

This commit is contained in:
tharexde 2020-10-05 22:59:08 +02:00
commit 68db54028c
7 changed files with 100 additions and 0 deletions

View file

@ -1049,6 +1049,10 @@ static void PacketReceived(PacketCommandNG *packet) {
em4x50_reset(); em4x50_reset();
break; break;
} }
case CMD_LF_EM4X50_WATCH: {
em4x50_watch();
break;
}
#endif #endif
#ifdef WITH_ISO15693 #ifdef WITH_ISO15693

View file

@ -1403,3 +1403,48 @@ int em4x50_standalone_read(uint64_t *words) {
return now; 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);
}

View file

@ -31,5 +31,6 @@ void em4x50_wipe(em4x50_data_t *etd);
void em4x50_brute(em4x50_data_t *etd); void em4x50_brute(em4x50_data_t *etd);
void em4x50_login(em4x50_data_t *etd); void em4x50_login(em4x50_data_t *etd);
void em4x50_reset(void); void em4x50_reset(void);
void em4x50_watch(void);
#endif /* EM4X50_H */ #endif /* EM4X50_H */

View file

@ -1425,6 +1425,7 @@ static command_t CommandTable[] = {
{"4x50_brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"}, {"4x50_brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"},
{"4x50_login", CmdEM4x50Login, IfPm3EM4x50, "login into EM4x50"}, {"4x50_login", CmdEM4x50Login, IfPm3EM4x50, "login into EM4x50"},
{"4x50_reset", CmdEM4x50Reset, IfPm3EM4x50, "reset EM4x50"}, {"4x50_reset", CmdEM4x50Reset, IfPm3EM4x50, "reset EM4x50"},
{"4x50_watch", CmdEM4x50Watch, IfPm3EM4x50, "read EM4x50 continously"},
{NULL, NULL, NULL, NULL} {NULL, NULL, NULL, NULL}
}; };

View file

@ -133,6 +133,17 @@ static int usage_lf_em4x50_reset(void) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS; 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) { 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; 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;
}

View file

@ -27,5 +27,6 @@ int CmdEM4x50Wipe(const char *Cmd);
int CmdEM4x50Brute(const char *Cmd); int CmdEM4x50Brute(const char *Cmd);
int CmdEM4x50Login(const char *Cmd); int CmdEM4x50Login(const char *Cmd);
int CmdEM4x50Reset(const char *Cmd); int CmdEM4x50Reset(const char *Cmd);
int CmdEM4x50Watch(const char *Cmd);
#endif #endif

View file

@ -496,6 +496,7 @@ typedef struct {
#define CMD_LF_EM4X50_BRUTE 0x0245 #define CMD_LF_EM4X50_BRUTE 0x0245
#define CMD_LF_EM4X50_LOGIN 0x0246 #define CMD_LF_EM4X50_LOGIN 0x0246
#define CMD_LF_EM4X50_RESET 0x0247 #define CMD_LF_EM4X50_RESET 0x0247
#define CMD_LF_EM4X50_WATCH 0x0248
// Sampling configuration for LF reader/sniffer // Sampling configuration for LF reader/sniffer
#define CMD_LF_SAMPLING_SET_CONFIG 0x021D #define CMD_LF_SAMPLING_SET_CONFIG 0x021D
#define CMD_LF_FSK_SIMULATE 0x021E #define CMD_LF_FSK_SIMULATE 0x021E