mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
style
This commit is contained in:
parent
ffd03dadaa
commit
21a7de38b8
5 changed files with 96 additions and 97 deletions
|
@ -918,7 +918,7 @@ void CmdHIDsimTAGEx(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT, boo
|
|||
*/
|
||||
|
||||
// special start of frame marker containing invalid Manchester bit sequences
|
||||
uint8_t bits[8+8*2+84*2] = { 0, 0, 0, 1, 1, 1, 0, 1 };
|
||||
uint8_t bits[8 + 8 * 2 + 84 * 2] = { 0, 0, 0, 1, 1, 1, 0, 1 };
|
||||
uint8_t bitlen = 0;
|
||||
uint16_t n = 8;
|
||||
|
||||
|
@ -928,9 +928,9 @@ void CmdHIDsimTAGEx(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT, boo
|
|||
DbpString("Tags can only have 84 bits.");
|
||||
return;
|
||||
}
|
||||
bitlen = 8+8*2+84*2;
|
||||
bitlen = 8 + 8 * 2 + 84 * 2;
|
||||
hi2 |= 0x9E00000; // 9E: long format identifier
|
||||
manchesterEncodeUint32(hi2, 16+12, bits, &n);
|
||||
manchesterEncodeUint32(hi2, 16 + 12, bits, &n);
|
||||
manchesterEncodeUint32(hi, 32, bits, &n);
|
||||
manchesterEncodeUint32(lo, 32, bits, &n);
|
||||
} else {
|
||||
|
@ -939,7 +939,7 @@ void CmdHIDsimTAGEx(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT, boo
|
|||
DbpString("[!] tags can only have 44 bits. - USE lf simfsk for larger tags");
|
||||
return;
|
||||
}
|
||||
bitlen = 8+44*2;
|
||||
bitlen = 8 + 44 * 2;
|
||||
manchesterEncodeUint32(hi, 12, bits, &n);
|
||||
manchesterEncodeUint32(lo, 32, bits, &n);
|
||||
}
|
||||
|
@ -2044,7 +2044,7 @@ void CopyVikingtoT55xx(uint8_t *blocks, uint8_t Q5) {
|
|||
data[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
|
||||
|
||||
data[1] = bytes_to_num(blocks, 4);
|
||||
data[2] = bytes_to_num(blocks +4, 4);
|
||||
data[2] = bytes_to_num(blocks + 4, 4);
|
||||
|
||||
// Program the data blocks for supplied ID and the block 0 config
|
||||
WriteT55xx(data, 0, 3);
|
||||
|
|
|
@ -52,7 +52,7 @@ t55xx_conf_block_t config = {
|
|||
.Q5 = false,
|
||||
.usepwd = false,
|
||||
.downlink_mode = refFixedBit
|
||||
};
|
||||
};
|
||||
|
||||
t55xx_conf_block_t Get_t55xx_Config() {
|
||||
return config;
|
||||
|
@ -338,7 +338,7 @@ static int usage_t55xx_protect() {
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, uint32_t new_password ) {
|
||||
static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, uint32_t new_password) {
|
||||
|
||||
PrintAndLogEx(INFO, "Checking current configuration");
|
||||
|
||||
|
@ -354,7 +354,7 @@ static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t pass
|
|||
if (GetT55xxBlockData(&block0) == false)
|
||||
return false;
|
||||
|
||||
bool isPwdBitAlreadySet = (block0 >> (32-28) & 1);
|
||||
bool isPwdBitAlreadySet = (block0 >> (32 - 28) & 1);
|
||||
if (isPwdBitAlreadySet) {
|
||||
PrintAndLogEx(INFO, "PWD bit is already set");
|
||||
usepwd = true;
|
||||
|
@ -368,7 +368,7 @@ static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t pass
|
|||
}
|
||||
|
||||
// write new password
|
||||
if ( t55xxWrite(T55x7_PWD_BLOCK, T55x7_PAGE0, usepwd, testmode, password, downlink_mode, new_password ) != PM3_SUCCESS ) {
|
||||
if (t55xxWrite(T55x7_PWD_BLOCK, T55x7_PAGE0, usepwd, testmode, password, downlink_mode, new_password) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Failed to write new password");
|
||||
return false;
|
||||
} else {
|
||||
|
@ -386,7 +386,7 @@ static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t pass
|
|||
}
|
||||
|
||||
// write config
|
||||
if ( t55xxWrite(T55x7_CONFIGURATION_BLOCK, T55x7_PAGE0, usepwd, testmode, curr_password, downlink_mode, block0 ) != PM3_SUCCESS ) {
|
||||
if (t55xxWrite(T55x7_CONFIGURATION_BLOCK, T55x7_PAGE0, usepwd, testmode, curr_password, downlink_mode, block0) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Failed to write modified configuration block %08X", block0);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -410,7 +410,7 @@ bool t55xxAquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known_
|
|||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Block0 write detected, running `detect` to see if validation is possible");
|
||||
|
||||
for ( uint8_t m = 0; m < 4; m++) {
|
||||
for (uint8_t m = 0; m < 4; m++) {
|
||||
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false) {
|
||||
continue;
|
||||
}
|
||||
|
@ -419,16 +419,16 @@ bool t55xxAquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known_
|
|||
continue;
|
||||
}
|
||||
|
||||
for( uint16_t i = 0; DemodBufferLen - 32; i++) {
|
||||
for (uint16_t i = 0; DemodBufferLen - 32; i++) {
|
||||
uint32_t tmp = PackBits(i, 32, DemodBuffer);
|
||||
if ( tmp == known_block0 ) {
|
||||
if (tmp == known_block0) {
|
||||
config.offset = i;
|
||||
config.downlink_mode = m;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose) {
|
||||
|
@ -436,7 +436,7 @@ bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0,
|
|||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Block0 write detected, running `detect` to see if validation is possible");
|
||||
|
||||
for ( uint8_t m = 0; m < 4; m++) {
|
||||
for (uint8_t m = 0; m < 4; m++) {
|
||||
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false)
|
||||
continue;
|
||||
|
||||
|
@ -446,7 +446,7 @@ bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0,
|
|||
config.downlink_mode = m;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, uint32_t data) {
|
||||
|
@ -462,7 +462,7 @@ bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override,
|
|||
if (GetT55xxBlockData(&read_data) == false)
|
||||
return false;
|
||||
|
||||
} else if ( res == PM3_EWRONGANSVER) {
|
||||
} else if (res == PM3_EWRONGANSVER) {
|
||||
|
||||
// could't decode. Lets see if this was a block 0 write and try read/detect it auto.
|
||||
// this messes up with ppls config..
|
||||
|
@ -539,7 +539,7 @@ void SetConfigWithBlock0Ex(uint32_t block0, uint8_t offset, bool Q5) {
|
|||
config.bitrate = dbr;
|
||||
|
||||
// FSK1a, FSK2a
|
||||
if ( datamod == DEMOD_FSK1a || datamod == DEMOD_FSK2a || datamod == DEMOD_BIa )
|
||||
if (datamod == DEMOD_FSK1a || datamod == DEMOD_FSK2a || datamod == DEMOD_BIa)
|
||||
config.inverted = 1;
|
||||
else
|
||||
config.inverted = inv;
|
||||
|
@ -679,7 +679,7 @@ static int CmdT55xxSetConfig(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors) return usage_t55xx_config();
|
||||
|
||||
if ( gotconf ) {
|
||||
if (gotconf) {
|
||||
SetConfigWithBlock0Ex(block0, config.offset, config.Q5);
|
||||
} else {
|
||||
config.block0 = 0;
|
||||
|
@ -929,7 +929,7 @@ static int CmdT55xxDetect(const char *Cmd) {
|
|||
|
||||
if (useGB == false) {
|
||||
|
||||
if ( try_all_dl_modes ) {
|
||||
if (try_all_dl_modes) {
|
||||
|
||||
for (uint8_t m = downlink_mode; m < 4; m++) {
|
||||
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false)
|
||||
|
@ -1152,7 +1152,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa
|
|||
wanted = (wanted_conf == tests[i].block0);
|
||||
|
||||
retval = testKnownConfigBlock(tests[i].block0);
|
||||
if (retval || wanted ) {
|
||||
if (retval || wanted) {
|
||||
PrintAndLogEx(NORMAL, "--[%d]--------------- << selected this", i + 1);
|
||||
config.modulation = tests[i].modulation;
|
||||
config.bitrate = tests[i].bitrate;
|
||||
|
@ -1167,7 +1167,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa
|
|||
}
|
||||
|
||||
if (print_config)
|
||||
printConfiguration(tests[i]);
|
||||
printConfiguration(tests[i]);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
|
@ -1427,7 +1427,7 @@ int printConfiguration(t55xx_conf_block_t b) {
|
|||
PrintAndLogEx(NORMAL, " Offset : %d", b.offset);
|
||||
PrintAndLogEx(NORMAL, " Seq. Term. : %s", (b.ST) ? _GREEN_("Yes") : "No");
|
||||
PrintAndLogEx(NORMAL, " Block0 : 0x%08X", b.block0);
|
||||
PrintAndLogEx(NORMAL, " Downlink Mode : %s", GetDownlinkModeStr (b.downlink_mode));
|
||||
PrintAndLogEx(NORMAL, " Downlink Mode : %s", GetDownlinkModeStr(b.downlink_mode));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -1550,7 +1550,7 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(INFO, "Writing page %d block: %02d data: 0x%08X %s", page1, block, data, (usepwd) ? pwdStr : "");
|
||||
|
||||
if ( t55xxWrite(block, page1, usepwd, testMode, password, downlink_mode, data) != PM3_SUCCESS ) {
|
||||
if (t55xxWrite(block, page1, usepwd, testMode, password, downlink_mode, data) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Write failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -2201,23 +2201,22 @@ char *GetModulationStr(uint32_t id, bool xmode) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
char *GetDownlinkModeStr (uint8_t downlink_mode)
|
||||
{
|
||||
char *GetDownlinkModeStr(uint8_t downlink_mode) {
|
||||
static char buf[30];
|
||||
char *retStr = buf;
|
||||
|
||||
switch (downlink_mode) {
|
||||
case T55XX_DLMODE_FIXED :
|
||||
snprintf(retStr, sizeof(buf),"default/fixed bit length");
|
||||
snprintf(retStr, sizeof(buf), "default/fixed bit length");
|
||||
break;
|
||||
case T55XX_DLMODE_LLR :
|
||||
snprintf(retStr, sizeof(buf),"long leading reference");
|
||||
snprintf(retStr, sizeof(buf), "long leading reference");
|
||||
break;
|
||||
case T55XX_DLMODE_LEADING_ZERO :
|
||||
snprintf(retStr, sizeof(buf),"leading zero reference");
|
||||
snprintf(retStr, sizeof(buf), "leading zero reference");
|
||||
break;
|
||||
case T55XX_DLMODE_1OF4 :
|
||||
snprintf(retStr, sizeof(buf),"1 of 4 coding reference");
|
||||
snprintf(retStr, sizeof(buf), "1 of 4 coding reference");
|
||||
break;
|
||||
default:
|
||||
snprintf(retStr, sizeof(buf), _RED_("(Unknown)"));
|
||||
|
@ -2428,7 +2427,7 @@ static int CmdT55xxWipe(const char *Cmd) {
|
|||
if (errors) return usage_t55xx_wipe();
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "\nBegin wiping %s", (Q5)? "Q5 / T5555 tag" : "T55x7 tag");
|
||||
PrintAndLogEx(INFO, "\nBegin wiping %s", (Q5) ? "Q5 / T5555 tag" : "T55x7 tag");
|
||||
|
||||
// default config blocks.
|
||||
if (gotconf == false) {
|
||||
|
@ -2615,7 +2614,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
|||
continue;
|
||||
}
|
||||
|
||||
found = tryDetectModulation(dl_mode,T55XX_PrintConfig);
|
||||
found = tryDetectModulation(dl_mode, T55XX_PrintConfig);
|
||||
if (found) {
|
||||
PrintAndLogEx(SUCCESS, "Found valid password: [ " _GREEN_("%08X") " ]", curr_password);
|
||||
dl_mode = 4; // Exit other downlink mode checks
|
||||
|
@ -2733,7 +2732,7 @@ uint8_t tryOnePassword(uint32_t password, uint8_t downlink_mode) {
|
|||
|
||||
// if (getSignalProperties()->isnoise == false) {
|
||||
// } else {
|
||||
if (tryDetectModulation(dl_mode,T55XX_PrintConfig)) {
|
||||
if (tryDetectModulation(dl_mode, T55XX_PrintConfig)) {
|
||||
return 1 + (dl_mode << 1);
|
||||
}
|
||||
// }
|
||||
|
@ -2993,7 +2992,7 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
|
|||
cmdp++;
|
||||
break;
|
||||
case 'r':
|
||||
//ICEMAN STRANGE
|
||||
//ICEMAN STRANGE
|
||||
downlink_mode = param_get8ex(Cmd, cmdp + 1, 0, 10);
|
||||
if (downlink_mode == 4)
|
||||
try_all_dl_modes = true;
|
||||
|
@ -3182,7 +3181,7 @@ static int CmdT55xxProtect(const char *Cmd) {
|
|||
cmdp += 2;
|
||||
break;
|
||||
case 'r':
|
||||
//ICEMAN STRANGE
|
||||
//ICEMAN STRANGE
|
||||
downlink_mode = param_get8ex(Cmd, cmdp + 1, 0, 10);
|
||||
if (downlink_mode > 3)
|
||||
downlink_mode = 0;
|
||||
|
@ -3206,7 +3205,7 @@ static int CmdT55xxProtect(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
|
||||
// lock
|
||||
if ( t55xxProtect(true, usepwd, override, password, downlink_mode, new_password) == false ) {
|
||||
if (t55xxProtect(true, usepwd, override, password, downlink_mode, new_password) == false) {
|
||||
PrintAndLogEx(WARNING, "Command failed. Did you run `lf t55xx detect` before?");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
|
|
@ -141,14 +141,14 @@ char *GetQ5ModulationStr(uint32_t id);
|
|||
char *GetModulationStr(uint32_t id, bool xmode);
|
||||
char *GetModelStrFromCID(uint32_t cid);
|
||||
char *GetSelectedModulationStr(uint8_t id);
|
||||
char *GetDownlinkModeStr (uint8_t dlmode);
|
||||
char *GetDownlinkModeStr(uint8_t dlmode);
|
||||
void printT5xxHeader(uint8_t page);
|
||||
void printT55xxBlock(uint8_t blockNum);
|
||||
int printConfiguration(t55xx_conf_block_t b);
|
||||
|
||||
bool t55xxAquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose);
|
||||
bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose);
|
||||
bool t55xxVerifyWrite( uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, uint32_t data);
|
||||
bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, uint32_t data);
|
||||
int T55xxReadBlock(uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode);
|
||||
int T55xxReadBlockEx(uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, bool verbose);
|
||||
|
||||
|
|
|
@ -154,5 +154,5 @@
|
|||
|
||||
/* Concatenation of all additional CA certificates in PEM format if available */
|
||||
const char additional_ca_pem[] = GLOBALSIGN_CA YUBICO_CA SOLOKEY_CA \
|
||||
FEITIAN_U2F_CA FEITIAN_FIDO2_CA HYPERFIDO_U2F_1_CA HYPERFIDO_U2F_2_CA NXP_U2F_CA;
|
||||
FEITIAN_U2F_CA FEITIAN_FIDO2_CA HYPERFIDO_U2F_1_CA HYPERFIDO_U2F_2_CA NXP_U2F_CA;
|
||||
const size_t additional_ca_pem_len = sizeof(additional_ca_pem);
|
||||
|
|
|
@ -930,7 +930,7 @@ static int l_T55xx_readblock(lua_State *L) {
|
|||
return returnToLuaWithError(L, "Failed to read config block");
|
||||
}
|
||||
|
||||
if (!tryDetectModulation(0,true)) { // Default to prev. behaviour (default dl mode and print config)
|
||||
if (!tryDetectModulation(0, true)) { // Default to prev. behaviour (default dl mode and print config)
|
||||
PrintAndLogEx(NORMAL, "Safety Check: Could not detect if PWD bit is set in config block. Exits.");
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -1006,7 +1006,7 @@ static int l_T55xx_detect(lua_State *L) {
|
|||
}
|
||||
}
|
||||
|
||||
isok = tryDetectModulation(0,true); // Default to prev. behaviour (default dl mode and print config)
|
||||
isok = tryDetectModulation(0, true); // Default to prev. behaviour (default dl mode and print config)
|
||||
if (isok == false) {
|
||||
return returnToLuaWithError(L, "Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue