chg: lf t55 - fixes / read block uses NG

This commit is contained in:
iceman1001
2019-05-22 11:59:39 -04:00
parent 150fc205b2
commit 794d109f30
5 changed files with 52 additions and 39 deletions

View File

@@ -34,7 +34,7 @@ static int usage_lf_paradox_sim(void) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf paradox sim 123 11223");
return 0;
return PM3_SUCCESS;
}
//by marshmellow
@@ -47,7 +47,7 @@ static int CmdParadoxDemod(const char *Cmd) {
size_t size = getFromGraphBuf(bits);
if (size == 0) {
PrintAndLogEx(DEBUG, "DEBUG: Error - Paradox not enough samples");
return 0;
return PM3_ESOFT;
}
uint32_t hi2 = 0, hi = 0, lo = 0;
@@ -69,7 +69,7 @@ static int CmdParadoxDemod(const char *Cmd) {
else
PrintAndLogEx(DEBUG, "DEBUG: Error - Paradox error demoding fsk %d", idx);
return 0;
return PM3_ESOFT;
}
setDemodBuff(bits, size, idx);
@@ -77,7 +77,7 @@ static int CmdParadoxDemod(const char *Cmd) {
if (hi2 == 0 && hi == 0 && lo == 0) {
PrintAndLogEx(DEBUG, "DEBUG: Error - Paradox no value found");
return 0;
return PM3_ESOFT;
}
uint32_t fc = ((hi & 0x3) << 6) | (lo >> 26);
@@ -100,7 +100,7 @@ static int CmdParadoxDemod(const char *Cmd) {
if (g_debugMode)
printDemodBuff();
return 1;
return PM3_SUCCESS;
}
//by marshmellow
//see ASKDemod for what args are accepted
@@ -127,7 +127,7 @@ static int CmdParadoxSim(const char *Cmd) {
facilitycode = (fc & 0x000000FF);
cardnumber = (cn & 0x0000FFFF);
// if ( !GetParadoxBits(facilitycode, cardnumber, bs)) {
// if ( GetParadoxBits(facilitycode, cardnumber, bs) != PM3_SUCCESS) {
// PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
// return 1;
// }
@@ -157,7 +157,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 CmdLFParadox(const char *Cmd) {

View File

@@ -541,7 +541,7 @@ static int CmdT55xxDetect(const char *Cmd) {
if (errors) return usage_t55xx_detect();
// sanity check.
if (!SanityOfflineCheck(useGB)) return PM3_ENODATA;
if (SanityOfflineCheck(useGB) != PM3_SUCCESS) return PM3_ENODATA;
if (!useGB) {
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password))
@@ -1116,7 +1116,7 @@ static int CmdT55xxReadTrace(const char *Cmd) {
if (strlen(Cmd) == 0) {
// sanity check.
if (!SanityOfflineCheck(false)) return PM3_ENODATA;
if (SanityOfflineCheck(false) != PM3_SUCCESS) return PM3_ENODATA;
bool pwdmode = false;
uint32_t password = 0;
@@ -1397,7 +1397,7 @@ static int CmdT55xxInfo(const char *Cmd) {
if (!frombuff && !gotdata) {
// sanity check.
if (!SanityOfflineCheck(false)) return PM3_ENODATA;
if (SanityOfflineCheck(false) != PM3_SUCCESS) return PM3_ENODATA;
bool pwdmode = false;
uint32_t password = 0;
@@ -1521,14 +1521,26 @@ static int CmdT55xxDump(const char *Cmd) {
bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
// arg0 bitmodes:
// bit0 = pwdmode
// bit1 = page to read from
// b0 = pwdmode
// b1 = page to read from
// b2 = brute_mem (armside function)
// arg1: which block to read
// arg2: password
uint8_t arg0 = (page << 1 | (pwdmode));
struct p {
uint32_t password;
uint8_t blockno;
uint8_t page;
bool pwdmode;
} PACKED;
struct p payload;
payload.password = password;
payload.blockno = block;
payload.page = page & 0x1;
payload.pwdmode = pwdmode;
clearCommandBuffer();
SendCommandMIX(CMD_T55XX_READ_BLOCK, arg0, block, password, NULL, 0);
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2500)) {
SendCommandNG(CMD_T55XX_READ_BLOCK, (uint8_t*)&payload, sizeof(payload));
if (!WaitForResponseTimeout(CMD_T55XX_READ_BLOCK, NULL, 2500)) {
PrintAndLogEx(WARNING, "command execution time out");
return false;
}