mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
make style
This commit is contained in:
parent
5520bdc20f
commit
395d0f9ebf
38 changed files with 305 additions and 301 deletions
|
@ -69,12 +69,12 @@ static void print_usage_t55xx_downloadlink(uint8_t ShowAll, uint8_t dl_mode_defa
|
|||
PrintAndLogEx(NORMAL, " r <mode> - downlink encoding 0|1|2|3|4");
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " r <mode> - downlink encoding 0|1|2|3");
|
||||
PrintAndLogEx(NORMAL, " 0 - fixed bit length%s",(dl_mode_default == 0)? " (detected default)":""); // default will be whats in config struct
|
||||
PrintAndLogEx(NORMAL, " 1 - long leading reference%s",(dl_mode_default == 1)? " (detected default)":"");
|
||||
PrintAndLogEx(NORMAL, " 2 - leading zero%s",(dl_mode_default == 2)? " (detected default)":"");
|
||||
PrintAndLogEx(NORMAL, " 3 - 1 of 4 coding reference%s",(dl_mode_default == 3)? " (detected default)":"");
|
||||
PrintAndLogEx(NORMAL, " 0 - fixed bit length%s", (dl_mode_default == 0) ? " (detected default)" : ""); // default will be whats in config struct
|
||||
PrintAndLogEx(NORMAL, " 1 - long leading reference%s", (dl_mode_default == 1) ? " (detected default)" : "");
|
||||
PrintAndLogEx(NORMAL, " 2 - leading zero%s", (dl_mode_default == 2) ? " (detected default)" : "");
|
||||
PrintAndLogEx(NORMAL, " 3 - 1 of 4 coding reference%s", (dl_mode_default == 3) ? " (detected default)" : "");
|
||||
if (ShowAll == T55XX_DLMODE_ALL)
|
||||
PrintAndLogEx(NORMAL, " 4 - Try all downlink modes%s",(dl_mode_default == 4)? " (default)":"");
|
||||
PrintAndLogEx(NORMAL, " 4 - Try all downlink modes%s", (dl_mode_default == 4) ? " (default)" : "");
|
||||
}
|
||||
|
||||
static int usage_t55xx_config() {
|
||||
|
@ -89,7 +89,7 @@ static int usage_t55xx_config() {
|
|||
PrintAndLogEx(NORMAL, " Q5 [0/1] - Set/reset as T5555 ( Q5 ) chip instead of T55x7");
|
||||
PrintAndLogEx(NORMAL, " ST [0/1] - Set/reset Sequence Terminator on");
|
||||
PrintAndLogEx(NORMAL, ""); // layout is a little differnet, so seperate until a better fix
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx config d FSK - FSK demodulation");
|
||||
|
@ -105,7 +105,7 @@ static int usage_t55xx_read() {
|
|||
PrintAndLogEx(NORMAL, " p <password> - OPTIONAL password (8 hex characters)");
|
||||
PrintAndLogEx(NORMAL, " o - OPTIONAL override safety check");
|
||||
PrintAndLogEx(NORMAL, " 1 - OPTIONAL 0|1 read Page 1 instead of Page 0");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, " " _RED_("**** WARNING ****"));
|
||||
PrintAndLogEx(NORMAL, " Use of read with password on a tag not configured");
|
||||
PrintAndLogEx(NORMAL, " for a password can damage the tag");
|
||||
|
@ -122,7 +122,7 @@ static int usage_t55xx_resetread() {
|
|||
PrintAndLogEx(NORMAL, "Send Reset Cmd then lf read the stream to attempt to identify the start of it (needs a demod and/or plot after)");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx resetread [r <mode>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx resetread");
|
||||
|
@ -138,7 +138,7 @@ static int usage_t55xx_write() {
|
|||
PrintAndLogEx(NORMAL, " 1 - OPTIONAL write Page 1 instead of Page 0");
|
||||
PrintAndLogEx(NORMAL, " t - OPTIONAL test mode write - ****DANGER****");
|
||||
PrintAndLogEx(NORMAL, " v - OPTIONAL validate data afterwards");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx write b 3 d 11223344 - write 11223344 to block 3");
|
||||
|
@ -150,7 +150,7 @@ static int usage_t55xx_write() {
|
|||
static int usage_t55xx_trace() {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx trace [1] [r mode]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer otherwise read data from tag.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
|
@ -168,7 +168,7 @@ static int usage_t55xx_info() {
|
|||
PrintAndLogEx(NORMAL, " c <block0> - set configuration from a block0");
|
||||
PrintAndLogEx(NORMAL, " if set, use these data instead of reading tag.");
|
||||
PrintAndLogEx(NORMAL, " q - if set, provided data are interpreted as Q5 config.");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx info");
|
||||
|
@ -185,7 +185,7 @@ static int usage_t55xx_dump() {
|
|||
PrintAndLogEx(NORMAL, " p <password> - OPTIONAL password 4bytes (8 hex symbols)");
|
||||
PrintAndLogEx(NORMAL, " o - OPTIONAL override, force pwd read despite danger to card");
|
||||
PrintAndLogEx(NORMAL, " f <prefix> - overide filename prefix (optional). Default is based on blk 0");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx dump");
|
||||
|
@ -212,7 +212,7 @@ static int usage_t55xx_detect() {
|
|||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer otherwise read data from tag.");
|
||||
PrintAndLogEx(NORMAL, " p <password - OPTIONAL password (8 hex characters)");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL,T55XX_DLMODE_ALL);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL, T55XX_DLMODE_ALL);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx detect");
|
||||
|
@ -227,7 +227,7 @@ static int usage_t55xx_detectP1() {
|
|||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer otherwise read data from tag.");
|
||||
PrintAndLogEx(NORMAL, " p <password> - OPTIONAL password (8 hex characters)");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode); // Need to setup to try all modes
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode); // Need to setup to try all modes
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx p1detect");
|
||||
|
@ -242,7 +242,7 @@ static int usage_t55xx_wakup() {
|
|||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " p <password> - password 4bytes (8 hex symbols)");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx wakeup p 11223344 - send wakeup password");
|
||||
|
@ -257,7 +257,7 @@ static int usage_t55xx_chk() {
|
|||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, " m - use dictionary from flashmemory\n");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL,T55XX_DLMODE_ALL);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL, T55XX_DLMODE_ALL);
|
||||
PrintAndLogEx(NORMAL, " i <*.dic> - loads a default keys dictionary file <*.dic>");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
|
@ -275,7 +275,7 @@ static int usage_t55xx_bruteforce() {
|
|||
PrintAndLogEx(NORMAL, " password must be 4 bytes (8 hex symbols)");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL,T55XX_DLMODE_ALL);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL, T55XX_DLMODE_ALL);
|
||||
PrintAndLogEx(NORMAL, " s <start_pwd> - 4 byte hex value to start pwd search at");
|
||||
PrintAndLogEx(NORMAL, " e <end_pwd> - 4 byte hex value to end pwd search at");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
@ -294,7 +294,7 @@ static int usage_t55xx_recoverpw() {
|
|||
PrintAndLogEx(NORMAL, " default password is 51243648, used by many cloners");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL,T55XX_DLMODE_ALL);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_ALL, T55XX_DLMODE_ALL);
|
||||
PrintAndLogEx(NORMAL, " p <password> - 4 byte hex value of password written by cloner");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
|
@ -347,7 +347,7 @@ static int usage_t55xx_protect() {
|
|||
PrintAndLogEx(NORMAL, " p <password> - OPTIONAL password (8 hex characters)");
|
||||
PrintAndLogEx(NORMAL, " o - OPTIONAL override safety check");
|
||||
PrintAndLogEx(NORMAL, " n <new password> - new password");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE,config.downlink_mode);
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx protect n 01020304 - sets new password to 01020304");
|
||||
|
@ -358,15 +358,15 @@ static int usage_t55xx_protect() {
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
void T55x7_SaveBlockData (uint8_t idx,uint32_t data) {
|
||||
void T55x7_SaveBlockData(uint8_t idx, uint32_t data) {
|
||||
if (idx < T55x7_BLOCK_COUNT) {
|
||||
cardmem[idx].valid = true;
|
||||
cardmem[idx].valid = true;
|
||||
cardmem[idx].blockdata = data;
|
||||
}
|
||||
}
|
||||
void T55x7_ClearAllBlockData (void) {
|
||||
void T55x7_ClearAllBlockData(void) {
|
||||
for (uint8_t idx = 0; idx < T55x7_BLOCK_COUNT; idx++) {
|
||||
cardmem[idx].valid = false;
|
||||
cardmem[idx].valid = false;
|
||||
cardmem[idx].blockdata = 0x00;
|
||||
}
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ int clone_t55xx_tag(uint32_t *blockdata, uint8_t numblocks) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t res = 0;
|
||||
uint8_t res = 0;
|
||||
for (int8_t i = 0; i < numblocks; i++) {
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -524,9 +524,9 @@ bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0,
|
|||
|
||||
// Update flags for usepwd pwd assume its correct
|
||||
config.usepwd = usepwd;
|
||||
if (usepwd)
|
||||
if (usepwd)
|
||||
config.pwd = password;
|
||||
else
|
||||
else
|
||||
config.pwd = 0x00;
|
||||
|
||||
for (uint8_t m = 0; m < 4; m++) {
|
||||
|
@ -541,7 +541,7 @@ bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0,
|
|||
}
|
||||
config.usepwd = false; // unknown so assume no password
|
||||
config.pwd = 0x00;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ int T55xxReadBlockEx(uint8_t block, bool page1, bool usepwd, uint8_t override, u
|
|||
return PM3_EWRONGANSVER;
|
||||
|
||||
if (verbose)
|
||||
printT55xxBlock(block,page1);
|
||||
printT55xxBlock(block, page1);
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ static int CmdT55xxDetect(const char *Cmd) {
|
|||
if (errors) return usage_t55xx_detect();
|
||||
|
||||
// detect called so clear data blocks
|
||||
T55x7_ClearAllBlockData ();
|
||||
T55x7_ClearAllBlockData();
|
||||
|
||||
// sanity check.
|
||||
if (SanityOfflineCheck(useGB) != PM3_SUCCESS)
|
||||
|
@ -1030,18 +1030,18 @@ static int CmdT55xxDetect(const char *Cmd) {
|
|||
if (useGB == false) {
|
||||
// do ... while to check without password then loop back if password supplied
|
||||
do {
|
||||
|
||||
|
||||
if (try_all_dl_modes) {
|
||||
for (uint8_t m = downlink_mode; m < 4; m++) {
|
||||
|
||||
|
||||
if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, try_with_pwd & usepwd, password, m) == false)
|
||||
continue;
|
||||
|
||||
// pre fill to save passing in.
|
||||
config.usepwd = try_with_pwd;
|
||||
if (try_with_pwd)
|
||||
if (try_with_pwd)
|
||||
config.pwd = password;
|
||||
else
|
||||
else
|
||||
config.pwd = 0x00;
|
||||
|
||||
if (tryDetectModulation(m, T55XX_PrintConfig) == false)
|
||||
|
@ -1052,9 +1052,9 @@ static int CmdT55xxDetect(const char *Cmd) {
|
|||
}
|
||||
} else {
|
||||
config.usepwd = try_with_pwd;
|
||||
if (try_with_pwd)
|
||||
if (try_with_pwd)
|
||||
config.pwd = password;
|
||||
else
|
||||
else
|
||||
config.pwd = 0x00;
|
||||
|
||||
if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, downlink_mode)) {
|
||||
|
@ -1062,12 +1062,12 @@ static int CmdT55xxDetect(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!found & usepwd)
|
||||
if (!found & usepwd)
|
||||
try_with_pwd = !try_with_pwd; // toggle so we loop back if not found and try with pwd
|
||||
|
||||
if (found)
|
||||
|
||||
if (found)
|
||||
try_with_pwd = false; // force exit as decect block has been found.
|
||||
|
||||
|
||||
} while (try_with_pwd);
|
||||
|
||||
} else {
|
||||
|
@ -1345,7 +1345,7 @@ void printT55xxBlock(uint8_t blockNum, bool page1) {
|
|||
|
||||
num_to_bytes(blockData, 4, bytes);
|
||||
|
||||
T55x7_SaveBlockData ((page1)?blockNum+8 : blockNum,blockData);
|
||||
T55x7_SaveBlockData((page1) ? blockNum + 8 : blockNum, blockData);
|
||||
|
||||
PrintAndLogEx(SUCCESS, " %02d | %08X | %s | %s", blockNum, blockData, sprint_bin(DemodBuffer + config.offset, 32), sprint_ascii(bytes, 4));
|
||||
}
|
||||
|
@ -1556,7 +1556,7 @@ int printConfiguration(t55xx_conf_block_t b) {
|
|||
PrintAndLogEx(NORMAL, " Downlink Mode : %s", GetDownlinkModeStr(b.downlink_mode));
|
||||
PrintAndLogEx(NORMAL, " Password Set : %s", (b.usepwd) ? _RED_("Yes") : _GREEN_("No"));
|
||||
if (b.usepwd)
|
||||
PrintAndLogEx(NORMAL, " Password : %08X",b.pwd);
|
||||
PrintAndLogEx(NORMAL, " Password : %08X", b.pwd);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -1930,9 +1930,9 @@ void printT55x7Trace(t55x7_tracedata_t data, uint8_t repeat) {
|
|||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
|
||||
/*
|
||||
Trace info.
|
||||
M1, M2 has the about ATMEL defintion of trace data.
|
||||
M3 has unique format following industry defacto standard with row/col parity
|
||||
Trace info.
|
||||
M1, M2 has the about ATMEL defintion of trace data.
|
||||
M3 has unique format following industry defacto standard with row/col parity
|
||||
|
||||
TRACE - BLOCK O
|
||||
Bits Definition HEX
|
||||
|
@ -1950,11 +1950,11 @@ void printT55x7Trace(t55x7_tracedata_t data, uint8_t repeat) {
|
|||
1-12 LOT ID
|
||||
13-17 Wafer number
|
||||
18-32 DW, die number sequential
|
||||
|
||||
|
||||
|
||||
Startup times (FC)
|
||||
M1, M2 = 192
|
||||
M3 = 128
|
||||
M1, M2 = 192
|
||||
M3 = 128
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -2226,11 +2226,11 @@ static int CmdT55xxDump(const char *Cmd) {
|
|||
cmdp++;
|
||||
break;
|
||||
case 'f':
|
||||
param_getstr(Cmd, cmdp + 1, preferredName, FILE_PATH_SIZE);
|
||||
cmdp+=2;
|
||||
if (strlen (preferredName) == 0)
|
||||
errors = true;
|
||||
break;
|
||||
param_getstr(Cmd, cmdp + 1, preferredName, FILE_PATH_SIZE);
|
||||
cmdp += 2;
|
||||
if (strlen(preferredName) == 0)
|
||||
errors = true;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
|
@ -2250,35 +2250,35 @@ static int CmdT55xxDump(const char *Cmd) {
|
|||
if (override == 1) override++; // flag not to show safty for 2nd and on.
|
||||
}
|
||||
printT5xxHeader(1);
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
if (T55xxReadBlock(i, 1, usepwd, override, password, downlink_mode) != PM3_SUCCESS)
|
||||
T55x7_SaveBlockData (8+i,0x00);
|
||||
T55x7_SaveBlockData(8 + i, 0x00);
|
||||
|
||||
|
||||
if (success) { // all ok save dump to file
|
||||
// saveFileEML will add .eml extension to filename
|
||||
// saveFile (binary) passes in the .bin extension.
|
||||
if (strcmp (preferredName,"") == 0) { // Set default filename, if not set by user
|
||||
strcpy (preferredName,"lf-t55xx");
|
||||
if (strcmp(preferredName, "") == 0) { // Set default filename, if not set by user
|
||||
strcpy(preferredName, "lf-t55xx");
|
||||
for (uint8_t i = 1; i <= 7; i++) {
|
||||
if ((cardmem[i].blockdata != 0x00) && (cardmem[i].blockdata != 0xFFFFFFFF))
|
||||
sprintf (preferredName + strlen(preferredName),"-%08X",cardmem[i].blockdata);
|
||||
sprintf(preferredName + strlen(preferredName), "-%08X", cardmem[i].blockdata);
|
||||
else
|
||||
break;
|
||||
}
|
||||
strcat (preferredName,"-data");
|
||||
strcat(preferredName, "-data");
|
||||
}
|
||||
|
||||
// Swap endian so the files match the txt display
|
||||
uint32_t data[T55x7_BLOCK_COUNT];
|
||||
|
||||
|
||||
for (int i = 0; i < T55x7_BLOCK_COUNT; i++)
|
||||
data[i] = BSWAP_32(cardmem[i].blockdata);
|
||||
|
||||
saveFileEML(preferredName, (uint8_t *)data, T55x7_BLOCK_COUNT*sizeof(uint32_t), sizeof(uint32_t));
|
||||
saveFile (preferredName, ".bin", data, sizeof(data));
|
||||
saveFileEML(preferredName, (uint8_t *)data, T55x7_BLOCK_COUNT * sizeof(uint32_t), sizeof(uint32_t));
|
||||
saveFile(preferredName, ".bin", data, sizeof(data));
|
||||
}
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2301,17 +2301,17 @@ static int CmdT55xxRestore(const char *Cmd) {
|
|||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_t55xx_restore();
|
||||
case 'f':
|
||||
param_getstr(Cmd, cmdp + 1, preferredName, FILE_PATH_SIZE);
|
||||
if (strlen (preferredName) == 0)
|
||||
errors = true;
|
||||
cmdp+=2;
|
||||
break;
|
||||
case 'f':
|
||||
param_getstr(Cmd, cmdp + 1, preferredName, FILE_PATH_SIZE);
|
||||
if (strlen(preferredName) == 0)
|
||||
errors = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'p':
|
||||
password = param_get32ex(Cmd, cmdp + 1, 0, 16);
|
||||
usepwd = true;
|
||||
cmdp += 2;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
|
@ -2320,40 +2320,40 @@ static int CmdT55xxRestore(const char *Cmd) {
|
|||
}
|
||||
|
||||
// File name expected to be .eml .bin or .json so sould be at least 4
|
||||
if (errors || (strlen (preferredName) == 0)) return usage_t55xx_restore();
|
||||
|
||||
if (errors || (strlen(preferredName) == 0)) return usage_t55xx_restore();
|
||||
|
||||
// split file name into prefix and ext.
|
||||
int fnLength;
|
||||
|
||||
fnLength = strlen (preferredName);
|
||||
|
||||
fnLength = strlen(preferredName);
|
||||
|
||||
success = PM3_ESOFT;
|
||||
if (fnLength > 4) { // Holds extension [.bin|.eml]
|
||||
memcpy (ext,&preferredName[fnLength - 4],4);
|
||||
memcpy(ext, &preferredName[fnLength - 4], 4);
|
||||
ext[5] = 0x00;
|
||||
|
||||
// check if valid file extension and attempt to load data
|
||||
|
||||
if (memcmp (ext,".bin",4) == 0) {
|
||||
preferredName[fnLength-4] = 0x00;
|
||||
success = loadFile (preferredName, ".bin", data, sizeof(data),&datalen);
|
||||
|
||||
} else if (memcmp (ext,".eml",4) == 0) {
|
||||
preferredName[fnLength-4] = 0x00;
|
||||
if (memcmp(ext, ".bin", 4) == 0) {
|
||||
preferredName[fnLength - 4] = 0x00;
|
||||
success = loadFile(preferredName, ".bin", data, sizeof(data), &datalen);
|
||||
|
||||
} else if (memcmp(ext, ".eml", 4) == 0) {
|
||||
preferredName[fnLength - 4] = 0x00;
|
||||
datalen = 12;
|
||||
success = loadFileEML(preferredName, (uint8_t *)data, &datalen);
|
||||
|
||||
} else
|
||||
PrintAndLogEx(WARNING,"\nWarning: invalid dump filename "_YELLOW_("%s")"to restore!\n",preferredName);
|
||||
} else
|
||||
PrintAndLogEx(WARNING, "\nWarning: invalid dump filename "_YELLOW_("%s")"to restore!\n", preferredName);
|
||||
}
|
||||
|
||||
if (success == PM3_SUCCESS) { // Got data, so write to cards
|
||||
if (datalen == T55x7_BLOCK_COUNT * 4) { // 12 blocks * 4 bytes per block
|
||||
if (usepwd)
|
||||
sprintf (pwdOpt,"p %08X",password);
|
||||
sprintf(pwdOpt, "p %08X", password);
|
||||
|
||||
// Restore endien for writing to card
|
||||
for (blockidx = 0; blockidx < 12; blockidx++)
|
||||
for (blockidx = 0; blockidx < 12; blockidx++)
|
||||
data[blockidx] = BSWAP_32(data[blockidx]);
|
||||
|
||||
// Have data ready, lets write
|
||||
|
@ -2364,30 +2364,30 @@ static int CmdT55xxRestore(const char *Cmd) {
|
|||
downlink_mode = 0;
|
||||
if ((((data[11] >> 28) & 0xf) == 6) || (((data[11] >> 28) & 0xf) == 9))
|
||||
downlink_mode = (data[11] >> 10) & 3;
|
||||
|
||||
|
||||
// write out blocks 1-7 page 0
|
||||
for (blockidx = 1; blockidx <= 7; blockidx++) {
|
||||
sprintf (writeCmdOpt,"b %d d %08X %s",blockidx,data[blockidx],pwdOpt);
|
||||
sprintf(writeCmdOpt, "b %d d %08X %s", blockidx, data[blockidx], pwdOpt);
|
||||
if (CmdT55xxWriteBlock(writeCmdOpt) != PM3_SUCCESS)
|
||||
PrintAndLogEx(WARNING, "Warning: error writing blk %d",blockidx);
|
||||
PrintAndLogEx(WARNING, "Warning: error writing blk %d", blockidx);
|
||||
}
|
||||
|
||||
// if password was set on the "blank" update as we may have just changed it
|
||||
if (usepwd)
|
||||
sprintf (pwdOpt,"p %08X",data[7]);
|
||||
sprintf(pwdOpt, "p %08X", data[7]);
|
||||
|
||||
// write out blocks 1-3 page 1
|
||||
for (blockidx = 9; blockidx <= 11; blockidx++) {
|
||||
sprintf (writeCmdOpt,"b %d 1 d %08X %s",blockidx-8,data[blockidx],pwdOpt);
|
||||
sprintf(writeCmdOpt, "b %d 1 d %08X %s", blockidx - 8, data[blockidx], pwdOpt);
|
||||
if (CmdT55xxWriteBlock(writeCmdOpt) != PM3_SUCCESS)
|
||||
PrintAndLogEx(WARNING, "Warning: error writing blk %d",blockidx);
|
||||
PrintAndLogEx(WARNING, "Warning: error writing blk %d", blockidx);
|
||||
}
|
||||
|
||||
// Update downlink mode for the page 0 config write.
|
||||
config.downlink_mode = downlink_mode;
|
||||
|
||||
|
||||
// Write the page 0 config
|
||||
sprintf (writeCmdOpt,"b 0 d %08X %s",data[0],pwdOpt);
|
||||
sprintf(writeCmdOpt, "b 0 d %08X %s", data[0], pwdOpt);
|
||||
if (CmdT55xxWriteBlock(writeCmdOpt) != PM3_SUCCESS)
|
||||
PrintAndLogEx(WARNING, "Warning: error writing blk 0");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue