added login function
This commit is contained in:
@@ -1399,6 +1399,7 @@ static command_t CommandTable[] = {
|
||||
{"4x50_read", CmdEM4x50Read, IfPm3EM4x50, "read word data from EM4x50"},
|
||||
{"4x50_wipe", CmdEM4x50Wipe, IfPm3EM4x50, "wipe data from EM4x50"},
|
||||
{"4x50_brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"},
|
||||
{"4x50_login", CmdEM4x50Login, IfPm3EM4x50, "login into EM4x50"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -97,31 +97,6 @@ static int usage_lf_em4x50_wipe(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_sim(void) {
|
||||
PrintAndLogEx(NORMAL, "Simulate EM4x50 tag. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_sim [h] w <word>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " w <word> - word (hex)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_sim w 12345678"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_test(void) {
|
||||
PrintAndLogEx(NORMAL, "Test functionality for EM4x50 tag. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_test [h] ...");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " c <0|1> - carrier on|off (optional)");
|
||||
PrintAndLogEx(NORMAL, " b <byte> - byte (hex) (optional)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_test ..."));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_brute(void) {
|
||||
PrintAndLogEx(NORMAL, "Guess password of EM4x50 tag. Tag must be on antenna. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -135,6 +110,18 @@ static int usage_lf_em4x50_brute(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_login(void) {
|
||||
PrintAndLogEx(NORMAL, "Login into EM4x50 tag. Tag must be on antenna. ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_login [h] p <pwd>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " p <pwd> - password (hex, lsb notation)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 4x50_login p 11200000"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void prepare_result(const uint8_t *byte, int fwr, int lwr, em4x50_word_t *words) {
|
||||
|
||||
@@ -841,3 +828,44 @@ int CmdEM4x50Brute(const char *Cmd) {
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdEM4x50Login(const char *Cmd) {
|
||||
|
||||
bool errors = false, pwd_given = false;
|
||||
uint8_t cmdp = 0;
|
||||
em4x50_data_t etd;
|
||||
PacketResponseNG resp;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_lf_em4x50_login();
|
||||
case 'p':
|
||||
etd.login_password = param_get32ex(Cmd, cmdp + 1, 0, 16);
|
||||
pwd_given = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "\n Unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (errors || !pwd_given)
|
||||
return usage_lf_em4x50_login();
|
||||
|
||||
// start
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM4X50_LOGIN, (uint8_t *)&etd, sizeof(etd));
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
// print response
|
||||
if ((bool)resp.status)
|
||||
PrintAndLogEx(NORMAL, "\nlogin " _GREEN_("ok") "\n");
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "\nlogin " _RED_("failed") "\n");
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -25,5 +25,6 @@ int CmdEM4x50Read(const char *Cmd);
|
||||
int CmdEM4x50Dump(const char *Cmd);
|
||||
int CmdEM4x50Wipe(const char *Cmd);
|
||||
int CmdEM4x50Brute(const char *Cmd);
|
||||
int CmdEM4x50Login(const char *Cmd);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user