use DEFINES

This commit is contained in:
iceman1001 2020-01-17 14:25:07 +01:00
parent 655345e109
commit d451631b13

View file

@ -35,7 +35,7 @@ static int usage_hitag_sniff(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag sniff");
return 0;
return PM3_SUCCESS;
}
static int usage_hitag_sim(void) {
PrintAndLogEx(NORMAL, "Simulate " _YELLOW_("Hitag2 / HitagS")" transponder");
@ -49,7 +49,7 @@ static int usage_hitag_sim(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag sim 2 b lf-hitag-dump");
return 0;
return PM3_SUCCESS;
}
static int usage_hitag_info(void) {
PrintAndLogEx(NORMAL, "Usage: lf hitag info [h] p <pwd>");
@ -58,7 +58,7 @@ static int usage_hitag_info(void) {
PrintAndLogEx(NORMAL, " p <pwd> password");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag info");
return 0;
return PM3_SUCCESS;
}
/*
static int usage_hitag_dump(void) {
@ -71,7 +71,7 @@ static int usage_hitag_dump(void) {
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag dump f mydump");
PrintAndLogEx(NORMAL, " lf hitag dump p 4D494B52 f mydump");
return 0;
return PM3_SUCCESS;
}
*/
static int usage_hitag_reader(void) {
@ -90,7 +90,7 @@ static int usage_hitag_reader(void) {
PrintAndLogEx(NORMAL, " 23 <key> Read all pages, crypto mode. Key format: ISK high + ISK low. Default: 4F4E4D494B52 (\"ONMIKR\")");
PrintAndLogEx(NORMAL, " 25 Test recorded authentications");
PrintAndLogEx(NORMAL, " 26 Just read UID");
return 0;
return PM3_SUCCESS;
}
static int usage_hitag_writer(void) {
PrintAndLogEx(NORMAL, "Hitag writer functions");
@ -106,7 +106,7 @@ static int usage_hitag_writer(void) {
PrintAndLogEx(NORMAL, " 24 <key> <page> <byte0...byte3> Write page, crypto mode. Key format: ISK high + ISK low.");
PrintAndLogEx(NORMAL, " Default: 4F4E4D494B52 (\"ONMIKR\"). Set key=0 for no auth");
PrintAndLogEx(NORMAL, " 27 <password> <page> <byte0...byte3> Write page, password mode. Default: 4D494B52 (\"MIKR\")");
return 0;
return PM3_SUCCESS;
}
static int usage_hitag_checkchallenges(void) {
PrintAndLogEx(NORMAL, "Check challenges, load a file with save hitag crypto challenges and test them all.");
@ -119,19 +119,19 @@ static int usage_hitag_checkchallenges(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag cc f lf-hitag-challenges");
return 0;
return PM3_SUCCESS;
}
static int CmdLFHitagList(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdTraceList("hitag");
return 0;
return PM3_SUCCESS;
/*
uint8_t *got = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
if (!got) {
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
return 2;
return PM3_EMALLOC;
}
// Query for the actual size of the trace
@ -139,7 +139,7 @@ static int CmdLFHitagList(const char *Cmd) {
if (!GetFromDevice(BIG_BUF, got, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out");
free(got);
return 2;
return PM3_ETIMEOUT;
}
uint16_t traceLen = response.arg[2];
@ -148,13 +148,13 @@ static int CmdLFHitagList(const char *Cmd) {
if (p == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
free(got);
return 2;
return PM3_EMALLOC;
}
got = p;
if (!GetFromDevice(BIG_BUF, got, traceLen, 0, NULL, 0, NULL, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out");
free(got);
return 2;
return PM3_ETIMEOUT;
}
}
@ -251,7 +251,7 @@ static int CmdLFHitagList(const char *Cmd) {
}
free(got);
return 0;
return PM3_SUCCES;
*/
}
@ -262,7 +262,7 @@ static int CmdLFHitagSniff(const char *Cmd) {
clearCommandBuffer();
SendCommandNG(CMD_LF_HITAG_SNIFF, NULL, 0);
return 0;
return PM3_SUCCESS;
}
static int CmdLFHitagSim(const char *Cmd) {
@ -343,7 +343,7 @@ static int CmdLFHitagSim(const char *Cmd) {
}
free(data);
return 0;
return PM3_SUCCESS;
}
static void printHitagConfiguration(uint8_t config) {
@ -487,13 +487,11 @@ static int CmdLFHitagInfo(const char *Cmd) {
PrintAndLogEx(SUCCESS, "UID: " _YELLOW_("%08X"), uid);
return PM3_SUCCESS;
// how to detemine Hitag types?
// read block3, get configuration byte.
PrintAndLogEx(FAILED, _RED_("TODO: This is a hardcoded example!"));
// common configurations.
printHitagConfiguration(0x06);
// printHitagConfiguration(0x06);
//printHitagConfiguration( 0x0E );
//printHitagConfiguration( 0x02 );
//printHitagConfiguration( 0x00 );
@ -577,6 +575,8 @@ static int CmdLFHitagReader(const char *Cmd) {
fnameptr += sprintf(fnameptr, "lf-hitag-");
FillFileNameByUID(fnameptr, data, "-dump", 4);
saveFile(filename, ".bin", data, 48);
saveFileEML(filename, data, 48, 4);
saveFileJSON(filename, jsfHitag, data, 48);
@ -633,7 +633,7 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
SendCommandMIX(CMD_LF_HITAGS_TEST_TRACES, 0, 0, 0, NULL, 0);
free(data);
return 0;
return PM3_SUCCESS;
}
static int CmdLFHitagWriter(const char *Cmd) {
@ -677,14 +677,14 @@ static int CmdLFHitagWriter(const char *Cmd) {
PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return 1;
return PM3_ETIMEOUT;
}
if (resp.oldarg[0] == false) {
PrintAndLogEx(DEBUG, "DEBUG: Error - hitag write failed");
return 1;
return PM3_ESOFT;
}
return 0;
return PM3_SUCCESS;
}
/*
@ -694,7 +694,7 @@ static int CmdLFHitagDump(const char *Cmd) {
char ctmp = tolower(param_getchar(Cmd, 0));
if (ctmp == 'h') return usage_hitag_dump();
return 0;
return PM3_SUCCESS;
}
*/
@ -713,7 +713,7 @@ static command_t CommandTable[] = {
static int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable);
return 0;
return PM3_SUCCESS;
}
int CmdLFHitag(const char *Cmd) {