mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
use PrintAndLogEx() instead of PrintAndLog()
This commit is contained in:
parent
740a1daaa4
commit
2cea36c3b5
1 changed files with 40 additions and 40 deletions
|
@ -33,7 +33,7 @@ size_t nbytes(size_t nbits) {
|
||||||
int CmdLFHitagList(const char *Cmd) {
|
int CmdLFHitagList(const char *Cmd) {
|
||||||
uint8_t *got = malloc(USB_CMD_DATA_SIZE);
|
uint8_t *got = malloc(USB_CMD_DATA_SIZE);
|
||||||
if ( !got ) {
|
if ( !got ) {
|
||||||
PrintAndLog("Cannot allocate memory for trace");
|
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ int CmdLFHitagList(const char *Cmd) {
|
||||||
if (traceLen > USB_CMD_DATA_SIZE) {
|
if (traceLen > USB_CMD_DATA_SIZE) {
|
||||||
uint8_t *p = realloc(got, traceLen);
|
uint8_t *p = realloc(got, traceLen);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
PrintAndLog("Cannot allocate memory for trace");
|
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
||||||
free(got);
|
free(got);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ int CmdLFHitagList(const char *Cmd) {
|
||||||
WaitForResponse(CMD_ACK,NULL);
|
WaitForResponse(CMD_ACK,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLog("recorded activity (TraceLen = %d bytes):");
|
PrintAndLogEx(NORMAL, "recorded activity (TraceLen = %d bytes):");
|
||||||
PrintAndLog(" ETU :nbits: who bytes");
|
PrintAndLogEx(NORMAL, " ETU :nbits: who bytes");
|
||||||
PrintAndLog("---------+-----+----+-----------");
|
PrintAndLogEx(NORMAL, "---------+-----+----+-----------");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int prev = -1;
|
int prev = -1;
|
||||||
|
@ -71,7 +71,7 @@ int CmdLFHitagList(const char *Cmd) {
|
||||||
if (strlen(filename) > 0) {
|
if (strlen(filename) > 0) {
|
||||||
f = fopen(filename,"wb");
|
f = fopen(filename,"wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PrintAndLog("Error: Could not open file [%s]",filename);
|
PrintAndLogEx(WARNING, "Error: Could not open file [%s]",filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ int CmdLFHitagList(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLog(" +%7d: %3d: %s %s",
|
PrintAndLogEx(NORMAL, " +%7d: %3d: %s %s",
|
||||||
(prev < 0 ? 0 : (timestamp - prev)),
|
(prev < 0 ? 0 : (timestamp - prev)),
|
||||||
bits,
|
bits,
|
||||||
(isResponse ? "TAG" : " "),
|
(isResponse ? "TAG" : " "),
|
||||||
|
@ -143,7 +143,7 @@ int CmdLFHitagList(const char *Cmd) {
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
PrintAndLog("Recorded activity succesfully written to file: %s", filename);
|
PrintAndLogEx(NORMAL, "Recorded activity succesfully written to file: %s", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(got);
|
free(got);
|
||||||
|
@ -171,13 +171,13 @@ int CmdLFHitagSim(const char *Cmd) {
|
||||||
if (strlen(filename) > 0) {
|
if (strlen(filename) > 0) {
|
||||||
f = fopen(filename,"rb+");
|
f = fopen(filename,"rb+");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PrintAndLog("Error: Could not open file [%s]",filename);
|
PrintAndLogEx(WARNING, "Error: Could not open file [%s]",filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
tag_mem_supplied = true;
|
tag_mem_supplied = true;
|
||||||
size_t bytes_read = fread(c.d.asBytes, 48, 1, f);
|
size_t bytes_read = fread(c.d.asBytes, 48, 1, f);
|
||||||
if ( bytes_read == 0) {
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("Error: File reading error");
|
PrintAndLogEx(WARNING, "Error: File reading error");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -226,20 +226,20 @@ int CmdLFHitagReader(const char *Cmd) {
|
||||||
// No additional parameters needed
|
// No additional parameters needed
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
PrintAndLog("\nError: unkown reader function %d", htf);
|
PrintAndLogEx(NORMAL, "\nError: unkown reader function %d", htf);
|
||||||
PrintAndLog("");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLog("Usage: hitag reader <Reader Function #>");
|
PrintAndLogEx(NORMAL, "Usage: hitag reader <Reader Function #>");
|
||||||
PrintAndLog("Reader Functions:");
|
PrintAndLogEx(NORMAL, "Reader Functions:");
|
||||||
PrintAndLog(" HitagS (0*)");
|
PrintAndLogEx(NORMAL, " HitagS (0*)");
|
||||||
PrintAndLog(" 01 <nr> <ar> (Challenge) read all pages from a Hitag S tag");
|
PrintAndLogEx(NORMAL, " 01 <nr> <ar> (Challenge) read all pages from a Hitag S tag");
|
||||||
PrintAndLog(" 02 <key> (set to 0 if no authentication is needed) read all pages from a Hitag S tag");
|
PrintAndLogEx(NORMAL, " 02 <key> (set to 0 if no authentication is needed) read all pages from a Hitag S tag");
|
||||||
PrintAndLog(" Hitag1 (1*)");
|
PrintAndLogEx(NORMAL, " Hitag1 (1*)");
|
||||||
PrintAndLog(" Hitag2 (2*)");
|
PrintAndLogEx(NORMAL, " Hitag2 (2*)");
|
||||||
PrintAndLog(" 21 <password> (password mode)");
|
PrintAndLogEx(NORMAL, " 21 <password> (password mode)");
|
||||||
PrintAndLog(" 22 <nr> <ar> (authentication)");
|
PrintAndLogEx(NORMAL, " 22 <nr> <ar> (authentication)");
|
||||||
PrintAndLog(" 23 <key> (authentication) key is in format: ISK high + ISK low");
|
PrintAndLogEx(NORMAL, " 23 <key> (authentication) key is in format: ISK high + ISK low");
|
||||||
PrintAndLog(" 25 (test recorded authentications)");
|
PrintAndLogEx(NORMAL, " 25 (test recorded authentications)");
|
||||||
PrintAndLog(" 26 just read UID");
|
PrintAndLogEx(NORMAL, " 26 just read UID");
|
||||||
return 1;
|
return 1;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -250,34 +250,34 @@ int CmdLFHitagReader(const char *Cmd) {
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
if ( !WaitForResponseTimeout(CMD_ACK, &resp, 4000) ) {
|
if ( !WaitForResponseTimeout(CMD_ACK, &resp, 4000) ) {
|
||||||
PrintAndLog("timeout while waiting for reply.");
|
PrintAndLogEx(NORMAL, "timeout while waiting for reply.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the return status, stored in the first argument
|
// Check the return status, stored in the first argument
|
||||||
if (resp.arg[0] == false) {
|
if (resp.arg[0] == false) {
|
||||||
if (g_debugMode) PrintAndLog("DEBUG: Error - hitag failed");
|
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t id = bytes_to_num(resp.d.asBytes, 4);
|
uint32_t id = bytes_to_num(resp.d.asBytes, 4);
|
||||||
|
|
||||||
if (htf == RHT2F_UID_ONLY){
|
if (htf == RHT2F_UID_ONLY){
|
||||||
PrintAndLog("Valid Hitag2 tag found - UID: %08x", id);
|
PrintAndLogEx(NORMAL, "Valid Hitag2 tag found - UID: %08x", id);
|
||||||
} else {
|
} else {
|
||||||
char filename[FILE_PATH_SIZE];
|
char filename[FILE_PATH_SIZE];
|
||||||
FILE* f = NULL;
|
FILE* f = NULL;
|
||||||
sprintf(filename, "%08x_%04x.ht2", id, (rand() & 0xffff));
|
sprintf(filename, "%08x_%04x.ht2", id, (rand() & 0xffff));
|
||||||
f = fopen(filename, "wb");
|
f = fopen(filename, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PrintAndLog("Error: Could not open file [%s]", filename);
|
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the 48 tag memory bytes to file and finalize
|
// Write the 48 tag memory bytes to file and finalize
|
||||||
fwrite(resp.d.asBytes, 1, 48, f);
|
fwrite(resp.d.asBytes, 1, 48, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
PrintAndLog("Succesfully saved tag memory to [%s]", filename);
|
PrintAndLogEx(NORMAL, "Succesfully saved tag memory to [%s]", filename);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -295,13 +295,13 @@ int CmdLFHitagSimS(const char *Cmd) {
|
||||||
if (strlen(filename) > 0) {
|
if (strlen(filename) > 0) {
|
||||||
f = fopen(filename, "rb+");
|
f = fopen(filename, "rb+");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PrintAndLog("Error: Could not open file [%s]", filename);
|
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
tag_mem_supplied = true;
|
tag_mem_supplied = true;
|
||||||
size_t bytes_read = fread(c.d.asBytes, 4*64, 1, f);
|
size_t bytes_read = fread(c.d.asBytes, 4*64, 1, f);
|
||||||
if ( bytes_read == 0) {
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("Error: File reading error");
|
PrintAndLogEx(WARNING, "Error: File reading error");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -330,13 +330,13 @@ int CmdLFHitagCheckChallenges(const char *Cmd) {
|
||||||
if (strlen(filename) > 0) {
|
if (strlen(filename) > 0) {
|
||||||
f = fopen(filename,"rb+");
|
f = fopen(filename,"rb+");
|
||||||
if ( !f ) {
|
if ( !f ) {
|
||||||
PrintAndLog("Error: Could not open file [%s]", filename);
|
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
file_given = true;
|
file_given = true;
|
||||||
size_t bytes_read = fread(c.d.asBytes, 8*60, 1, f);
|
size_t bytes_read = fread(c.d.asBytes, 8*60, 1, f);
|
||||||
if ( bytes_read == 0) {
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("Error: File reading error");
|
PrintAndLogEx(WARNING, "Error: File reading error");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -371,13 +371,13 @@ int CmdLFHitagWP(const char *Cmd) {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
PrintAndLog("Error: unkown writer function %d", htf);
|
PrintAndLogEx(WARNING, "Error: unkown writer function %d", htf);
|
||||||
PrintAndLog("Hitag writer functions");
|
PrintAndLogEx(NORMAL, "Hitag writer functions");
|
||||||
PrintAndLog(" HitagS (0*)");
|
PrintAndLogEx(NORMAL, " HitagS (0*)");
|
||||||
PrintAndLog(" 03 <nr,ar> (Challenge) <page> <byte0...byte3> write page on a Hitag S tag");
|
PrintAndLogEx(NORMAL, " 03 <nr,ar> (Challenge) <page> <byte0...byte3> write page on a Hitag S tag");
|
||||||
PrintAndLog(" 04 <key> (set to 0 if no authentication is needed) <page> <byte0...byte3> write page on a Hitag S tag");
|
PrintAndLogEx(NORMAL, " 04 <key> (set to 0 if no authentication is needed) <page> <byte0...byte3> write page on a Hitag S tag");
|
||||||
PrintAndLog(" Hitag1 (1*)");
|
PrintAndLogEx(NORMAL, " Hitag1 (1*)");
|
||||||
PrintAndLog(" Hitag2 (2*)");
|
PrintAndLogEx(NORMAL, " Hitag2 (2*)");
|
||||||
return 1;
|
return 1;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue