mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
chg: lf em 410x_sim - reworked to NG\n chg: lf em 410x_demod - now can demod the simulation data.
This commit is contained in:
parent
a1db12bcae
commit
ad394a2d6b
11 changed files with 271 additions and 177 deletions
|
@ -822,7 +822,14 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
break;
|
||||
case CMD_SIMULATE_TAG_125K:
|
||||
LED_A_ON();
|
||||
SimulateTagLowFrequency(packet->oldarg[0], packet->oldarg[1], 1);
|
||||
struct p {
|
||||
uint16_t len;
|
||||
uint16_t gap;
|
||||
} PACKED;
|
||||
struct p *payload;
|
||||
payload = (struct p*)packet->data.asBytes;
|
||||
// length, start gap, led control
|
||||
SimulateTagLowFrequency(payload->len, payload->gap, 1);
|
||||
reply_ng(CMD_SIMULATE_TAG_125K, PM3_EOPABORTED, NULL, 0);
|
||||
LED_A_OFF();
|
||||
break;
|
||||
|
@ -1339,17 +1346,32 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
case CMD_UPLOAD_SIM_SAMPLES_125K: {
|
||||
// iceman; since changing fpga_bitstreams clears bigbuff, Its better to call it before.
|
||||
// to be able to use this one for uploading data to device
|
||||
// arg1 = 0 upload for LF usage
|
||||
// flag =
|
||||
// b0 0 upload for LF usage
|
||||
// 1 upload for HF usage
|
||||
#define FPGA_LF 1
|
||||
if (packet->oldarg[1] == FPGA_LF)
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
else
|
||||
// b1 0 skip
|
||||
// 1 clear bigbuff
|
||||
struct p {
|
||||
uint8_t flag;
|
||||
uint16_t offset;
|
||||
uint8_t *data;
|
||||
};
|
||||
struct p* payload = (struct p*)packet->data.asBytes;
|
||||
|
||||
|
||||
if ((payload->flag & 0x1) == 0x1)
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
else
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
|
||||
if ((payload->flag & 0x2) == 0x2) {
|
||||
BigBuf_Clear_ext(false);
|
||||
BigBuf_free();
|
||||
}
|
||||
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, PM3_CMD_DATA_SIZE);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
memcpy(mem + payload->offset, &payload->data, PM3_CMD_DATA_SIZE - 3);
|
||||
reply_ng(CMD_UPLOAD_SIM_SAMPLES_125K, PM3_SUCCESS, NULL, 0);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,7 @@ static int usage_lf_sniff(void) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "Usage: lf sniff [h]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h This help");
|
||||
PrintAndLogEx(NORMAL, " h This help");
|
||||
return 0;
|
||||
}
|
||||
static int usage_lf_config(void) {
|
||||
|
@ -427,11 +427,12 @@ int CmdLFSniff(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void ChkBitstream(const char *str) {
|
||||
static void ChkBitstream() {
|
||||
// convert to bitstream if necessary
|
||||
for (int i = 0; i < (int)(GraphTraceLen / 2); i++) {
|
||||
if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
|
||||
CmdGetBitStream("");
|
||||
PrintAndLogEx(INFO, " called cmdgetbitstream");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -442,36 +443,68 @@ int CmdLFSim(const char *Cmd) {
|
|||
#define FPGA_LF 1
|
||||
#define FPGA_HF 2
|
||||
|
||||
int gap = 0;
|
||||
sscanf(Cmd, "%i", &gap);
|
||||
uint16_t gap = param_get32ex(Cmd, 0, 0, 10) & 0xFFFF;
|
||||
|
||||
// convert to bitstream if necessary
|
||||
ChkBitstream(Cmd);
|
||||
ChkBitstream();
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Sending [%d bytes]\n", GraphTraceLen);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Uploading %d bytes", GraphTraceLen);
|
||||
|
||||
struct pupload {
|
||||
uint8_t flag;
|
||||
uint16_t offset;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE - 3];
|
||||
} PACKED;
|
||||
struct pupload payload_up;
|
||||
|
||||
// flag =
|
||||
// b0 0 upload for LF usage
|
||||
// 1 upload for HF usage
|
||||
// b1 0 skip
|
||||
// 1 clear bigbuff
|
||||
payload_up.flag |= 0x2;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
|
||||
//can send only 512 bits at a time (1 byte sent per bit...)
|
||||
for (uint16_t i = 0; i < GraphTraceLen; i += PM3_CMD_DATA_SIZE) {
|
||||
for (uint16_t i = 0; i < GraphTraceLen; i += PM3_CMD_DATA_SIZE - 3) {
|
||||
|
||||
size_t len = MIN((GraphTraceLen - i), PM3_CMD_DATA_SIZE - 3);
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_UPLOAD_SIM_SAMPLES_125K, i, FPGA_LF, 0, &GraphBuffer[i], PM3_CMD_DATA_SIZE);
|
||||
WaitForResponse(CMD_ACK, NULL);
|
||||
payload_up.offset = i;
|
||||
|
||||
for(uint16_t j = 0; j < len; j++)
|
||||
payload_up.data[j] = GraphBuffer[i+j];
|
||||
|
||||
SendCommandNG(CMD_UPLOAD_SIM_SAMPLES_125K, (uint8_t *)&payload_up, sizeof(struct pupload));
|
||||
WaitForResponse(CMD_UPLOAD_SIM_SAMPLES_125K, NULL);
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
|
||||
payload_up.flag = 0;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// Disable fast mode before last command
|
||||
conn.block_after_ACK = false;
|
||||
|
||||
PrintAndLogEx(NORMAL, "Simulating");
|
||||
PrintAndLogEx(INFO, "\nSimulating");
|
||||
|
||||
struct p {
|
||||
uint16_t len;
|
||||
uint16_t gap;
|
||||
} PACKED;
|
||||
struct p payload;
|
||||
payload.len = GraphTraceLen;
|
||||
payload.gap = gap;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_SIMULATE_TAG_125K, GraphTraceLen, gap, 0, NULL, 0);
|
||||
SendCommandNG(CMD_SIMULATE_TAG_125K, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_SIMULATE_TAG_125K, &resp);
|
||||
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
if (resp.status != PM3_EOPABORTED)
|
||||
return resp.status;
|
||||
return PM3_SUCCESS;
|
||||
|
@ -966,20 +999,20 @@ int CmdLFfind(const char *Cmd) {
|
|||
|
||||
//fsk
|
||||
if (GetFskClock("", false)) {
|
||||
if (FSKrawDemod("", true)) {
|
||||
if (FSKrawDemod("", true) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(NORMAL, "\nUnknown FSK Modulated Tag found!");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
bool st = true;
|
||||
if (ASKDemod_ext("0 0 0", true, false, 1, &st)) {
|
||||
if (ASKDemod_ext("0 0 0", true, false, 1, &st) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(NORMAL, "\nUnknown ASK Modulated and Manchester encoded Tag found!");
|
||||
PrintAndLogEx(NORMAL, "if it does not look right it could instead be ASK/Biphase - try " _YELLOW_("'data rawdemod ab'"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (CmdPSK1rawDemod("")) {
|
||||
if (CmdPSK1rawDemod("") == PM3_SUCCESS) {
|
||||
PrintAndLogEx(NORMAL, "Possible unknown PSK1 Modulated Tag found above!");
|
||||
PrintAndLogEx(NORMAL, " Could also be PSK2 - try " _YELLOW_("'data rawdemod p2'"));
|
||||
PrintAndLogEx(NORMAL, " Could also be PSK3 - [currently not supported]");
|
||||
|
@ -992,7 +1025,7 @@ int CmdLFfind(const char *Cmd) {
|
|||
out:
|
||||
// identify chipset
|
||||
CheckChipType(isOnline);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
|
@ -1044,5 +1077,5 @@ int CmdLF(const char *Cmd) {
|
|||
int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ static int usage_lf_em410x_demod(void) {
|
|||
PrintAndLogEx(NORMAL, " lf em 410x_demod 32 1 = demod an EM410x Tag ID from GraphBuffer using a clock of RF/32 and inverting data");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod 1 = demod an EM410x Tag ID from GraphBuffer while inverting data");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod 64 1 0 = demod an EM410x Tag ID from GraphBuffer using a clock of RF/64 and inverting data and allowing 0 demod errors");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Writes EM410x ID to a T55x7 / T5555 (Q5) tag");
|
||||
|
@ -42,7 +42,7 @@ static int usage_lf_em410x_write(void) {
|
|||
PrintAndLogEx(NORMAL, " <clock> - 16|32|40|64, optional, set R/F clock rate, defaults to 64");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_write 0F0368568B 1 = write ID to t55x7 card");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_ws(void) {
|
||||
PrintAndLogEx(NORMAL, "Watch 'nd Spoof, activates reader, waits until a EM410x tag gets presented then it starts simulating the found UID");
|
||||
|
@ -52,7 +52,7 @@ static int usage_lf_em410x_ws(void) {
|
|||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_spoof");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_sim(void) {
|
||||
PrintAndLogEx(NORMAL, "Simulating EM410x tag");
|
||||
|
@ -65,7 +65,7 @@ static int usage_lf_em410x_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_sim 0F0368568B");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_sim 0F0368568B 32");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_brute(void) {
|
||||
PrintAndLogEx(NORMAL, "Bruteforcing by emulating EM410x tag");
|
||||
|
@ -81,7 +81,7 @@ static int usage_lf_em410x_brute(void) {
|
|||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt c 32");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt d 3000");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt d 3000 c 32");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//////////////// 4050 / 4450 commands
|
||||
|
@ -95,7 +95,7 @@ static int usage_lf_em4x50_dump(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_dump");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_dump 11223344");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Read EM 4x50/EM4x69. Tag must be on antenna. ");
|
||||
|
@ -108,7 +108,7 @@ static int usage_lf_em4x50_read(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_read 1");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_read 1 11223344");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x50_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Write EM 4x50/4x69. Tag must be on antenna. ");
|
||||
|
@ -122,7 +122,7 @@ static int usage_lf_em4x50_write(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_write 1 deadc0de");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x50_write 1 deadc0de 11223344");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//////////////// 4205 / 4305 commands
|
||||
|
@ -136,7 +136,7 @@ static int usage_lf_em4x05_dump(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_dump");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_dump 11223344");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x05_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Read EM4x05/EM4x69. Tag must be on antenna. ");
|
||||
|
@ -149,7 +149,7 @@ static int usage_lf_em4x05_read(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_read 1");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_read 1 11223344");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x05_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Write EM4x05/4x69. Tag must be on antenna. ");
|
||||
|
@ -163,7 +163,7 @@ static int usage_lf_em4x05_write(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_write 1 deadc0de");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_write 1 deadc0de 11223344");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em4x05_info(void) {
|
||||
PrintAndLogEx(NORMAL, "Tag information EM4205/4305/4469//4569 tags. Tag must be on antenna.");
|
||||
|
@ -175,7 +175,7 @@ static int usage_lf_em4x05_info(void) {
|
|||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_info");
|
||||
PrintAndLogEx(NORMAL, " lf em 4x05_info deadc0de");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
/* Read the ID of an EM410x tag.
|
||||
|
@ -193,7 +193,11 @@ static void ConstructEM410xEmulGraph(const char *uid, const uint8_t clock) {
|
|||
int i, j, binary[4], parity[4];
|
||||
uint32_t n;
|
||||
/* clear our graph */
|
||||
ClearGraph(false);
|
||||
ClearGraph(true);
|
||||
|
||||
/* write 16 zero bit sledge */
|
||||
for (i = 0; i < 10; i++)
|
||||
AppendGraph(false, clock, 0);
|
||||
|
||||
/* write 9 start bits */
|
||||
for (i = 0; i < 9; i++)
|
||||
|
@ -239,7 +243,7 @@ void printEM410x(uint32_t hi, uint64_t id) {
|
|||
|
||||
if (!id && !hi) return;
|
||||
|
||||
PrintAndLogEx(SUCCESS, "EM410x %s pattern found", (hi) ? "XL" : "");
|
||||
PrintAndLogEx(SUCCESS, "EM410x%s pattern found", (hi) ? " XL " : "");
|
||||
|
||||
uint64_t n = 1;
|
||||
uint64_t id2lo = 0;
|
||||
|
@ -252,11 +256,11 @@ void printEM410x(uint32_t hi, uint64_t id) {
|
|||
|
||||
if (hi) {
|
||||
//output 88 bit em id
|
||||
PrintAndLogEx(NORMAL, "\nEM TAG ID : %06X%016" PRIX64, hi, id);
|
||||
PrintAndLogEx(NORMAL, "\nEM TAG ID : "_YELLOW_("%06X%016" PRIX64), hi, id);
|
||||
} else {
|
||||
//output 40 bit em id
|
||||
PrintAndLogEx(NORMAL, "\nEM TAG ID : %010" PRIX64, id);
|
||||
PrintAndLogEx(NORMAL, "\nPossible de-scramble patterns");
|
||||
PrintAndLogEx(NORMAL, "\nEM TAG ID : "_YELLOW_("%010" PRIX64), id);
|
||||
PrintAndLogEx(NORMAL, "\nPossible de-scramble patterns\n");
|
||||
PrintAndLogEx(NORMAL, "Unique TAG ID : %010" PRIX64, id2lo);
|
||||
PrintAndLogEx(NORMAL, "HoneyWell IdentKey {");
|
||||
PrintAndLogEx(NORMAL, "DEZ 8 : %08" PRIu64, id & 0xFFFFFF);
|
||||
|
@ -343,7 +347,7 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) {
|
|||
size_t size = sizeof(bits);
|
||||
if (!getDemodBuff(bits, &size)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Em410x problem during copy from ASK demod");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
int ans = Em410xDecode(bits, &size, &idx, hi, lo);
|
||||
|
@ -358,11 +362,11 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) {
|
|||
else if (ans == -6)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Em410x parity failed");
|
||||
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (!lo && !hi) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Em410x decoded to all zeros");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//set GraphBuffer for clone or sim command
|
||||
|
@ -376,11 +380,39 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) {
|
|||
if (verbose)
|
||||
printEM410x(*hi, *lo);
|
||||
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static bool isBitstream(void) {
|
||||
// convert to bitstream if necessary
|
||||
for (int i = 0; i < GraphTraceLen; i++) {
|
||||
if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
|
||||
bool st = true;
|
||||
if (!ASKDemod_ext(Cmd, false, false, 1, &st)) return 0;
|
||||
|
||||
// em410x simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again
|
||||
if ( isBitstream() ) {
|
||||
for (int i = 0; i < GraphTraceLen; i++) {
|
||||
if (GraphBuffer[i] == 1)
|
||||
GraphBuffer[i] = 127;
|
||||
else
|
||||
GraphBuffer[i] = -127;
|
||||
}
|
||||
uint8_t bits[GraphTraceLen];
|
||||
memset(bits, 0, sizeof(bits));
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
|
||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||
computeSignalProperties(bits, size);
|
||||
RepaintGraphWindow();
|
||||
}
|
||||
|
||||
if (ASKDemod_ext(Cmd, false, false, 1, &st) != PM3_SUCCESS)
|
||||
return PM3_ESOFT;
|
||||
return AskEm410xDecode(verbose, hi, lo);
|
||||
}
|
||||
/*
|
||||
|
@ -404,10 +436,11 @@ static int CmdEM410xDemod(const char *Cmd) {
|
|||
uint32_t hi = 0;
|
||||
uint64_t lo = 0;
|
||||
|
||||
if (AskEm410xDemod(Cmd, &hi, &lo, true) != 1) return 0;
|
||||
if (AskEm410xDemod(Cmd, &hi, &lo, true) != PM3_SUCCESS)
|
||||
return PM3_ESOFT;
|
||||
|
||||
g_em410xid = lo;
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// this read is the "normal" read, which download lf signal and tries to demod here.
|
||||
|
@ -424,19 +457,19 @@ static int CmdEM410xSim(const char *Cmd) {
|
|||
uint8_t uid[5] = {0x00};
|
||||
|
||||
/* clock is 64 in EM410x tags */
|
||||
uint8_t clock1 = 64;
|
||||
uint8_t clk = 64;
|
||||
|
||||
if (param_gethex(Cmd, 0, uid, 10)) {
|
||||
PrintAndLogEx(FAILED, "UID must include 10 HEX symbols");
|
||||
return 0;
|
||||
}
|
||||
|
||||
param_getdec(Cmd, 1, &clock1);
|
||||
param_getdec(Cmd, 1, &clk);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Starting simulating UID %02X%02X%02X%02X%02X clock: %d", uid[0], uid[1], uid[2], uid[3], uid[4], clock1);
|
||||
PrintAndLogEx(SUCCESS, "Starting simulating UID "_YELLOW_("%02X%02X%02X%02X%02X")"clock: "_YELLOW_("%d"), uid[0], uid[1], uid[2], uid[3], uid[4], clk);
|
||||
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation");
|
||||
|
||||
ConstructEM410xEmulGraph(Cmd, clock1);
|
||||
ConstructEM410xEmulGraph(Cmd, clk);
|
||||
|
||||
CmdLFSim("0"); //240 start_gap.
|
||||
return 0;
|
||||
|
@ -470,18 +503,18 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
int filelen = param_getstr(Cmd, 0, filename, FILE_PATH_SIZE);
|
||||
if (filelen == 0) {
|
||||
PrintAndLogEx(WARNING, "Error: Please specify a filename");
|
||||
return 1;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if ((f = fopen(filename, "r")) == NULL) {
|
||||
PrintAndLogEx(WARNING, "Error: Could not open UIDs file [%s]", filename);
|
||||
return 1;
|
||||
PrintAndLogEx(WARNING, "Error: Could not open UIDs file ["_YELLOW_("%s")"]", filename);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
uidBlock = calloc(stUidBlock, 5);
|
||||
if (uidBlock == NULL) {
|
||||
fclose(f);
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
|
@ -495,7 +528,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
PrintAndLogEx(FAILED, "UIDs must include 10 HEX symbols");
|
||||
free(uidBlock);
|
||||
fclose(f);
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
buf[10] = 0;
|
||||
|
@ -506,7 +539,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "Cannot allocate memory for UIDs");
|
||||
free(uidBlock);
|
||||
fclose(f);
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
uidBlock = p;
|
||||
}
|
||||
|
@ -521,10 +554,10 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
if (uidcnt == 0) {
|
||||
PrintAndLogEx(FAILED, "No UIDs found in file");
|
||||
free(uidBlock);
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Loaded %d UIDs from %s, pause delay: %d ms", uidcnt, filename, delay);
|
||||
PrintAndLogEx(SUCCESS, "Loaded "_YELLOW_("%d")" UIDs from "_YELLOW_("%s")", pause delay:"_YELLOW_("%d")"ms", uidcnt, filename, delay);
|
||||
|
||||
// loop
|
||||
for (uint32_t c = 0; c < uidcnt; ++c) {
|
||||
|
@ -536,7 +569,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
(void)gc;
|
||||
PrintAndLogEx(WARNING, "\nAborted via keyboard!\n");
|
||||
free(uidBlock);
|
||||
return 0;
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
||||
sprintf(testuid, "%010" PRIX64, bytes_to_num(uidBlock + 5 * c, 5));
|
||||
|
@ -550,7 +583,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
|||
}
|
||||
|
||||
free(uidBlock);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
/* Function is equivalent of lf read + data samples + em410xread
|
||||
|
@ -575,8 +608,8 @@ static int CmdEM410xWatch(const char *Cmd) {
|
|||
}
|
||||
lf_read(true, 8201);
|
||||
|
||||
} while (!CmdEM410xRead(""));
|
||||
return 0;
|
||||
} while (CmdEM410xRead("") != PM3_SUCCESS);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//currently only supports manchester modulations
|
||||
|
@ -587,9 +620,9 @@ static int CmdEM410xWatchnSpoof(const char *Cmd) {
|
|||
|
||||
// loops if the captured ID was in XL-format.
|
||||
CmdEM410xWatch(Cmd);
|
||||
PrintAndLogEx(SUCCESS, "# Replaying captured ID: %010" PRIx64, g_em410xid);
|
||||
PrintAndLogEx(SUCCESS, "# Replaying captured ID: "_YELLOW_("%010" PRIx64), g_em410xid);
|
||||
CmdLFaskSim("");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdEM410xWrite(const char *Cmd) {
|
||||
|
@ -605,21 +638,21 @@ static int CmdEM410xWrite(const char *Cmd) {
|
|||
// Check ID
|
||||
if (id == 0xFFFFFFFFFFFFFFFF) {
|
||||
PrintAndLogEx(WARNING, "Error! ID is required.\n");
|
||||
return 0;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (id >= 0x10000000000) {
|
||||
PrintAndLogEx(WARNING, "Error! Given EM410x ID is longer than 40 bits.\n");
|
||||
return 0;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// Check Card
|
||||
if (card == 0xFF) {
|
||||
PrintAndLogEx(WARNING, "Error! Card type required.\n");
|
||||
return 0;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (card < 0) {
|
||||
PrintAndLogEx(WARNING, "Error! Bad card type selected.\n");
|
||||
return 0;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// Check Clock
|
||||
|
@ -628,8 +661,8 @@ static int CmdEM410xWrite(const char *Cmd) {
|
|||
|
||||
// Allowed clock rates: 16, 32, 40 and 64
|
||||
if ((clock1 != 16) && (clock1 != 32) && (clock1 != 64) && (clock1 != 40)) {
|
||||
PrintAndLogEx(WARNING, "Error! Clock rate %d not valid. Supported clock rates are 16, 32, 40 and 64.\n", clock1);
|
||||
return 0;
|
||||
PrintAndLogEx(WARNING, "Error! Clock rate" _YELLOW_("%d")" not valid. Supported clock rates are 16, 32, 40 and 64.\n", clock1);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (card == 1) {
|
||||
|
@ -644,11 +677,11 @@ static int CmdEM410xWrite(const char *Cmd) {
|
|||
card = (card & 0xFF) | ((clock1 << 8) & 0xFF00);
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, "Error! Bad card type selected.\n");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
SendCommandMIX(CMD_EM410X_WRITE_TAG, card, (uint32_t)(id >> 32), (uint32_t)id, NULL, 0);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//**************** Start of EM4x50 Code ************************
|
||||
|
@ -961,13 +994,13 @@ static int CmdEM4x50Write(const char *Cmd) {
|
|||
uint8_t ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_lf_em4x50_write();
|
||||
PrintAndLogEx(NORMAL, "no implemented yet");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int CmdEM4x50Dump(const char *Cmd) {
|
||||
uint8_t ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_lf_em4x50_dump();
|
||||
PrintAndLogEx(NORMAL, "no implemented yet");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
#define EM_PREAMBLE_LEN 6
|
||||
|
@ -1016,13 +1049,13 @@ static bool doPreambleSearch(size_t *startIdx) {
|
|||
|
||||
static bool detectFSK() {
|
||||
// detect fsk clock
|
||||
if (!GetFskClock("", false)) {
|
||||
if (GetFskClock("", false) == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: FSK clock failed");
|
||||
return false;
|
||||
}
|
||||
// demod
|
||||
int ans = FSKrawDemod("0 0", false);
|
||||
if (!ans) {
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: FSK Demod failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -1038,12 +1071,12 @@ static bool detectPSK() {
|
|||
//demod
|
||||
//try psk1 -- 0 0 6 (six errors?!?)
|
||||
ans = PSKDemod("0 0 6", false);
|
||||
if (!ans) {
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK1 Demod failed");
|
||||
|
||||
//try psk1 inverted
|
||||
ans = PSKDemod("0 1 6", false);
|
||||
if (!ans) {
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK1 inverted Demod failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -1055,7 +1088,7 @@ static bool detectPSK() {
|
|||
// try manchester - NOTE: ST only applies to T55x7 tags.
|
||||
static bool detectASK_MAN() {
|
||||
bool stcheck = false;
|
||||
if (!ASKDemod_ext("0 0 0", false, false, 1, &stcheck)) {
|
||||
if (ASKDemod_ext("0 0 0", false, false, 1, &stcheck) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/Manchester Demod failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -1064,11 +1097,11 @@ static bool detectASK_MAN() {
|
|||
|
||||
static bool detectASK_BI() {
|
||||
int ans = ASKbiphaseDemod("0 0 1", false);
|
||||
if (!ans) {
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase normal demod failed");
|
||||
|
||||
ans = ASKbiphaseDemod("0 1 1", false);
|
||||
if (!ans) {
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase inverted demod failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -1130,10 +1163,10 @@ static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t
|
|||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(DEBUG, "timeout while waiting for reply.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
if (!downloadSamplesEM()) {
|
||||
return -1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
return demodEM4x05resp(word);
|
||||
|
|
|
@ -33,7 +33,7 @@ static int usage_lf_indala_demod(void) {
|
|||
PrintAndLogEx(NORMAL, " lf indala demod 32 = demod a Indala tag from GraphBuffer using a clock of RF/32");
|
||||
PrintAndLogEx(NORMAL, " lf indala demod 32 1 = demod a Indala tag from GraphBuffer using a clock of RF/32 and inverting data");
|
||||
PrintAndLogEx(NORMAL, " lf indala demod 64 1 0 = demod a Indala tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_indala_sim(void) {
|
||||
|
@ -47,7 +47,7 @@ static int usage_lf_indala_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf indala sim deadc0de");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// Indala 26 bit decode
|
||||
|
@ -64,9 +64,9 @@ static int CmdIndalaDemod(const char *Cmd) {
|
|||
else
|
||||
ans = PSKDemod("32", true);
|
||||
|
||||
if (!ans) {
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Indala can't demod signal: %d", ans);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
uint8_t invert = 0;
|
||||
|
@ -83,7 +83,7 @@ static int CmdIndalaDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Indala: size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Indala: error demoding psk idx: %d", idx);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, size, idx);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock));
|
||||
|
@ -160,7 +160,7 @@ static int CmdIndalaDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Indala - printing demodbuffer");
|
||||
printDemodBuff();
|
||||
}
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// older alternative indala demodulate (has some positives and negatives)
|
||||
|
@ -223,7 +223,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Recovered %d raw bits, expected: %d", rawbit, GraphTraceLen / 32);
|
||||
PrintAndLogEx(INFO, "worst metric (0=best..7=worst): %d at pos %d", worst, worstPos);
|
||||
} else {
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// Finding the start of a UID
|
||||
|
@ -252,7 +252,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
|
||||
if (start == rawbit - uidlen + 1) {
|
||||
PrintAndLogEx(FAILED, "nothing to wait for");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// Inverting signal if needed
|
||||
|
@ -278,7 +278,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
}
|
||||
showbits[bit + 1] = '\0';
|
||||
PrintAndLogEx(SUCCESS, "Partial UID | %s", showbits);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
for (bit = 0; bit < uidlen; bit++) {
|
||||
bits[bit] = rawbits[i++];
|
||||
|
@ -358,7 +358,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
}
|
||||
|
||||
RepaintGraphWindow();
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// this read is the "normal" read, which download lf signal and tries to demod here.
|
||||
|
@ -457,7 +457,7 @@ static int CmdIndalaClone(const char *Cmd) {
|
|||
SendCommandOLD(CMD_INDALA_CLONE_TAG, 0, 0, 0, datawords, sizeof(datawords));
|
||||
}
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
|
@ -473,7 +473,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 CmdLFINDALA(const char *Cmd) {
|
||||
|
|
|
@ -21,7 +21,7 @@ static int usage_lf_keri_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf keri clone 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_keri_sim(void) {
|
||||
|
@ -35,15 +35,15 @@ static int usage_lf_keri_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf keri sim 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdKeriDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
|
||||
if (!PSKDemod("", false)) {
|
||||
if (PSKDemod("", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - KERI: PSK1 Demod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
bool invert = false;
|
||||
size_t size = DemodBufferLen;
|
||||
|
@ -58,7 +58,7 @@ static int CmdKeriDemod(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - KERI: ans: %d", idx);
|
||||
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, size, idx);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock));
|
||||
|
@ -95,7 +95,7 @@ static int CmdKeriDemod(const char *Cmd) {
|
|||
|
||||
CmdPrintDemodBuff("x");
|
||||
}
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdKeriRead(const char *Cmd) {
|
||||
|
@ -165,11 +165,11 @@ static int CmdKeriClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdKeriSim(const char *Cmd) {
|
||||
|
@ -214,7 +214,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 CmdLFKeri(const char *Cmd) {
|
||||
|
|
|
@ -15,9 +15,9 @@ static int CmdHelp(const char *Cmd);
|
|||
static int CmdNexWatchDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
|
||||
if (!PSKDemod("", false)) {
|
||||
if (PSKDemod("", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch can't demod signal");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
bool invert = false;
|
||||
size_t size = DemodBufferLen;
|
||||
|
@ -36,7 +36,7 @@ static int CmdNexWatchDemod(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch error %d", idx);
|
||||
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
setDemodBuff(DemodBuffer, size, idx + 4);
|
||||
|
@ -64,7 +64,7 @@ static int CmdNexWatchDemod(const char *Cmd) {
|
|||
}
|
||||
|
||||
CmdPrintDemodBuff("x");
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//by marshmellow
|
||||
|
@ -84,7 +84,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 CmdLFNEXWATCH(const char *Cmd) {
|
||||
|
|
|
@ -22,7 +22,7 @@ static int usage_lf_noralsy_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf noralsy clone 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_noralsy_sim(void) {
|
||||
|
@ -37,7 +37,7 @@ static int usage_lf_noralsy_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf noralsy sim 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t noralsy_chksum(uint8_t *bits, uint8_t len) {
|
||||
|
@ -53,13 +53,13 @@ static int CmdNoralsyDemod(const char *Cmd) {
|
|||
|
||||
//ASK / Manchester
|
||||
bool st = true;
|
||||
if (!ASKDemod_ext("32 0 0", false, false, 1, &st)) {
|
||||
if (ASKDemod_ext("32 0 0", false, false, 1, &st) != PM3_SUCCESS) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: ASK/Manchester Demod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (!st) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: sequence terminator not found");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
|
@ -75,7 +75,7 @@ static int CmdNoralsyDemod(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: ans: %d", ans);
|
||||
}
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
@ -103,11 +103,11 @@ static int CmdNoralsyDemod(const char *Cmd) {
|
|||
// test checksums
|
||||
if (chk1 != calc1) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: checksum 1 failed %x - %x\n", chk1, calc1);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (chk2 != calc2) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: checksum 2 failed %x - %x\n", chk2, calc2);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Noralsy Tag Found: Card ID %u, Year: %u Raw: %08X%08X%08X", cardid, year, raw1, raw2, raw3);
|
||||
|
@ -115,7 +115,7 @@ static int CmdNoralsyDemod(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "Unknown bits set in first block! Expected 0xBB0214FF, Found: 0x%08X", raw1);
|
||||
PrintAndLogEx(WARNING, "Please post this output in forum to further research on this format");
|
||||
}
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdNoralsyRead(const char *Cmd) {
|
||||
|
@ -141,9 +141,9 @@ static int CmdNoralsyClone(const char *Cmd) {
|
|||
if (param_getchar(Cmd, 2) == 'Q' || param_getchar(Cmd, 2) == 'q')
|
||||
blocks[0] = T5555_MODULATION_MANCHESTER | T5555_SET_BITRATE(32) | T5555_ST_TERMINATOR | 3 << T5555_MAXBLOCK_SHIFT;
|
||||
|
||||
if (!getnoralsyBits(id, year, bits)) {
|
||||
if (getnoralsyBits(id, year, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -173,10 +173,10 @@ static int CmdNoralsyClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdNoralsySim(const char *Cmd) {
|
||||
|
@ -188,16 +188,17 @@ static int CmdNoralsySim(const char *Cmd) {
|
|||
uint32_t id = 0;
|
||||
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_noralsy_sim();
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H')
|
||||
return usage_lf_noralsy_sim();
|
||||
|
||||
id = param_get32ex(Cmd, 0, 0, 10);
|
||||
year = param_get32ex(Cmd, 1, 2000, 10);
|
||||
|
||||
uint8_t clk = 32, encoding = 1, separator = 1, invert = 0;
|
||||
|
||||
if (!getnoralsyBits(id, year, bits)) {
|
||||
if (getnoralsyBits(id, year, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Noralsy - CardId: %u", id);
|
||||
|
@ -223,7 +224,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 CmdLFNoralsy(const char *Cmd) {
|
||||
|
@ -256,7 +257,7 @@ int getnoralsyBits(uint32_t id, uint16_t year, uint8_t *bits) {
|
|||
num_to_bytebits(chksum, 4, bits + 72);
|
||||
chksum = noralsy_chksum(bits, 76);
|
||||
num_to_bytebits(chksum, 4, bits + 76);
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// by iceman
|
||||
|
|
|
@ -21,7 +21,7 @@ static int usage_lf_presco_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf presco clone d 123456789");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_presco_sim(void) {
|
||||
|
@ -37,16 +37,16 @@ static int usage_lf_presco_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf presco sim d 123456789");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//see ASKDemod for what args are accepted
|
||||
static int CmdPrescoDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
bool st = true;
|
||||
if (!ASKDemod_ext("32 0 0 0 0 a", false, false, 1, &st)) {
|
||||
if (ASKDemod_ext("32 0 0 0 0 a", false, false, 1, &st) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error Presco ASKDemod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectPresco(DemodBuffer, &size);
|
||||
|
@ -59,7 +59,7 @@ static int CmdPrescoDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Presco: Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Presco: ans: %d", ans);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 128, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
@ -78,7 +78,7 @@ static int CmdPrescoDemod(const char *Cmd) {
|
|||
sprintf(cmd, "H %08X", cardid);
|
||||
getWiegandFromPresco(cmd, &sitecode, &usercode, &fullcode, &Q5);
|
||||
PrintAndLogEx(SUCCESS, "SiteCode %u, UserCode %u, FullCode, %08X", sitecode, usercode, fullcode);
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//see ASKDemod for what args are accepted
|
||||
|
@ -139,10 +139,10 @@ static int CmdPrescoClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// takes base 12 ID converts to hex
|
||||
|
@ -151,7 +151,8 @@ static int CmdPrescoSim(const char *Cmd) {
|
|||
uint32_t sitecode = 0, usercode = 0, fullcode = 0;
|
||||
bool Q5 = false;
|
||||
// get wiegand from printed number.
|
||||
if (getWiegandFromPresco(Cmd, &sitecode, &usercode, &fullcode, &Q5) == -1) return usage_lf_presco_sim();
|
||||
if (getWiegandFromPresco(Cmd, &sitecode, &usercode, &fullcode, &Q5) == -1)
|
||||
return usage_lf_presco_sim();
|
||||
|
||||
uint8_t clk = 32, encoding = 1, separator = 1, invert = 0;
|
||||
|
||||
|
@ -178,7 +179,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 CmdLFPresco(const char *Cmd) {
|
||||
|
|
|
@ -17,11 +17,13 @@ static int CmdSecurakeyDemod(const char *Cmd) {
|
|||
|
||||
//ASK / Manchester
|
||||
bool st = false;
|
||||
if (!ASKDemod_ext("40 0 0", false, false, 1, &st)) {
|
||||
if (ASKDemod_ext("40 0 0", false, false, 1, &st) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ASK/Manchester Demod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (st) return 0;
|
||||
if (st)
|
||||
return PM3_ESOFT;
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectSecurakey(DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
|
@ -33,7 +35,7 @@ static int CmdSecurakeyDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ans: %d", ans);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
@ -69,7 +71,7 @@ static int CmdSecurakeyDemod(const char *Cmd) {
|
|||
uint32_t fc = 0, lWiegand = 0, rWiegand = 0;
|
||||
if (bitLen > 40) { //securakey's max bitlen is 40 bits...
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error bitLen too long: %u", bitLen);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
// get left 1/2 wiegand & right 1/2 wiegand (for parity test and wiegand print)
|
||||
lWiegand = bytebits_to_byte(bits_no_spacer + 48 - bitLen, bitLen / 2);
|
||||
|
@ -91,7 +93,7 @@ static int CmdSecurakeyDemod(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "\nHow the FC translates to printed FC is unknown");
|
||||
PrintAndLogEx(INFO, "How the checksum is calculated is unknown");
|
||||
PrintAndLogEx(INFO, "Help the community identify this format further\n by sharing your tag on the pm3 forum or with forum members");
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdSecurakeyRead(const char *Cmd) {
|
||||
|
@ -111,7 +113,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 CmdLFSecurakey(const char *Cmd) {
|
||||
|
|
|
@ -493,14 +493,14 @@ bool DecodeT55xxBlock(void) {
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
return (bool) ans;
|
||||
return (ans == PM3_SUCCESS);
|
||||
}
|
||||
|
||||
static bool DecodeT5555TraceBlock(void) {
|
||||
DemodBufferLen = 0x00;
|
||||
|
||||
// According to datasheet. Always: RF/64, not inverted, Manchester
|
||||
return (bool) ASKDemod("64 0 1", false, false, 1);
|
||||
return (ASKDemod("64 0 1", false, false, 1) == PM3_SUCCESS);
|
||||
}
|
||||
|
||||
// sanity check. Don't use proxmark if it is offline and you didn't specify useGraphbuf
|
||||
|
@ -597,7 +597,7 @@ bool tryDetectModulation(void) {
|
|||
// false = no emSearch
|
||||
// 1 = Ask/Man
|
||||
// st = true
|
||||
if (ASKDemod_ext("0 0 1", false, false, 1, &tests[hits].ST) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ((ASKDemod_ext("0 0 1", false, false, 1, &tests[hits].ST) == PM3_SUCCESS) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_ASK;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
|
@ -610,7 +610,7 @@ bool tryDetectModulation(void) {
|
|||
// false = no emSearch
|
||||
// 1 = Ask/Man
|
||||
// st = true
|
||||
if (ASKDemod_ext("0 1 1", false, false, 1, &tests[hits].ST) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ((ASKDemod_ext("0 1 1", false, false, 1, &tests[hits].ST) == PM3_SUCCESS) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_ASK;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
|
@ -661,7 +661,7 @@ bool tryDetectModulation(void) {
|
|||
save_restoreGB(GRAPH_SAVE);
|
||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
CmdLtrim("160");
|
||||
if (PSKDemod("0 0 6", false) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ( (PSKDemod("0 0 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK1;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
|
@ -669,7 +669,7 @@ bool tryDetectModulation(void) {
|
|||
tests[hits].ST = false;
|
||||
++hits;
|
||||
}
|
||||
if (PSKDemod("0 1 6", false) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
if ((PSKDemod("0 1 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK1;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
|
@ -679,7 +679,7 @@ bool tryDetectModulation(void) {
|
|||
}
|
||||
//ICEMAN: are these PSKDemod calls needed?
|
||||
// PSK2 - needs a call to psk1TOpsk2.
|
||||
if (PSKDemod("0 0 6", false)) {
|
||||
if (PSKDemod("0 0 6", false) == PM3_SUCCESS) {
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK2;
|
||||
|
@ -691,7 +691,7 @@ bool tryDetectModulation(void) {
|
|||
}
|
||||
} // inverse waves does not affect this demod
|
||||
// PSK3 - needs a call to psk1TOpsk2.
|
||||
if (PSKDemod("0 0 6", false)) {
|
||||
if (PSKDemod("0 0 6", false) == PM3_SUCCESS) {
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK3;
|
||||
|
@ -1041,7 +1041,7 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
|
|||
case 'b':
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &block);
|
||||
cmdp += 2;
|
||||
|
||||
|
||||
if (block > 7) {
|
||||
PrintAndLogEx(WARNING, "Block number must be between 0 and 7");
|
||||
errors = true;
|
||||
|
@ -1085,14 +1085,14 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Writing page %d block: %02d data: 0x%08X %s", page1, block, data, (usepwd) ? pwdStr : "");
|
||||
|
||||
clearCommandBuffer();
|
||||
|
||||
|
||||
/*
|
||||
OLD style
|
||||
arg0 = data, (4 bytes)
|
||||
arg1 = block (1 byte)
|
||||
arg2 = password (4 bytes)
|
||||
flags = data[0] (1 byte)
|
||||
|
||||
|
||||
new style
|
||||
uses struct in pm3_cmd.h
|
||||
*/
|
||||
|
@ -1101,7 +1101,7 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
|
|||
ng.pwd = password;
|
||||
ng.blockno = block;
|
||||
ng.flags = flags;
|
||||
|
||||
|
||||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not ACK write operation. (May be due to old firmware)");
|
||||
|
@ -2148,13 +2148,13 @@ bool tryDetectP1(bool getData) {
|
|||
// try ask clock detect. it could be another type even if successful.
|
||||
clk = GetAskClock("", false);
|
||||
if (clk > 0) {
|
||||
if (ASKDemod_ext("0 0 1", false, false, 1, &st) &&
|
||||
if ((ASKDemod_ext("0 0 1", false, false, 1, &st) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
st = true;
|
||||
if (ASKDemod_ext("0 1 1", false, false, 1, &st) &&
|
||||
if ((ASKDemod_ext("0 1 1", false, false, 1, &st) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
return true;
|
||||
|
@ -2194,20 +2194,20 @@ bool tryDetectP1(bool getData) {
|
|||
// save_restoreGB(GRAPH_SAVE);
|
||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
//CmdLtrim("160");
|
||||
if (PSKDemod("0 0 6", false) &&
|
||||
if ((PSKDemod("0 0 6", false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
//save_restoreGB(GRAPH_RESTORE);
|
||||
return true;
|
||||
}
|
||||
if (PSKDemod("0 1 6", false) &&
|
||||
if ((PSKDemod("0 1 6", false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
//save_restoreGB(GRAPH_RESTORE);
|
||||
return true;
|
||||
}
|
||||
// PSK2 - needs a call to psk1TOpsk2.
|
||||
if (PSKDemod("0 0 6", false)) {
|
||||
if (PSKDemod("0 0 6", false) == PM3_SUCCESS) {
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
if (preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
|
|
|
@ -25,7 +25,7 @@ static int usage_lf_visa2k_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf visa2000 clone 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_visa2k_sim(void) {
|
||||
|
@ -39,7 +39,7 @@ static int usage_lf_visa2k_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf visa2000 sim 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t visa_chksum(uint32_t id) {
|
||||
|
@ -90,10 +90,10 @@ static int CmdVisa2kDemod(const char *Cmd) {
|
|||
|
||||
//ASK / Manchester
|
||||
bool st = true;
|
||||
if (!ASKDemod_ext("64 0 0", false, false, 1, &st)) {
|
||||
if (ASKDemod_ext("64 0 0", false, false, 1, &st) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ASK/Manchester Demod failed");
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectVisa2k(DemodBuffer, &size);
|
||||
|
@ -108,7 +108,7 @@ static int CmdVisa2kDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ans: %d", ans);
|
||||
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
@ -126,7 +126,7 @@ static int CmdVisa2kDemod(const char *Cmd) {
|
|||
if (chk != calc) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: error: Visa2000 checksum failed %x - %x\n", chk, calc);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
// parity
|
||||
uint8_t calc_par = visa_parity(raw2);
|
||||
|
@ -134,10 +134,10 @@ static int CmdVisa2kDemod(const char *Cmd) {
|
|||
if (calc_par != chk_par) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: error: Visa2000 parity failed %x - %x\n", chk_par, calc_par);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Visa2000 Tag Found: Card ID %u, Raw: %08X%08X%08X", raw2, raw1, raw2, raw3);
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// 64*96*2=12288 samples just in case we just missed the first preamble we can still catch 2 of them
|
||||
|
@ -152,7 +152,8 @@ static int CmdVisa2kClone(const char *Cmd) {
|
|||
uint32_t blocks[4] = {T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_64 | T55x7_ST_TERMINATOR | 3 << T55x7_MAXBLOCK_SHIFT, BL0CK1, 0};
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_visa2k_clone();
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h')
|
||||
return usage_lf_visa2k_clone();
|
||||
|
||||
id = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
|
@ -186,17 +187,18 @@ static int CmdVisa2kClone(const char *Cmd) {
|
|||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdVisa2kSim(const char *Cmd) {
|
||||
|
||||
uint32_t id = 0;
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_visa2k_sim();
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H')
|
||||
return usage_lf_visa2k_sim();
|
||||
|
||||
id = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
|
@ -231,7 +233,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 CmdLFVisa2k(const char *Cmd) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue