This commit is contained in:
iceman1001 2019-09-19 10:54:34 +02:00
commit 21a7de38b8
5 changed files with 96 additions and 97 deletions

View file

@ -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 // 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; uint8_t bitlen = 0;
uint16_t n = 8; 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."); DbpString("Tags can only have 84 bits.");
return; return;
} }
bitlen = 8+8*2+84*2; bitlen = 8 + 8 * 2 + 84 * 2;
hi2 |= 0x9E00000; // 9E: long format identifier hi2 |= 0x9E00000; // 9E: long format identifier
manchesterEncodeUint32(hi2, 16+12, bits, &n); manchesterEncodeUint32(hi2, 16 + 12, bits, &n);
manchesterEncodeUint32(hi, 32, bits, &n); manchesterEncodeUint32(hi, 32, bits, &n);
manchesterEncodeUint32(lo, 32, bits, &n); manchesterEncodeUint32(lo, 32, bits, &n);
} else { } 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"); DbpString("[!] tags can only have 44 bits. - USE lf simfsk for larger tags");
return; return;
} }
bitlen = 8+44*2; bitlen = 8 + 44 * 2;
manchesterEncodeUint32(hi, 12, bits, &n); manchesterEncodeUint32(hi, 12, bits, &n);
manchesterEncodeUint32(lo, 32, bits, &n); manchesterEncodeUint32(lo, 32, bits, &n);
} }
@ -2038,14 +2038,14 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
// clone viking tag to T55xx // clone viking tag to T55xx
void CopyVikingtoT55xx(uint8_t *blocks, uint8_t Q5) { void CopyVikingtoT55xx(uint8_t *blocks, uint8_t Q5) {
uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), 0, 0}; uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), 0, 0};
if (Q5) if (Q5)
data[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT; data[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
data[1] = bytes_to_num(blocks, 4); 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 // Program the data blocks for supplied ID and the block 0 config
WriteT55xx(data, 0, 3); WriteT55xx(data, 0, 3);
LED_D_OFF(); LED_D_OFF();

View file

@ -44,7 +44,7 @@
//static uint8_t bit_rates[9] = {8, 16, 32, 40, 50, 64, 100, 128, 0}; //static uint8_t bit_rates[9] = {8, 16, 32, 40, 50, 64, 100, 128, 0};
// Default configuration // Default configuration
t55xx_conf_block_t config = { t55xx_conf_block_t config = {
.modulation = DEMOD_ASK, .modulation = DEMOD_ASK,
.inverted = false, .inverted = false,
.offset = 0x00, .offset = 0x00,
@ -52,7 +52,7 @@ t55xx_conf_block_t config = {
.Q5 = false, .Q5 = false,
.usepwd = false, .usepwd = false,
.downlink_mode = refFixedBit .downlink_mode = refFixedBit
}; };
t55xx_conf_block_t Get_t55xx_Config() { t55xx_conf_block_t Get_t55xx_Config() {
return config; return config;
@ -86,7 +86,7 @@ static int usage_t55xx_config() {
PrintAndLogEx(NORMAL, " Q5 [0/1] - Set/reset as Q5(T5555) chip instead of T55x7"); PrintAndLogEx(NORMAL, " Q5 [0/1] - Set/reset as Q5(T5555) chip instead of T55x7");
PrintAndLogEx(NORMAL, " ST [0/1] - Set/reset Sequence Terminator on"); PrintAndLogEx(NORMAL, " ST [0/1] - Set/reset Sequence Terminator on");
PrintAndLogEx(NORMAL, ""); // layout is a little differnet, so seperate until a better fix PrintAndLogEx(NORMAL, ""); // layout is a little differnet, so seperate until a better fix
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE); print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE);
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf t55xx config d FSK - FSK demodulation"); PrintAndLogEx(NORMAL, " lf t55xx config d FSK - FSK demodulation");
@ -331,17 +331,17 @@ static int usage_t55xx_protect() {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf t55xx protect n 01020304 - sets new password to 01020304"); PrintAndLogEx(NORMAL, " lf t55xx protect n 01020304 - sets new password to 01020304");
PrintAndLogEx(NORMAL, " lf t55xx protect p 11223344 - use pwd 11223344 to set newpwd to 00000000"); PrintAndLogEx(NORMAL, " lf t55xx protect p 11223344 - use pwd 11223344 to set newpwd to 00000000");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int CmdHelp(const char *Cmd); 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"); PrintAndLogEx(INFO, "Checking current configuration");
bool testmode = false; bool testmode = false;
uint32_t block0 = 0; uint32_t block0 = 0;
@ -350,25 +350,25 @@ static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t pass
PrintAndLogEx(WARNING, "Failed to read block0, use `p` password parameter?"); PrintAndLogEx(WARNING, "Failed to read block0, use `p` password parameter?");
return false; return false;
} }
if (GetT55xxBlockData(&block0) == false) if (GetT55xxBlockData(&block0) == false)
return false; return false;
bool isPwdBitAlreadySet = (block0 >> (32-28) & 1); bool isPwdBitAlreadySet = (block0 >> (32 - 28) & 1);
if (isPwdBitAlreadySet) { if (isPwdBitAlreadySet) {
PrintAndLogEx(INFO, "PWD bit is already set"); PrintAndLogEx(INFO, "PWD bit is already set");
usepwd = true; usepwd = true;
} }
// set / clear pwd bit // set / clear pwd bit
if (lock) { if (lock) {
block0 |= 1 << 4; block0 |= 1 << 4;
} else { } else {
block0 &= ~(1 << 4); block0 &= ~(1 << 4);
} }
// write new password // 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"); PrintAndLogEx(ERR, "Failed to write new password");
return false; return false;
} else { } else {
@ -377,22 +377,22 @@ static bool t55xxProtect(bool lock, bool usepwd, uint8_t override, uint32_t pass
// validate new password // validate new password
uint32_t curr_password = (isPwdBitAlreadySet) ? new_password : password; uint32_t curr_password = (isPwdBitAlreadySet) ? new_password : password;
if (t55xxVerifyWrite(T55x7_PWD_BLOCK, T55x7_PAGE0, usepwd, override, curr_password, downlink_mode, new_password) == false) { if (t55xxVerifyWrite(T55x7_PWD_BLOCK, T55x7_PAGE0, usepwd, override, curr_password, downlink_mode, new_password) == false) {
PrintAndLogEx(WARNING, "Failed to validate the password write. aborting."); PrintAndLogEx(WARNING, "Failed to validate the password write. aborting.");
return false; return false;
} else { } else {
PrintAndLogEx(SUCCESS, "Validated new password"); PrintAndLogEx(SUCCESS, "Validated new password");
} }
// write config // 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); PrintAndLogEx(ERR, "Failed to write modified configuration block %08X", block0);
return false; return false;
} else { } else {
PrintAndLogEx(SUCCESS, "Wrote modified configuration block"); PrintAndLogEx(SUCCESS, "Wrote modified configuration block");
} }
// validate new config. If all went well, card should now demand pwd, hence override = 0. // validate new config. If all went well, card should now demand pwd, hence override = 0.
override = 0; override = 0;
if (t55xxVerifyWrite(T55x7_CONFIGURATION_BLOCK, T55x7_PAGE0, true, override, new_password, downlink_mode, block0) == false) { if (t55xxVerifyWrite(T55x7_CONFIGURATION_BLOCK, T55x7_PAGE0, true, override, new_password, downlink_mode, block0) == false) {
@ -409,34 +409,34 @@ bool t55xxAquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known_
if (verbose) if (verbose)
PrintAndLogEx(INFO, "Block0 write detected, running `detect` to see if validation is possible"); 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) { if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false) {
continue; continue;
} }
if (DecodeT55xxBlock() == false) { if (DecodeT55xxBlock() == false) {
continue; continue;
} }
for( uint16_t i = 0; DemodBufferLen - 32; i++) { for (uint16_t i = 0; DemodBufferLen - 32; i++) {
uint32_t tmp = PackBits(i, 32, DemodBuffer); uint32_t tmp = PackBits(i, 32, DemodBuffer);
if ( tmp == known_block0 ) { if (tmp == known_block0) {
config.offset = i; config.offset = i;
config.downlink_mode = m; config.downlink_mode = m;
return true; return true;
} }
} }
} }
return false; return false;
} }
bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose) { bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose) {
if (verbose) if (verbose)
PrintAndLogEx(INFO, "Block0 write detected, running `detect` to see if validation is possible"); 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) if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false)
continue; continue;
@ -446,14 +446,14 @@ bool t55xxAquireAndDetect(bool usepwd, uint32_t password, uint32_t known_block0,
config.downlink_mode = m; config.downlink_mode = m;
return true; 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) { bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, uint32_t data) {
uint32_t read_data = 0; uint32_t read_data = 0;
if (downlink_mode == 0xFF) if (downlink_mode == 0xFF)
downlink_mode = config.downlink_mode; downlink_mode = config.downlink_mode;
int res = T55xxReadBlockEx(block, page1, usepwd, override, password, downlink_mode, false); int res = T55xxReadBlockEx(block, page1, usepwd, override, password, downlink_mode, false);
@ -462,15 +462,15 @@ bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override,
if (GetT55xxBlockData(&read_data) == false) if (GetT55xxBlockData(&read_data) == false)
return 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. // could't decode. Lets see if this was a block 0 write and try read/detect it auto.
// this messes up with ppls config.. // this messes up with ppls config..
if (block == 0 && page1 == false) { if (block == 0 && page1 == false) {
if (t55xxAquireAndDetect(usepwd, password, data, true) == false) if (t55xxAquireAndDetect(usepwd, password, data, true) == false)
return false; return false;
return t55xxVerifyWrite(block, page1, usepwd, 2, password, config.downlink_mode, data); return t55xxVerifyWrite(block, page1, usepwd, 2, password, config.downlink_mode, data);
} }
} }
@ -479,7 +479,7 @@ bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override,
} }
int t55xxWrite(uint8_t block, bool page1, bool usepwd, bool testMode, uint32_t password, uint8_t downlink_mode, uint32_t data) { int t55xxWrite(uint8_t block, bool page1, bool usepwd, bool testMode, uint32_t password, uint8_t downlink_mode, uint32_t data) {
uint8_t flags; uint8_t flags;
flags = (usepwd) ? 0x1 : 0; flags = (usepwd) ? 0x1 : 0;
flags |= (page1) ? 0x2 : 0; flags |= (page1) ? 0x2 : 0;
@ -534,16 +534,16 @@ void SetConfigWithBlock0Ex(uint32_t block0, uint8_t offset, bool Q5) {
bool pwd = (bool)((block0 >> (32 - 28)) & 0x01); bool pwd = (bool)((block0 >> (32 - 28)) & 0x01);
bool sst = (bool)((block0 >> (32 - 29)) & 0x01); bool sst = (bool)((block0 >> (32 - 29)) & 0x01);
bool inv = (bool)((block0 >> (32 - 31)) & 0x01); bool inv = (bool)((block0 >> (32 - 31)) & 0x01);
config.modulation = datamod; config.modulation = datamod;
config.bitrate = dbr; config.bitrate = dbr;
// FSK1a, FSK2a // 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; config.inverted = 1;
else else
config.inverted = inv; config.inverted = inv;
config.Q5 = Q5; config.Q5 = Q5;
config.ST = sst; config.ST = sst;
config.usepwd = pwd; config.usepwd = pwd;
@ -564,7 +564,7 @@ static int CmdT55xxSetConfig(const char *Cmd) {
bool errors = false; bool errors = false;
uint32_t block0 = 0; uint32_t block0 = 0;
bool gotconf = false; bool gotconf = false;
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) { while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
char tmp = tolower(param_getchar(Cmd, cmdp)); char tmp = tolower(param_getchar(Cmd, cmdp));
switch (tmp) { switch (tmp) {
@ -679,8 +679,8 @@ static int CmdT55xxSetConfig(const char *Cmd) {
//Validations //Validations
if (errors) return usage_t55xx_config(); if (errors) return usage_t55xx_config();
if ( gotconf ) { if (gotconf) {
SetConfigWithBlock0Ex(block0, config.offset, config.Q5); SetConfigWithBlock0Ex(block0, config.offset, config.Q5);
} else { } else {
config.block0 = 0; config.block0 = 0;
} }
@ -928,9 +928,9 @@ static int CmdT55xxDetect(const char *Cmd) {
return PM3_ESOFT; return PM3_ESOFT;
if (useGB == false) { if (useGB == false) {
if ( try_all_dl_modes ) { if (try_all_dl_modes) {
for (uint8_t m = downlink_mode; m < 4; m++) { for (uint8_t m = downlink_mode; m < 4; m++) {
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false) if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false)
continue; continue;
@ -942,7 +942,7 @@ static int CmdT55xxDetect(const char *Cmd) {
break; break;
} }
} else { } else {
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, downlink_mode)) { if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, downlink_mode)) {
found = tryDetectModulation(downlink_mode, T55XX_PrintConfig); found = tryDetectModulation(downlink_mode, T55XX_PrintConfig);
} }
@ -951,10 +951,10 @@ static int CmdT55xxDetect(const char *Cmd) {
} else { } else {
found = tryDetectModulation(downlink_mode, T55XX_PrintConfig); found = tryDetectModulation(downlink_mode, T55XX_PrintConfig);
} }
if (found == false) if (found == false)
PrintAndLogEx(WARNING, "Could not detect modulation automatically. Try setting it manually with " _YELLOW_("\'lf t55xx config\'")); PrintAndLogEx(WARNING, "Could not detect modulation automatically. Try setting it manually with " _YELLOW_("\'lf t55xx config\'"));
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -1146,13 +1146,13 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa
if (hits > 1) { if (hits > 1) {
PrintAndLogEx(SUCCESS, "Found [%d] possible matches for modulation.", hits); PrintAndLogEx(SUCCESS, "Found [%d] possible matches for modulation.", hits);
for (int i = 0; i < hits; ++i) { for (int i = 0; i < hits; ++i) {
bool wanted = false; bool wanted = false;
if (wanted_conf > 0) if (wanted_conf > 0)
wanted = (wanted_conf == tests[i].block0); wanted = (wanted_conf == tests[i].block0);
retval = testKnownConfigBlock(tests[i].block0); retval = testKnownConfigBlock(tests[i].block0);
if (retval || wanted ) { if (retval || wanted) {
PrintAndLogEx(NORMAL, "--[%d]--------------- << selected this", i + 1); PrintAndLogEx(NORMAL, "--[%d]--------------- << selected this", i + 1);
config.modulation = tests[i].modulation; config.modulation = tests[i].modulation;
config.bitrate = tests[i].bitrate; config.bitrate = tests[i].bitrate;
@ -1167,7 +1167,7 @@ bool tryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32_t wa
} }
if (print_config) if (print_config)
printConfiguration(tests[i]); printConfiguration(tests[i]);
} }
} }
return retval; return retval;
@ -1327,14 +1327,14 @@ static bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk)
si += 3; si += 3;
//uint8_t ST = PackBits(si, 1, DemodBuffer); si += 1; //uint8_t ST = PackBits(si, 1, DemodBuffer); si += 1;
if (maxBlk == 0) continue; if (maxBlk == 0) continue;
//test modulation //test modulation
if (!testQ5Modulation(mode, modread)) continue; if (!testQ5Modulation(mode, modread)) continue;
if (bitRate != clk) continue; if (bitRate != clk) continue;
*fndBitRate = convertQ5bitRate(bitRate); *fndBitRate = convertQ5bitRate(bitRate);
if (*fndBitRate < 0) continue; if (*fndBitRate < 0) continue;
*offset = idx; *offset = idx;
return true; return true;
@ -1427,7 +1427,7 @@ int printConfiguration(t55xx_conf_block_t b) {
PrintAndLogEx(NORMAL, " Offset : %d", b.offset); PrintAndLogEx(NORMAL, " Offset : %d", b.offset);
PrintAndLogEx(NORMAL, " Seq. Term. : %s", (b.ST) ? _GREEN_("Yes") : "No"); PrintAndLogEx(NORMAL, " Seq. Term. : %s", (b.ST) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " Block0 : 0x%08X", b.block0); 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, ""); PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -1550,19 +1550,19 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
PrintAndLogEx(INFO, "Writing page %d block: %02d data: 0x%08X %s", page1, block, data, (usepwd) ? pwdStr : ""); 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"); PrintAndLogEx(ERR, "Write failed");
return PM3_ESOFT; return PM3_ESOFT;
} }
if (validate) { if (validate) {
bool isOK = t55xxVerifyWrite(block, page1, usepwd, 1, password, downlink_mode, data); bool isOK = t55xxVerifyWrite(block, page1, usepwd, 1, password, downlink_mode, data);
if (isOK) if (isOK)
PrintAndLogEx(SUCCESS, "Write OK, validation successful"); PrintAndLogEx(SUCCESS, "Write OK, validation successful");
else else
PrintAndLogEx(WARNING, "Write could not validate the written data"); PrintAndLogEx(WARNING, "Write could not validate the written data");
} }
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -2201,23 +2201,22 @@ char *GetModulationStr(uint32_t id, bool xmode) {
return buf; return buf;
} }
char *GetDownlinkModeStr (uint8_t downlink_mode) char *GetDownlinkModeStr(uint8_t downlink_mode) {
{
static char buf[30]; static char buf[30];
char *retStr = buf; char *retStr = buf;
switch (downlink_mode) { switch (downlink_mode) {
case T55XX_DLMODE_FIXED : case T55XX_DLMODE_FIXED :
snprintf(retStr, sizeof(buf),"default/fixed bit length"); snprintf(retStr, sizeof(buf), "default/fixed bit length");
break; break;
case T55XX_DLMODE_LLR : case T55XX_DLMODE_LLR :
snprintf(retStr, sizeof(buf),"long leading reference"); snprintf(retStr, sizeof(buf), "long leading reference");
break; break;
case T55XX_DLMODE_LEADING_ZERO : case T55XX_DLMODE_LEADING_ZERO :
snprintf(retStr, sizeof(buf),"leading zero reference"); snprintf(retStr, sizeof(buf), "leading zero reference");
break; break;
case T55XX_DLMODE_1OF4 : case T55XX_DLMODE_1OF4 :
snprintf(retStr, sizeof(buf),"1 of 4 coding reference"); snprintf(retStr, sizeof(buf), "1 of 4 coding reference");
break; break;
default: default:
snprintf(retStr, sizeof(buf), _RED_("(Unknown)")); snprintf(retStr, sizeof(buf), _RED_("(Unknown)"));
@ -2428,7 +2427,7 @@ static int CmdT55xxWipe(const char *Cmd) {
if (errors) return usage_t55xx_wipe(); 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. // default config blocks.
if (gotconf == false) { if (gotconf == false) {
@ -2441,17 +2440,17 @@ static int CmdT55xxWipe(const char *Cmd) {
snprintf(msg, sizeof(msg), "User provided configuration block %08X", block0); snprintf(msg, sizeof(msg), "User provided configuration block %08X", block0);
else else
snprintf(msg, sizeof(msg), "Default configation block %08X", block0); snprintf(msg, sizeof(msg), "Default configation block %08X", block0);
PrintAndLogEx(INFO, "%s", msg); PrintAndLogEx(INFO, "%s", msg);
// Creating cmd string for write block :) // Creating cmd string for write block :)
snprintf(ptrData, sizeof(writeData), "b 0 "); snprintf(ptrData, sizeof(writeData), "b 0 ");
if (usepwd) { if (usepwd) {
snprintf(ptrData + strlen(writeData), sizeof(writeData) - strlen(writeData), "p %08x ", password); snprintf(ptrData + strlen(writeData), sizeof(writeData) - strlen(writeData), "p %08x ", password);
} }
snprintf(ptrData + strlen(writeData), sizeof(writeData) - strlen(writeData), "d %08X", block0); snprintf(ptrData + strlen(writeData), sizeof(writeData) - strlen(writeData), "d %08X", block0);
if (CmdT55xxWriteBlock(ptrData) != PM3_SUCCESS) if (CmdT55xxWriteBlock(ptrData) != PM3_SUCCESS)
PrintAndLogEx(WARNING, "Warning: error writing blk 0"); PrintAndLogEx(WARNING, "Warning: error writing blk 0");
@ -2464,7 +2463,7 @@ static int CmdT55xxWipe(const char *Cmd) {
memset(writeData, 0x00, sizeof(writeData)); memset(writeData, 0x00, sizeof(writeData));
} }
// Check and rest t55xx downlink mode. // Check and rest t55xx downlink mode.
if (config.downlink_mode != T55XX_DLMODE_FIXED) { // Detect found a different mode so card must support if (config.downlink_mode != T55XX_DLMODE_FIXED) { // Detect found a different mode so card must support
snprintf(ptrData, sizeof(writeData), "b 3 1 d 00000000"); snprintf(ptrData, sizeof(writeData), "b 3 1 d 00000000");
@ -2615,7 +2614,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
continue; continue;
} }
found = tryDetectModulation(dl_mode,T55XX_PrintConfig); found = tryDetectModulation(dl_mode, T55XX_PrintConfig);
if (found) { if (found) {
PrintAndLogEx(SUCCESS, "Found valid password: [ " _GREEN_("%08X") " ]", curr_password); PrintAndLogEx(SUCCESS, "Found valid password: [ " _GREEN_("%08X") " ]", curr_password);
dl_mode = 4; // Exit other downlink mode checks 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) { // if (getSignalProperties()->isnoise == false) {
// } else { // } else {
if (tryDetectModulation(dl_mode,T55XX_PrintConfig)) { if (tryDetectModulation(dl_mode, T55XX_PrintConfig)) {
return 1 + (dl_mode << 1); return 1 + (dl_mode << 1);
} }
// } // }
@ -2992,8 +2991,8 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
useGB = true; useGB = true;
cmdp++; cmdp++;
break; break;
case 'r': case 'r':
//ICEMAN STRANGE //ICEMAN STRANGE
downlink_mode = param_get8ex(Cmd, cmdp + 1, 0, 10); downlink_mode = param_get8ex(Cmd, cmdp + 1, 0, 10);
if (downlink_mode == 4) if (downlink_mode == 4)
try_all_dl_modes = true; try_all_dl_modes = true;
@ -3028,7 +3027,7 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
} else { } else {
found = tryDetectP1(false); found = tryDetectP1(false);
} }
if (found) { if (found) {
PrintAndLogEx(SUCCESS, "T55xx chip found!"); PrintAndLogEx(SUCCESS, "T55xx chip found!");
T55xx_Print_DownlinkMode(found_mode); T55xx_Print_DownlinkMode(found_mode);
@ -3181,8 +3180,8 @@ static int CmdT55xxProtect(const char *Cmd) {
override = 1; override = 1;
cmdp += 2; cmdp += 2;
break; break;
case 'r': case 'r':
//ICEMAN STRANGE //ICEMAN STRANGE
downlink_mode = param_get8ex(Cmd, cmdp + 1, 0, 10); downlink_mode = param_get8ex(Cmd, cmdp + 1, 0, 10);
if (downlink_mode > 3) if (downlink_mode > 3)
downlink_mode = 0; downlink_mode = 0;
@ -3198,15 +3197,15 @@ static int CmdT55xxProtect(const char *Cmd) {
if (gotnewpwd == false) if (gotnewpwd == false)
return usage_t55xx_protect(); return usage_t55xx_protect();
if (errors || cmdp == 0) return usage_t55xx_protect(); if (errors || cmdp == 0) return usage_t55xx_protect();
// sanity check. // sanity check.
if (SanityOfflineCheck(false) != PM3_SUCCESS) if (SanityOfflineCheck(false) != PM3_SUCCESS)
return PM3_ESOFT; return PM3_ESOFT;
// lock // 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?"); PrintAndLogEx(WARNING, "Command failed. Did you run `lf t55xx detect` before?");
return PM3_ESOFT; return PM3_ESOFT;
} }

View file

@ -141,14 +141,14 @@ char *GetQ5ModulationStr(uint32_t id);
char *GetModulationStr(uint32_t id, bool xmode); char *GetModulationStr(uint32_t id, bool xmode);
char *GetModelStrFromCID(uint32_t cid); char *GetModelStrFromCID(uint32_t cid);
char *GetSelectedModulationStr(uint8_t id); char *GetSelectedModulationStr(uint8_t id);
char *GetDownlinkModeStr (uint8_t dlmode); char *GetDownlinkModeStr(uint8_t dlmode);
void printT5xxHeader(uint8_t page); void printT5xxHeader(uint8_t page);
void printT55xxBlock(uint8_t blockNum); void printT55xxBlock(uint8_t blockNum);
int printConfiguration(t55xx_conf_block_t b); int printConfiguration(t55xx_conf_block_t b);
bool t55xxAquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known_block0, bool verbose); 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 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 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); int T55xxReadBlockEx(uint8_t block, bool page1, bool usepwd, uint8_t override, uint32_t password, uint8_t downlink_mode, bool verbose);

View file

@ -89,7 +89,7 @@
"A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAgNHADBEAiAwfPqgIWIUB+QBBaVGsdHy\r\n" \ "A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAgNHADBEAiAwfPqgIWIUB+QBBaVGsdHy\r\n" \
"0s5RMxlkzpSX/zSyTZmUpQIgB2wJ6nZRM8oX/nA43Rh6SJovM2XwCCH//+LirBAb\r\n" \ "0s5RMxlkzpSX/zSyTZmUpQIgB2wJ6nZRM8oX/nA43Rh6SJovM2XwCCH//+LirBAb\r\n" \
"B0M=\r\n" \ "B0M=\r\n" \
"-----END CERTIFICATE-----\r\n" "-----END CERTIFICATE-----\r\n"
// FEITIAN FIDO2 // FEITIAN FIDO2
#define FEITIAN_FIDO2_CA \ #define FEITIAN_FIDO2_CA \
@ -104,7 +104,7 @@
"FEu9hyYRrRyJzwRYvnDSCIxrFiO3MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\r\n" \ "FEu9hyYRrRyJzwRYvnDSCIxrFiO3MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/\r\n" \
"BAQDAgEGMAoGCCqGSM49BAMCA0gAMEUCIDHSb2mbNDAUNXvpPU0oWKeNye0fQ2l9\r\n" \ "BAQDAgEGMAoGCCqGSM49BAMCA0gAMEUCIDHSb2mbNDAUNXvpPU0oWKeNye0fQ2l9\r\n" \
"D01AR2+sLZdhAiEAo3wz684IFMVsCCRmuJqxH6FQRESNqezuo1E+KkGxWuM=\r\n" \ "D01AR2+sLZdhAiEAo3wz684IFMVsCCRmuJqxH6FQRESNqezuo1E+KkGxWuM=\r\n" \
"-----END CERTIFICATE-----\r\n" "-----END CERTIFICATE-----\r\n"
// https://hypersecu.com/support/downloads // https://hypersecu.com/support/downloads
// HyperFIDO U2F Security Key Attestation CA // HyperFIDO U2F Security Key Attestation CA
@ -135,9 +135,9 @@
"FPFypmsIMAwGA1UdEwQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMC\r\n" \ "FPFypmsIMAwGA1UdEwQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMC\r\n" \
"A0kAMEYCIQCG2/ppMGt7pkcRie5YIohS3uDPIrmiRcTjqDclKVWg0gIhANcPNDZH\r\n" \ "A0kAMEYCIQCG2/ppMGt7pkcRie5YIohS3uDPIrmiRcTjqDclKVWg0gIhANcPNDZH\r\n" \
"E2/zZ+uB5ThG9OZus+xSb4knkrbAyXKX2zm/\r\n" \ "E2/zZ+uB5ThG9OZus+xSb4knkrbAyXKX2zm/\r\n" \
"-----END CERTIFICATE-----\r\n" "-----END CERTIFICATE-----\r\n"
// NXP // NXP
// https://fido-mds-parser.appspot.com/?url=https://mds.fidoalliance.org/metadata/JKP5CiDehdMMPwtG5i7to5 // https://fido-mds-parser.appspot.com/?url=https://mds.fidoalliance.org/metadata/JKP5CiDehdMMPwtG5i7to5
#define NXP_U2F_CA \ #define NXP_U2F_CA \
"-----BEGIN CERTIFICATE-----\r\n" \ "-----BEGIN CERTIFICATE-----\r\n" \
@ -151,8 +151,8 @@
"AJlr23jig2LxRM1PpgMAQXnZJy/HnkRB9O8KD0o2oK/mAiBG5EK1S3yVHdkkVGTJ\r\n" \ "AJlr23jig2LxRM1PpgMAQXnZJy/HnkRB9O8KD0o2oK/mAiBG5EK1S3yVHdkkVGTJ\r\n" \
"Q12ffuK8Op7Nx89cszCr0WyIhQ==\r\n" \ "Q12ffuK8Op7Nx89cszCr0WyIhQ==\r\n" \
"-----END CERTIFICATE-----\r\n" "-----END CERTIFICATE-----\r\n"
/* Concatenation of all additional CA certificates in PEM format if available */ /* Concatenation of all additional CA certificates in PEM format if available */
const char additional_ca_pem[] = GLOBALSIGN_CA YUBICO_CA SOLOKEY_CA \ 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); const size_t additional_ca_pem_len = sizeof(additional_ca_pem);

View file

@ -930,7 +930,7 @@ static int l_T55xx_readblock(lua_State *L) {
return returnToLuaWithError(L, "Failed to read config block"); 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."); PrintAndLogEx(NORMAL, "Safety Check: Could not detect if PWD bit is set in config block. Exits.");
return 0; return 0;
} else { } 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) { if (isok == false) {
return returnToLuaWithError(L, "Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'"); return returnToLuaWithError(L, "Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");
} }