added function reset

This commit is contained in:
tharexde
2020-09-27 23:39:04 +02:00
parent a308fc692b
commit c20ab4ca20
7 changed files with 101 additions and 29 deletions

View File

@@ -1400,6 +1400,7 @@ static command_t CommandTable[] = {
{"4x50_wipe", CmdEM4x50Wipe, IfPm3EM4x50, "wipe data from EM4x50"},
{"4x50_brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"},
{"4x50_login", CmdEM4x50Login, IfPm3EM4x50, "login into EM4x50"},
{"4x50_reset", CmdEM4x50Reset, IfPm3EM4x50, "reset EM4x50"},
{NULL, NULL, NULL, NULL}
};

View File

@@ -122,6 +122,17 @@ static int usage_lf_em4x50_login(void) {
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}
static int usage_lf_em4x50_reset(void) {
PrintAndLogEx(NORMAL, "Reset EM4x50 tag. Tag must be on antenna. ");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_reset [h]");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h - this help");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_reset"));
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}
static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t *words) {
@@ -869,3 +880,38 @@ int CmdEM4x50Login(const char *Cmd) {
return PM3_SUCCESS;
}
int CmdEM4x50Reset(const char *Cmd) {
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_reset();
default:
PrintAndLogEx(WARNING, "\n Unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
errors = true;
break;
}
}
if (errors)
return usage_lf_em4x50_reset();
// start
clearCommandBuffer();
SendCommandNG(CMD_LF_EM4X50_RESET, 0, 0);
WaitForResponse(CMD_ACK, &resp);
// print response
if ((bool)resp.status)
PrintAndLogEx(NORMAL, "\nreset " _GREEN_("ok") "\n");
else
PrintAndLogEx(NORMAL, "\nreset " _RED_("failed") "\n");
return PM3_SUCCESS;
}

View File

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