mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
rename globals DemodBuffer and DemodBufferLen
This commit is contained in:
parent
45d4d361e9
commit
e4fbfe0f40
34 changed files with 445 additions and 445 deletions
|
@ -23,7 +23,7 @@
|
|||
#include "crc32.h" // crc32_ex
|
||||
#include "tea.h"
|
||||
#include "legic_prng.h"
|
||||
#include "cmddata.h" // demodbuffer
|
||||
#include "cmddata.h" // g_DemodBuffer
|
||||
#include "graph.h"
|
||||
#include "proxgui.h"
|
||||
#include "cliparser.h"
|
||||
|
@ -936,7 +936,7 @@ static int CmdAnalyseNuid(const char *Cmd) {
|
|||
static int CmdAnalyseDemodBuffer(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "analyse demodbuff",
|
||||
"loads a binary string into demod buffer",
|
||||
"loads a binary string into DemodBuffer",
|
||||
"analyse demodbuff -d 0011101001001011"
|
||||
);
|
||||
|
||||
|
@ -959,9 +959,9 @@ static int CmdAnalyseDemodBuffer(const char *Cmd) {
|
|||
for (size_t i = 0; i <= strlen(s); i++) {
|
||||
char c = s[i];
|
||||
if (c == '1')
|
||||
DemodBuffer[i] = 1;
|
||||
g_DemodBuffer[i] = 1;
|
||||
if (c == '0')
|
||||
DemodBuffer[i] = 0;
|
||||
g_DemodBuffer[i] = 0;
|
||||
|
||||
PrintAndLogEx(NORMAL, "%c" NOLF, c);
|
||||
}
|
||||
|
@ -969,9 +969,9 @@ static int CmdAnalyseDemodBuffer(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
DemodBufferLen = len;
|
||||
g_DemodBufferLen = len;
|
||||
free(data);
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data print") "` to view demod buffer");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data print") "` to view DemodBuffer");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ static command_t CommandTable[] = {
|
|||
{"lfsr", CmdAnalyseLfsr, AlwaysAvailable, "LFSR tests"},
|
||||
{"a", CmdAnalyseA, AlwaysAvailable, "num bits test"},
|
||||
{"nuid", CmdAnalyseNuid, AlwaysAvailable, "create NUID from 7byte UID"},
|
||||
{"demodbuff", CmdAnalyseDemodBuffer, AlwaysAvailable, "Load binary string to demodbuffer"},
|
||||
{"demodbuff", CmdAnalyseDemodBuffer, AlwaysAvailable, "Load binary string to DemodBuffer"},
|
||||
{"freq", CmdAnalyseFreq, AlwaysAvailable, "Calc wave lengths"},
|
||||
{"foo", CmdAnalyseFoo, AlwaysAvailable, "muxer"},
|
||||
{"units", CmdAnalyseUnits, AlwaysAvailable, "convert ETU <> US <> SSP_CLK (3.39MHz)"},
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
#include "cmdlft55xx.h" // print...
|
||||
#include "crypto/asn1utils.h" // ASN1 decode / print
|
||||
|
||||
uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
size_t DemodBufferLen = 0;
|
||||
uint8_t g_DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
size_t g_DemodBufferLen = 0;
|
||||
int32_t g_DemodStartIdx = 0;
|
||||
int g_DemodClock = 0;
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
//set the demod buffer with given array ofq binary (one bit per byte)
|
||||
//set the g_DemodBuffer with given array ofq binary (one bit per byte)
|
||||
//by marshmellow
|
||||
void setDemodBuff(uint8_t *buff, size_t size, size_t start_idx) {
|
||||
if (buff == NULL) return;
|
||||
|
@ -45,9 +45,9 @@ void setDemodBuff(uint8_t *buff, size_t size, size_t start_idx) {
|
|||
size = MAX_DEMOD_BUF_LEN - start_idx;
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
DemodBuffer[i] = buff[start_idx++];
|
||||
g_DemodBuffer[i] = buff[start_idx++];
|
||||
|
||||
DemodBufferLen = size;
|
||||
g_DemodBufferLen = size;
|
||||
}
|
||||
|
||||
bool getDemodBuff(uint8_t *buff, size_t *size) {
|
||||
|
@ -55,9 +55,9 @@ bool getDemodBuff(uint8_t *buff, size_t *size) {
|
|||
if (size == NULL) return false;
|
||||
if (*size == 0) return false;
|
||||
|
||||
*size = (*size > DemodBufferLen) ? DemodBufferLen : *size;
|
||||
*size = (*size > g_DemodBufferLen) ? g_DemodBufferLen : *size;
|
||||
|
||||
memcpy(buff, DemodBuffer, *size);
|
||||
memcpy(buff, g_DemodBuffer, *size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ static double compute_autoc(const int *data, size_t n, int lag) {
|
|||
}
|
||||
*/
|
||||
|
||||
// option '1' to save DemodBuffer any other to restore
|
||||
// option '1' to save g_DemodBuffer any other to restore
|
||||
void save_restoreDB(uint8_t saveOpt) {
|
||||
static uint8_t SavedDB[MAX_DEMOD_BUF_LEN];
|
||||
static size_t SavedDBlen;
|
||||
|
@ -149,15 +149,15 @@ void save_restoreDB(uint8_t saveOpt) {
|
|||
|
||||
if (saveOpt == GRAPH_SAVE) { //save
|
||||
|
||||
memcpy(SavedDB, DemodBuffer, sizeof(DemodBuffer));
|
||||
SavedDBlen = DemodBufferLen;
|
||||
memcpy(SavedDB, g_DemodBuffer, sizeof(g_DemodBuffer));
|
||||
SavedDBlen = g_DemodBufferLen;
|
||||
DB_Saved = true;
|
||||
savedDemodStartIdx = g_DemodStartIdx;
|
||||
savedDemodClock = g_DemodClock;
|
||||
} else if (DB_Saved) { //restore
|
||||
|
||||
memcpy(DemodBuffer, SavedDB, sizeof(DemodBuffer));
|
||||
DemodBufferLen = SavedDBlen;
|
||||
memcpy(g_DemodBuffer, SavedDB, sizeof(g_DemodBuffer));
|
||||
g_DemodBufferLen = SavedDBlen;
|
||||
g_DemodClock = savedDemodClock;
|
||||
g_DemodStartIdx = savedDemodStartIdx;
|
||||
}
|
||||
|
@ -215,9 +215,9 @@ static int CmdSetDebugMode(const char *Cmd) {
|
|||
// max output to 512 bits if we have more
|
||||
// doesn't take inconsideration where the demod offset or bitlen found.
|
||||
int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_hex) {
|
||||
size_t len = DemodBufferLen;
|
||||
size_t len = g_DemodBufferLen;
|
||||
if (len == 0) {
|
||||
PrintAndLogEx(WARNING, "Demodbuffer is empty");
|
||||
PrintAndLogEx(WARNING, "DemodBuffer is empty");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
@ -226,15 +226,15 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
|
|||
PrintAndLogEx(WARNING, "dail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
memcpy(buf, DemodBuffer, len);
|
||||
memcpy(buf, g_DemodBuffer, len);
|
||||
|
||||
uint8_t *p = NULL;
|
||||
|
||||
if (strip_leading) {
|
||||
p = (buf + offset);
|
||||
|
||||
if (len > (DemodBufferLen - offset))
|
||||
len = (DemodBufferLen - offset);
|
||||
if (len > (g_DemodBufferLen - offset))
|
||||
len = (g_DemodBufferLen - offset);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < len; i++) {
|
||||
|
@ -243,8 +243,8 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
|
|||
offset += i;
|
||||
}
|
||||
|
||||
if (len > (DemodBufferLen - offset)) {
|
||||
len = (DemodBufferLen - offset);
|
||||
if (len > (g_DemodBufferLen - offset)) {
|
||||
len = (g_DemodBufferLen - offset);
|
||||
}
|
||||
|
||||
if (len > 512) {
|
||||
|
@ -291,7 +291,7 @@ int CmdPrintDemodBuff(const char *Cmd) {
|
|||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("i", "inv", "invert Demodbuffer before printing"),
|
||||
arg_lit0("i", "inv", "invert DemodBuffer before printing"),
|
||||
// arg_int0("l","len", "<dec>", "length to print in # of bits or hex characters respectively"),
|
||||
arg_int0("o", "offset", "<dec>", "offset in # of bits"),
|
||||
arg_lit0("s", "strip", "strip leading zeroes, i.e. set offset to first bit equal to one"),
|
||||
|
@ -535,7 +535,7 @@ static int Cmdmandecoderaw(const char *Cmd) {
|
|||
CLIParserInit(&ctx, "data manrawdecode",
|
||||
"Manchester decode binary stream in DemodBuffer\n"
|
||||
"Converts 10 and 01 and converts to 0 and 1 respectively\n"
|
||||
" - must have binary sequence in demodbuffer (run `data rawdemod --ar` before)",
|
||||
" - must have binary sequence in DemodBuffer (run `data rawdemod --ar` before)",
|
||||
"data manrawdecode"
|
||||
);
|
||||
void *argtable[] = {
|
||||
|
@ -549,7 +549,7 @@ static int Cmdmandecoderaw(const char *Cmd) {
|
|||
int max_err = arg_get_int_def(ctx, 2, 20);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (DemodBufferLen == 0) {
|
||||
if (g_DemodBufferLen == 0) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer empty, run " _YELLOW_("`data rawdemod --ar`"));
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -559,12 +559,12 @@ static int Cmdmandecoderaw(const char *Cmd) {
|
|||
// make sure its just binary data 0|1|7 in buffer
|
||||
int high = 0, low = 0;
|
||||
size_t i = 0;
|
||||
for (; i < DemodBufferLen; ++i) {
|
||||
if (DemodBuffer[i] > high)
|
||||
high = DemodBuffer[i];
|
||||
else if (DemodBuffer[i] < low)
|
||||
low = DemodBuffer[i];
|
||||
bits[i] = DemodBuffer[i];
|
||||
for (; i < g_DemodBufferLen; ++i) {
|
||||
if (g_DemodBuffer[i] > high)
|
||||
high = g_DemodBuffer[i];
|
||||
else if (g_DemodBuffer[i] < low)
|
||||
low = g_DemodBuffer[i];
|
||||
bits[i] = g_DemodBuffer[i];
|
||||
}
|
||||
|
||||
if (high > 7 || low < 0) {
|
||||
|
@ -618,10 +618,10 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) {
|
|||
CLIParserInit(&ctx, "data biphaserawdecode",
|
||||
"Biphase decode binary stream in DemodBuffer\n"
|
||||
"Converts 10 or 01 -> 1 and 11 or 00 -> 0\n"
|
||||
" - must have binary sequence in demodbuffer (run `data rawdemod --ar` before)\n"
|
||||
" - must have binary sequence in DemodBuffer (run `data rawdemod --ar` before)\n"
|
||||
" - invert for Conditional Dephase Encoding (CDP) AKA Differential Manchester",
|
||||
"data biphaserawdecode --> decode biphase bitstream from the demodbuffer\n"
|
||||
"data biphaserawdecode -oi --> decode biphase bitstream from the demodbuffer, adjust offset, and invert output"
|
||||
"data biphaserawdecode --> decode biphase bitstream from the DemodBuffer\n"
|
||||
"data biphaserawdecode -oi --> decode biphase bitstream from the DemodBuffer, adjust offset, and invert output"
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
@ -636,7 +636,7 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) {
|
|||
int max_err = arg_get_int_def(ctx, 3, 20);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (DemodBufferLen == 0) {
|
||||
if (g_DemodBufferLen == 0) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer empty, run " _YELLOW_("`data rawdemod --ar`"));
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -699,7 +699,7 @@ int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose) {
|
|||
if (offset >= 1) {
|
||||
offset -= 1;
|
||||
}
|
||||
//success set DemodBuffer and return
|
||||
//success set g_DemodBuffer and return
|
||||
setDemodBuff(bs, size, 0);
|
||||
setClockGrid(clk, startIdx + clk * offset / 2);
|
||||
if (g_debugMode || verbose) {
|
||||
|
@ -853,7 +853,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
|
|||
|
||||
CursorCPos = idx_1;
|
||||
CursorDPos = idx_1 + retval;
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
RepaintGraphWindow();
|
||||
}
|
||||
free(correl_buf);
|
||||
|
@ -1308,7 +1308,7 @@ int PSKDemod(int clk, int invert, int maxErr, bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) errors during Demoding (shown as 7 in bit stream): %d", errCnt);
|
||||
}
|
||||
}
|
||||
//prime demod buffer for output
|
||||
//prime g_DemodBuffer for output
|
||||
setDemodBuff(bits, bitlen, 0);
|
||||
setClockGrid(clk, startIdx);
|
||||
free(bits);
|
||||
|
@ -1317,7 +1317,7 @@ int PSKDemod(int clk, int invert, int maxErr, bool verbose) {
|
|||
|
||||
// takes 3 arguments - clock, invert, maxErr as integers
|
||||
// attempts to demodulate nrz only
|
||||
// prints binary found and saves in demodbuffer for further commands
|
||||
// prints binary found and saves in g_DemodBuffer for further commands
|
||||
int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) {
|
||||
|
||||
int errCnt = 0, clkStartIdx = 0;
|
||||
|
@ -1355,7 +1355,7 @@ int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) {
|
|||
}
|
||||
|
||||
if (verbose || g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) Tried NRZ Demod using Clock: %d - invert: %d - Bits Found: %zu", clk, invert, bitlen);
|
||||
//prime demod buffer for output
|
||||
//prime g_DemodBuffer for output
|
||||
setDemodBuff(bits, bitlen, 0);
|
||||
setClockGrid(clk, clkStartIdx);
|
||||
|
||||
|
@ -1400,7 +1400,7 @@ static int CmdNRZrawDemod(const char *Cmd) {
|
|||
|
||||
// takes 3 arguments - clock, invert, max_err as integers
|
||||
// attempts to demodulate psk only
|
||||
// prints binary found and saves in demodbuffer for further commands
|
||||
// prints binary found and saves in g_DemodBuffer for further commands
|
||||
int CmdPSK1rawDemod(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "data rawdemod --p1",
|
||||
|
@ -1468,7 +1468,7 @@ static int CmdPSK2rawDemod(const char *Cmd) {
|
|||
if (g_debugMode) PrintAndLogEx(ERR, "Error demoding: %d", ans);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen);
|
||||
PrintAndLogEx(SUCCESS, _YELLOW_("PSK2") " demoded bitstream");
|
||||
PrintAndLogEx(INFO, "----------------------");
|
||||
// Now output the bitstream to the scrollback by line of 16 bits
|
||||
|
@ -1794,7 +1794,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose) {
|
|||
computeSignalProperties(bits, size);
|
||||
|
||||
setClockGrid(0, 0);
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
RepaintGraphWindow();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -1845,7 +1845,7 @@ int CmdTuneSamples(const char *Cmd) {
|
|||
#define ANTENNA_ERROR 1.00 // current algo has 3% error margin.
|
||||
|
||||
// hide demod plot line
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
setClockGrid(0, 0);
|
||||
RepaintGraphWindow();
|
||||
|
||||
|
@ -2071,7 +2071,7 @@ static int CmdLoad(const char *Cmd) {
|
|||
computeSignalProperties(bits, size);
|
||||
|
||||
setClockGrid(0, 0);
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
RepaintGraphWindow();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -2663,7 +2663,7 @@ static int CmdFSKToNRZ(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
|
||||
setClockGrid(0, 0);
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
int ans = FSKToNRZ(GraphBuffer, &GraphTraceLen, clk, fc_low, fc_high);
|
||||
CmdNorm("");
|
||||
RepaintGraphWindow();
|
||||
|
|
|
@ -72,7 +72,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
|
|||
|
||||
void setDemodBuff(uint8_t *buff, size_t size, size_t start_idx);
|
||||
bool getDemodBuff(uint8_t *buff, size_t *size);
|
||||
void save_restoreDB(uint8_t saveOpt);// option '1' to save DemodBuffer any other to restore
|
||||
void save_restoreDB(uint8_t saveOpt);// option '1' to save g_DemodBuffer any other to restore
|
||||
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose);
|
||||
|
||||
int getSamples(uint32_t n, bool verbose);
|
||||
|
@ -83,8 +83,8 @@ int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t
|
|||
int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||
|
||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
extern size_t DemodBufferLen;
|
||||
extern uint8_t g_DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
extern size_t g_DemodBufferLen;
|
||||
|
||||
extern int g_DemodClock;
|
||||
extern int32_t g_DemodStartIdx;
|
||||
|
|
|
@ -376,7 +376,7 @@ int handle_hf_plot(void) {
|
|||
CmdHpf("");
|
||||
|
||||
setClockGrid(0, 0);
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
RepaintGraphWindow();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ int CmdFlexdemod(const char *Cmd) {
|
|||
|
||||
}
|
||||
|
||||
// iceman, use demod buffer? blue line?
|
||||
// iceman, use g_DemodBuffer? blue line?
|
||||
// HACK writing back to graphbuffer.
|
||||
GraphTraceLen = 32 * 64;
|
||||
i = 0;
|
||||
|
@ -871,11 +871,11 @@ int CmdLFSim(const char *Cmd) {
|
|||
}
|
||||
|
||||
// sim fsk data given clock, fcHigh, fcLow, invert
|
||||
// - allow pull data from DemodBuffer
|
||||
// - allow pull data from g_DemodBuffer
|
||||
int CmdLFfskSim(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf simfsk",
|
||||
"Simulate FSK tag from demodbuffer or input. There are about four FSK modulations to know of.\n"
|
||||
"Simulate FSK tag from DemodBuffer or input. There are about four FSK modulations to know of.\n"
|
||||
"FSK1 - where fc/8 = high and fc/5 = low\n"
|
||||
"FSK1a - is inverted FSK1, ie: fc/5 = high and fc/8 = low\n"
|
||||
"FSK2 - where fc/10 = high and fc/8 = low\n"
|
||||
|
@ -912,8 +912,8 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
|
||||
// No args
|
||||
if (raw_len == 0 && DemodBufferLen == 0) {
|
||||
PrintAndLogEx(ERR, "No user supplied data nor inside Demodbuffer");
|
||||
if (raw_len == 0 && g_DemodBufferLen == 0) {
|
||||
PrintAndLogEx(ERR, "No user supplied data nor inside DemodBuffer");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
@ -925,10 +925,10 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
uint8_t bs[256] = {0x00};
|
||||
int bs_len = hextobinarray((char *)bs, raw);
|
||||
if (bs_len == 0) {
|
||||
// Using data from DemodBuffer
|
||||
// might be able to autodetect FC and clock from Graphbuffer if using demod buffer
|
||||
// Using data from g_DemodBuffer
|
||||
// might be able to autodetect FC and clock from Graphbuffer if using g_DemodBuffer
|
||||
// will need clock, fchigh, fclow and bitstream
|
||||
PrintAndLogEx(INFO, "No user supplied data, using Demodbuffer...");
|
||||
PrintAndLogEx(INFO, "No user supplied data, using DemodBuffer...");
|
||||
|
||||
if (clk == 0 || fchigh == 0 || fclow == 0) {
|
||||
int firstClockEdge = 0;
|
||||
|
@ -939,7 +939,7 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
fclow = 0;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(DEBUG, "Detected rf/%u, High fc/%u, Low fc/%u, n %zu ", clk, fchigh, fclow, DemodBufferLen);
|
||||
PrintAndLogEx(DEBUG, "Detected rf/%u, High fc/%u, Low fc/%u, n %zu ", clk, fchigh, fclow, g_DemodBufferLen);
|
||||
|
||||
} else {
|
||||
setDemodBuff(bs, bs_len, 0);
|
||||
|
@ -961,7 +961,7 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "Autodetection of smaller clock failed, falling back to fc/%u", fclow);
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
size_t size = g_DemodBufferLen;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t));
|
||||
PrintAndLogEx(INFO, "Continuing with trimmed down data");
|
||||
|
@ -973,7 +973,7 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
payload->fclow = fclow;
|
||||
payload->separator = separator;
|
||||
payload->clock = clk;
|
||||
memcpy(payload->data, DemodBuffer, size);
|
||||
memcpy(payload->data, g_DemodBuffer, size);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_FSK_SIMULATE, (uint8_t *)payload, sizeof(lf_fsksim_t) + size);
|
||||
|
@ -984,11 +984,11 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
}
|
||||
|
||||
// sim ask data given clock, invert, manchester or raw, separator
|
||||
// - allow pull data from DemodBuffer
|
||||
// - allow pull data from g_DemodBuffer
|
||||
int CmdLFaskSim(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf simask",
|
||||
"Simulate ASK tag from demodbuffer or input",
|
||||
"Simulate ASK tag from DemodBuffer or input",
|
||||
"lf simask --clk 32 --am -d 0102030405 --> simulate ASK/MAN rf/32\n"
|
||||
"lf simask --clk 32 --bi -d 0102030405 --> simulate ASK/BIPHASE rf/32\n\n"
|
||||
"lf simask --clk 64 --am -d ffbd8001686f1924 --> simulate a EM410x tag\n"
|
||||
|
@ -1033,18 +1033,18 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
encoding = 0;
|
||||
|
||||
// No args
|
||||
if (raw_len == 0 && DemodBufferLen == 0) {
|
||||
PrintAndLogEx(ERR, "No user supplied data nor any inside Demodbuffer");
|
||||
if (raw_len == 0 && g_DemodBufferLen == 0) {
|
||||
PrintAndLogEx(ERR, "No user supplied data nor any inside DemodBuffer");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint8_t bs[256] = {0x00};
|
||||
int bs_len = hextobinarray((char *)bs, raw);
|
||||
if (bs_len == 0) {
|
||||
// Using data from DemodBuffer
|
||||
// might be able to autodetect FC and clock from Graphbuffer if using demod buffer
|
||||
// Using data from g_DemodBuffer
|
||||
// might be able to autodetect FC and clock from Graphbuffer if using g_DemodBuffer
|
||||
// will need carrier, clock, and bitstream
|
||||
PrintAndLogEx(INFO, "No user supplied data, using Demodbuffer...");
|
||||
PrintAndLogEx(INFO, "No user supplied data, using DemodBuffer...");
|
||||
|
||||
if (clk == 0) {
|
||||
int res = GetAskClock("0", verbose);
|
||||
|
@ -1055,7 +1055,7 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(DEBUG, "Detected rf/%u, n %zu ", clk, DemodBufferLen);
|
||||
PrintAndLogEx(DEBUG, "Detected rf/%u, n %zu ", clk, g_DemodBufferLen);
|
||||
|
||||
} else {
|
||||
setDemodBuff(bs, bs_len, 0);
|
||||
|
@ -1072,7 +1072,7 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "ASK/RAW needs half rf. Using rf/%u", clk);
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
size_t size = g_DemodBufferLen;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_asksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, PM3_CMD_DATA_SIZE - sizeof(lf_asksim_t));
|
||||
PrintAndLogEx(INFO, "Continuing with trimmed down data");
|
||||
|
@ -1084,7 +1084,7 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
payload->invert = invert;
|
||||
payload->separator = separator;
|
||||
payload->clock = clk;
|
||||
memcpy(payload->data, DemodBuffer, size);
|
||||
memcpy(payload->data, g_DemodBuffer, size);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_ASK_SIMULATE, (uint8_t *)payload, sizeof(lf_asksim_t) + size);
|
||||
|
@ -1095,12 +1095,12 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
}
|
||||
|
||||
// sim psk data given carrier, clock, invert
|
||||
// - allow pull data from DemodBuffer or parameters
|
||||
// - allow pull data from g_DemodBuffer or parameters
|
||||
int CmdLFpskSim(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf simpsk",
|
||||
"Simulate PSK tag from demodbuffer or input",
|
||||
"Simulate PSK tag from DemodBuffer or input",
|
||||
"lf simpsk -1 --clk 40 --fc 4 -d 01020304 --> simulate PSK1 rf/40 psksub fc/4, data 01020304\n\n"
|
||||
"lf simpsk -1 --clk 32 --fc 2 -d a0000000bd989a11 --> simulate a indala tag manually"
|
||||
);
|
||||
|
@ -1147,8 +1147,8 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
psk_type = 3;
|
||||
|
||||
// No args
|
||||
if (raw_len == 0 && DemodBufferLen == 0) {
|
||||
PrintAndLogEx(ERR, "No user supplied data nor any inside Demodbuffer");
|
||||
if (raw_len == 0 && g_DemodBufferLen == 0) {
|
||||
PrintAndLogEx(ERR, "No user supplied data nor any inside DemodBuffer");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
@ -1156,10 +1156,10 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
int bs_len = hextobinarray((char *)bs, raw);
|
||||
|
||||
if (bs_len == 0) {
|
||||
// Using data from DemodBuffer
|
||||
// might be able to autodetect FC and clock from Graphbuffer if using demod buffer
|
||||
// Using data from g_DemodBuffer
|
||||
// might be able to autodetect FC and clock from Graphbuffer if using g_DemodBuffer
|
||||
// will need carrier, clock, and bitstream
|
||||
PrintAndLogEx(INFO, "No user supplied data, using Demodbuffer...");
|
||||
PrintAndLogEx(INFO, "No user supplied data, using DemodBuffer...");
|
||||
|
||||
int res;
|
||||
if (clk == 0) {
|
||||
|
@ -1180,7 +1180,7 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(DEBUG, "Detected rf/%u, fc/%u, n %zu ", clk, carrier, DemodBufferLen);
|
||||
PrintAndLogEx(DEBUG, "Detected rf/%u, fc/%u, n %zu ", clk, carrier, g_DemodBufferLen);
|
||||
|
||||
} else {
|
||||
setDemodBuff(bs, bs_len, 0);
|
||||
|
@ -1193,12 +1193,12 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
|
||||
if (psk_type == 2) {
|
||||
//need to convert psk2 to psk1 data before sim
|
||||
psk2TOpsk1(DemodBuffer, DemodBufferLen);
|
||||
psk2TOpsk1(g_DemodBuffer, g_DemodBufferLen);
|
||||
} else if (psk_type == 3) {
|
||||
PrintAndLogEx(INFO, "PSK3 not yet available. Falling back to PSK1");
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
size_t size = g_DemodBufferLen;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t));
|
||||
PrintAndLogEx(INFO, "Continuing with trimmed down data");
|
||||
|
@ -1209,7 +1209,7 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
payload->carrier = carrier;
|
||||
payload->invert = invert;
|
||||
payload->clock = clk;
|
||||
memcpy(payload->data, DemodBuffer, size);
|
||||
memcpy(payload->data, g_DemodBuffer, size);
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_PSK_SIMULATE, (uint8_t *)payload, sizeof(lf_psksim_t) + size);
|
||||
free(payload);
|
||||
|
|
|
@ -268,7 +268,7 @@ int demodAWID(bool verbose) {
|
|||
}
|
||||
free(bits);
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: AWID idx: %d, Len: %zu Printing Demod Buffer:", idx, size);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: AWID idx: %d, Len: %zu Printing DemodBuffer:", idx, size);
|
||||
if (g_debugMode) {
|
||||
printDemodBuff(0, false, false, true);
|
||||
printDemodBuff(0, false, false, false);
|
||||
|
|
|
@ -27,7 +27,7 @@ int demodCOTAG(bool verbose) {
|
|||
|
||||
uint8_t bits[COTAG_BITS] = {0};
|
||||
size_t bitlen = COTAG_BITS;
|
||||
memcpy(bits, DemodBuffer, COTAG_BITS);
|
||||
memcpy(bits, g_DemodBuffer, COTAG_BITS);
|
||||
|
||||
uint8_t alignPos = 0;
|
||||
uint16_t err = manrawdecode(bits, &bitlen, 1, &alignPos);
|
||||
|
@ -150,8 +150,8 @@ static int CmdCOTAGReader(const char *Cmd) {
|
|||
break;
|
||||
}
|
||||
case 1: {
|
||||
memcpy(DemodBuffer, resp.data.asBytes, resp.length);
|
||||
DemodBufferLen = resp.length;
|
||||
memcpy(g_DemodBuffer, resp.data.asBytes, resp.length);
|
||||
g_DemodBufferLen = resp.length;
|
||||
return demodCOTAG(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ int demodDestron(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectDestron(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectDestron(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Destron: too few bits found");
|
||||
|
@ -52,12 +52,12 @@ int demodDestron(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
setDemodBuff(DemodBuffer, DESTRON_FRAME_SIZE, ans);
|
||||
setDemodBuff(g_DemodBuffer, DESTRON_FRAME_SIZE, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
uint8_t bits[DESTRON_FRAME_SIZE - DESTRON_PREAMBLE_SIZE] = {0};
|
||||
size_t bitlen = DESTRON_FRAME_SIZE - DESTRON_PREAMBLE_SIZE;
|
||||
memcpy(bits, DemodBuffer + DESTRON_PREAMBLE_SIZE, DESTRON_FRAME_SIZE - DESTRON_PREAMBLE_SIZE);
|
||||
memcpy(bits, g_DemodBuffer + DESTRON_PREAMBLE_SIZE, DESTRON_FRAME_SIZE - DESTRON_PREAMBLE_SIZE);
|
||||
|
||||
uint8_t alignPos = 0;
|
||||
uint16_t errCnt = manrawdecode(bits, &bitlen, 0, &alignPos);
|
||||
|
|
|
@ -264,10 +264,10 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) {
|
|||
}
|
||||
|
||||
//set GraphBuffer for clone or sim command
|
||||
setDemodBuff(DemodBuffer, (size == 40) ? 64 : 128, idx + 1);
|
||||
setDemodBuff(g_DemodBuffer, (size == 40) ? 64 : 128, idx + 1);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + ((idx + 1)*g_DemodClock));
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Em410x idx: %zu, Len: %zu, Printing Demod Buffer:", idx, size);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Em410x idx: %zu, Len: %zu, Printing DemodBuffer:", idx, size);
|
||||
if (g_debugMode) {
|
||||
printDemodBuff(0, false, false, true);
|
||||
}
|
||||
|
|
|
@ -113,22 +113,22 @@ static bool em4x05_download_samples(void) {
|
|||
static int doPreambleSearch(size_t *startIdx) {
|
||||
|
||||
// sanity check
|
||||
if (DemodBufferLen < EM_PREAMBLE_LEN) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM4305 demodbuffer too small");
|
||||
if (g_DemodBufferLen < EM_PREAMBLE_LEN) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM4305 DemodBuffer too small");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// set size to 11 to only test first 3 positions for the preamble
|
||||
// do not set it too long else an error preamble followed by 010 could be seen as success.
|
||||
size_t size = (11 > DemodBufferLen) ? DemodBufferLen : 11;
|
||||
size_t size = (11 > g_DemodBufferLen) ? g_DemodBufferLen : 11;
|
||||
*startIdx = 0;
|
||||
|
||||
// skip first two 0 bits as they might have been missed in the demod
|
||||
uint8_t preamble[EM_PREAMBLE_LEN] = {0, 0, 0, 0, 1, 0, 1, 0};
|
||||
if (!preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, startIdx, true)) {
|
||||
if (!preambleSearchEx(g_DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, startIdx, true)) {
|
||||
|
||||
uint8_t errpreamble[EM_PREAMBLE_LEN] = {0, 0, 0, 0, 0, 0, 0, 1};
|
||||
if (!preambleSearchEx(DemodBuffer, errpreamble, EM_PREAMBLE_LEN, &size, startIdx, true)) {
|
||||
if (!preambleSearchEx(g_DemodBuffer, errpreamble, EM_PREAMBLE_LEN, &size, startIdx, true)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM4305 preamble not found :: %zu", *startIdx);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -168,14 +168,14 @@ static bool detectPSK(void) {
|
|||
}
|
||||
|
||||
// In order to hit the INVERT, we need to demod here
|
||||
if (DemodBufferLen < 11) {
|
||||
if (g_DemodBufferLen < 11) {
|
||||
PrintAndLogEx(INFO, " demod buff len less than PREAMBLE lEN");
|
||||
}
|
||||
|
||||
size_t size = (11 > DemodBufferLen) ? DemodBufferLen : 11;
|
||||
size_t size = (11 > g_DemodBufferLen) ? g_DemodBufferLen : 11;
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[EM_PREAMBLE_LEN] = {0, 0, 0, 0, 1, 0, 1, 0};
|
||||
if (!preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, &startIdx, true)) {
|
||||
if (!preambleSearchEx(g_DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, &startIdx, true)) {
|
||||
|
||||
//try psk1 inverted
|
||||
ans = PSKDemod(0, 1, 6, false);
|
||||
|
@ -184,7 +184,7 @@ static bool detectPSK(void) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, &startIdx, true)) {
|
||||
if (!preambleSearchEx(g_DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, &startIdx, true)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK1 inverted Demod failed 2");
|
||||
return false;
|
||||
}
|
||||
|
@ -237,19 +237,19 @@ static int em4x05_setdemod_buffer(uint32_t *word, size_t idx) {
|
|||
|
||||
//test for even parity bits.
|
||||
uint8_t parity[45] = {0};
|
||||
memcpy(parity, DemodBuffer, 45);
|
||||
if (!em4x05_col_parity_test(DemodBuffer + idx + EM_PREAMBLE_LEN, 45, 5, 9, 0)) {
|
||||
memcpy(parity, g_DemodBuffer, 45);
|
||||
if (!em4x05_col_parity_test(g_DemodBuffer + idx + EM_PREAMBLE_LEN, 45, 5, 9, 0)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - End Parity check failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// test for even parity bits and remove them. (leave out the end row of parities so 36 bits)
|
||||
if (!removeParity(DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 36)) {
|
||||
if (!removeParity(g_DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 36)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM, failed removing parity");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 32, 0);
|
||||
*word = bytebits_to_byteLSBF(DemodBuffer, 32);
|
||||
setDemodBuff(g_DemodBuffer, 32, 0);
|
||||
*word = bytebits_to_byteLSBF(g_DemodBuffer, 32);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ static int em4x05_demod_resp(uint32_t *word, bool onlyPreamble) {
|
|||
if (res == PM3_EFAILED)
|
||||
found_err = true;
|
||||
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen);
|
||||
res = doPreambleSearch(&idx);
|
||||
if (res == PM3_SUCCESS)
|
||||
break;
|
||||
|
|
|
@ -485,8 +485,8 @@ int demodFDXB(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B ASKbiphaseDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int preambleIndex = detectFDXB(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int preambleIndex = detectFDXB(g_DemodBuffer, &size);
|
||||
if (preambleIndex < 0) {
|
||||
|
||||
if (preambleIndex == -1)
|
||||
|
@ -500,13 +500,13 @@ int demodFDXB(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// set and leave DemodBuffer intact
|
||||
setDemodBuff(DemodBuffer, 128, preambleIndex);
|
||||
// set and leave g_DemodBuffer intact
|
||||
setDemodBuff(g_DemodBuffer, 128, preambleIndex);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (preambleIndex * g_DemodClock));
|
||||
|
||||
|
||||
// remove marker bits (1's every 9th digit after preamble) (pType = 2)
|
||||
size = removeParity(DemodBuffer, 11, 9, 2, 117);
|
||||
size = removeParity(g_DemodBuffer, 11, 9, 2, 117);
|
||||
if (size != 104) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B error removeParity: %zu", size);
|
||||
return PM3_ESOFT;
|
||||
|
@ -515,42 +515,42 @@ int demodFDXB(bool verbose) {
|
|||
//got a good demod
|
||||
uint8_t offset;
|
||||
// ISO: bits 27..64
|
||||
uint64_t NationalCode = ((uint64_t)(bytebits_to_byteLSBF(DemodBuffer + 32, 6)) << 32) | bytebits_to_byteLSBF(DemodBuffer, 32);
|
||||
uint64_t NationalCode = ((uint64_t)(bytebits_to_byteLSBF(g_DemodBuffer + 32, 6)) << 32) | bytebits_to_byteLSBF(g_DemodBuffer, 32);
|
||||
|
||||
offset = 38;
|
||||
// ISO: bits 17..26
|
||||
uint16_t countryCode = bytebits_to_byteLSBF(DemodBuffer + offset, 10);
|
||||
uint16_t countryCode = bytebits_to_byteLSBF(g_DemodBuffer + offset, 10);
|
||||
|
||||
offset += 10;
|
||||
// ISO: bits 16
|
||||
uint8_t dataBlockBit = DemodBuffer[offset];
|
||||
uint8_t dataBlockBit = g_DemodBuffer[offset];
|
||||
|
||||
offset++;
|
||||
// ISO: bits 15
|
||||
uint8_t rudiBit = DemodBuffer[offset];
|
||||
uint8_t rudiBit = g_DemodBuffer[offset];
|
||||
|
||||
offset++;
|
||||
// ISO: bits 10..14
|
||||
uint32_t reservedCode = bytebits_to_byteLSBF(DemodBuffer + offset, 5);
|
||||
uint32_t reservedCode = bytebits_to_byteLSBF(g_DemodBuffer + offset, 5);
|
||||
|
||||
offset += 5;
|
||||
// ISO: bits 5..9
|
||||
uint32_t userInfo = bytebits_to_byteLSBF(DemodBuffer + offset, 5);
|
||||
uint32_t userInfo = bytebits_to_byteLSBF(g_DemodBuffer + offset, 5);
|
||||
|
||||
offset += 5;
|
||||
// ISO: bits 2..4
|
||||
uint32_t replacementNr = bytebits_to_byteLSBF(DemodBuffer + offset, 3);
|
||||
uint32_t replacementNr = bytebits_to_byteLSBF(g_DemodBuffer + offset, 3);
|
||||
|
||||
offset += 3;
|
||||
uint8_t animalBit = DemodBuffer[offset];
|
||||
uint8_t animalBit = g_DemodBuffer[offset];
|
||||
|
||||
offset++;
|
||||
uint16_t crc = bytebits_to_byteLSBF(DemodBuffer + offset, 16);
|
||||
uint16_t crc = bytebits_to_byteLSBF(g_DemodBuffer + offset, 16);
|
||||
|
||||
offset += 16;
|
||||
uint32_t extended = bytebits_to_byteLSBF(DemodBuffer + offset, 24);
|
||||
uint32_t extended = bytebits_to_byteLSBF(g_DemodBuffer + offset, 24);
|
||||
|
||||
uint64_t rawid = (uint64_t)(bytebits_to_byte(DemodBuffer, 32)) << 32 | bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint64_t rawid = (uint64_t)(bytebits_to_byte(g_DemodBuffer, 32)) << 32 | bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint8_t raw[8];
|
||||
num_to_bytes(rawid, 8, raw);
|
||||
|
||||
|
@ -578,7 +578,7 @@ int demodFDXB(bool verbose) {
|
|||
|
||||
if (g_debugMode) {
|
||||
PrintAndLogEx(DEBUG, "Start marker %d; Size %zu", preambleIndex, size);
|
||||
char *bin = sprint_bin_break(DemodBuffer, size, 16);
|
||||
char *bin = sprint_bin_break(g_DemodBuffer, size, 16);
|
||||
PrintAndLogEx(DEBUG, "DEBUG bin stream:\n%s", bin);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,8 @@ int demodGallagher(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectGallagher(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectGallagher(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - GALLAGHER: too few bits found");
|
||||
|
@ -102,23 +102,23 @@ int demodGallagher(bool verbose) {
|
|||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
// got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
|
||||
// bytes
|
||||
uint8_t arr[8] = {0};
|
||||
for (int i = 0, pos = 0; i < ARRAYLEN(arr); i++) {
|
||||
pos = 16 + (9 * i);
|
||||
arr[i] = bytebits_to_byte(DemodBuffer + pos, 8);
|
||||
arr[i] = bytebits_to_byte(g_DemodBuffer + pos, 8);
|
||||
}
|
||||
|
||||
// crc
|
||||
uint8_t crc = bytebits_to_byte(DemodBuffer + 16 + (9 * 8), 8);
|
||||
uint8_t crc = bytebits_to_byte(g_DemodBuffer + 16 + (9 * 8), 8);
|
||||
uint8_t calc_crc = CRC8Cardx(arr, ARRAYLEN(arr));
|
||||
|
||||
descramble(arr, ARRAYLEN(arr));
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
// attempts to demodulate and identify a G_Prox_II verex/chubb card
|
||||
// WARNING: if it fails during some points it will destroy the DemodBuffer data
|
||||
// WARNING: if it fails during some points it will destroy the g_DemodBuffer data
|
||||
// but will leave the GraphBuffer intact.
|
||||
// if successful it will push askraw data back to demod buffer ready for emulation
|
||||
// if successful it will push askraw data back to g_DemodBuffer ready for emulation
|
||||
int demodGuard(bool verbose) {
|
||||
(void) verbose; // unused so far
|
||||
//Differential Biphase
|
||||
|
@ -40,9 +40,9 @@ int demodGuard(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
size_t size = g_DemodBufferLen;
|
||||
|
||||
int preambleIndex = detectGProxII(DemodBuffer, &size);
|
||||
int preambleIndex = detectGProxII(g_DemodBuffer, &size);
|
||||
if (preambleIndex < 0) {
|
||||
|
||||
if (preambleIndex == -1)
|
||||
|
@ -65,8 +65,8 @@ int demodGuard(bool verbose) {
|
|||
size_t startIdx = preambleIndex + 6; //start after 6 bit preamble
|
||||
uint8_t bits_no_spacer[90];
|
||||
|
||||
// not mess with raw DemodBuffer copy to a new sample array
|
||||
memcpy(bits_no_spacer, DemodBuffer + startIdx, 90);
|
||||
// not mess with raw g_DemodBuffer copy to a new sample array
|
||||
memcpy(bits_no_spacer, g_DemodBuffer + startIdx, 90);
|
||||
|
||||
// remove the 18 (90/5=18) parity bits (down to 72 bits (96-6-18=72))
|
||||
size_t len = removeParity(bits_no_spacer, 0, 5, 3, 90); //source, startloc, paritylen, ptype, length_to_run
|
||||
|
@ -82,7 +82,7 @@ int demodGuard(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: gProxII byte %zu after xor: %02x", idx, plain[idx]);
|
||||
}
|
||||
|
||||
setDemodBuff(DemodBuffer, 96, preambleIndex);
|
||||
setDemodBuff(g_DemodBuffer, 96, preambleIndex);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (preambleIndex * g_DemodClock));
|
||||
|
||||
//plain contains 8 Bytes (64 bits) of decrypted raw tag data
|
||||
|
@ -90,9 +90,9 @@ int demodGuard(bool verbose) {
|
|||
uint32_t FC = 0;
|
||||
uint32_t Card = 0;
|
||||
//get raw 96 bits to print
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
bool unknown = false;
|
||||
switch (fmtLen) {
|
||||
case 36:
|
||||
|
|
|
@ -146,7 +146,7 @@ int demodHID(bool verbose) {
|
|||
}
|
||||
PrintAndLogEx(INFO, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing Demod Buffer: ", idx, size);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing DemodBuffer: ", idx, size);
|
||||
if (g_debugMode) {
|
||||
PrintAndLogEx(DEBUG, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ int demodIdteck(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
size_t size = g_DemodBufferLen;
|
||||
|
||||
//get binary from PSK1 wave
|
||||
int idx = detectIdteck(DemodBuffer, &size);
|
||||
int idx = detectIdteck(g_DemodBuffer, &size);
|
||||
if (idx < 0) {
|
||||
|
||||
if (idx == -1)
|
||||
|
@ -55,7 +55,7 @@ int demodIdteck(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
idx = detectIdteck(DemodBuffer, &size);
|
||||
idx = detectIdteck(g_DemodBuffer, &size);
|
||||
if (idx < 0) {
|
||||
|
||||
if (idx == -1)
|
||||
|
@ -72,12 +72,12 @@ int demodIdteck(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 64, idx);
|
||||
setDemodBuff(g_DemodBuffer, 64, idx);
|
||||
|
||||
//got a good demod
|
||||
uint32_t id = 0;
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
|
||||
//parity check (TBD)
|
||||
//checksum check (TBD)
|
||||
|
|
|
@ -124,8 +124,8 @@ int demodIndalaEx(int clk, int invert, int maxErr, bool verbose) {
|
|||
}
|
||||
|
||||
uint8_t inv = 0;
|
||||
size_t size = DemodBufferLen;
|
||||
int idx = detectIndala(DemodBuffer, &size, &inv);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int idx = detectIndala(g_DemodBuffer, &size, &inv);
|
||||
if (idx < 0) {
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Indala: not enough samples");
|
||||
|
@ -139,68 +139,68 @@ int demodIndalaEx(int clk, int invert, int maxErr, bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Indala: error demoding psk idx: %d", idx);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, size, idx);
|
||||
setDemodBuff(g_DemodBuffer, size, idx);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock));
|
||||
|
||||
//convert UID to HEX
|
||||
uint32_t uid1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t uid2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t uid1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t uid2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
// To be checked, what's this internal ID ?
|
||||
// foo is only used for 64b ids and in that case uid1 must be only preamble, plus the following code is wrong as x<<32 & 0x1FFFFFFF is always zero
|
||||
//uint64_t foo = (((uint64_t)uid1 << 32) & 0x1FFFFFFF) | (uid2 & 0x7FFFFFFF);
|
||||
uint64_t foo = uid2 & 0x7FFFFFFF;
|
||||
|
||||
if (DemodBufferLen == 64) {
|
||||
PrintAndLogEx(SUCCESS, "Indala (len %zu) Raw: " _GREEN_("%x%08x"), DemodBufferLen, uid1, uid2);
|
||||
if (g_DemodBufferLen == 64) {
|
||||
PrintAndLogEx(SUCCESS, "Indala (len %zu) Raw: " _GREEN_("%x%08x"), g_DemodBufferLen, uid1, uid2);
|
||||
|
||||
uint16_t p1 = 0;
|
||||
p1 |= DemodBuffer[32 + 3] << 8;
|
||||
p1 |= DemodBuffer[32 + 6] << 5;
|
||||
p1 |= DemodBuffer[32 + 8] << 4;
|
||||
p1 |= DemodBuffer[32 + 9] << 3;
|
||||
p1 |= DemodBuffer[32 + 11] << 1;
|
||||
p1 |= DemodBuffer[32 + 16] << 6;
|
||||
p1 |= DemodBuffer[32 + 19] << 7;
|
||||
p1 |= DemodBuffer[32 + 20] << 10;
|
||||
p1 |= DemodBuffer[32 + 21] << 2;
|
||||
p1 |= DemodBuffer[32 + 22] << 0;
|
||||
p1 |= DemodBuffer[32 + 24] << 9;
|
||||
p1 |= g_DemodBuffer[32 + 3] << 8;
|
||||
p1 |= g_DemodBuffer[32 + 6] << 5;
|
||||
p1 |= g_DemodBuffer[32 + 8] << 4;
|
||||
p1 |= g_DemodBuffer[32 + 9] << 3;
|
||||
p1 |= g_DemodBuffer[32 + 11] << 1;
|
||||
p1 |= g_DemodBuffer[32 + 16] << 6;
|
||||
p1 |= g_DemodBuffer[32 + 19] << 7;
|
||||
p1 |= g_DemodBuffer[32 + 20] << 10;
|
||||
p1 |= g_DemodBuffer[32 + 21] << 2;
|
||||
p1 |= g_DemodBuffer[32 + 22] << 0;
|
||||
p1 |= g_DemodBuffer[32 + 24] << 9;
|
||||
|
||||
uint8_t fc = 0;
|
||||
fc |= DemodBuffer[57] << 7; // b8
|
||||
fc |= DemodBuffer[49] << 6; // b7
|
||||
fc |= DemodBuffer[44] << 5; // b6
|
||||
fc |= DemodBuffer[47] << 4; // b5
|
||||
fc |= DemodBuffer[48] << 3; // b4
|
||||
fc |= DemodBuffer[53] << 2; // b3
|
||||
fc |= DemodBuffer[39] << 1; // b2
|
||||
fc |= DemodBuffer[58] << 0; // b1
|
||||
fc |= g_DemodBuffer[57] << 7; // b8
|
||||
fc |= g_DemodBuffer[49] << 6; // b7
|
||||
fc |= g_DemodBuffer[44] << 5; // b6
|
||||
fc |= g_DemodBuffer[47] << 4; // b5
|
||||
fc |= g_DemodBuffer[48] << 3; // b4
|
||||
fc |= g_DemodBuffer[53] << 2; // b3
|
||||
fc |= g_DemodBuffer[39] << 1; // b2
|
||||
fc |= g_DemodBuffer[58] << 0; // b1
|
||||
|
||||
uint16_t csn = 0;
|
||||
csn |= DemodBuffer[42] << 15; // b16
|
||||
csn |= DemodBuffer[45] << 14; // b15
|
||||
csn |= DemodBuffer[43] << 13; // b14
|
||||
csn |= DemodBuffer[40] << 12; // b13
|
||||
csn |= DemodBuffer[52] << 11; // b12
|
||||
csn |= DemodBuffer[36] << 10; // b11
|
||||
csn |= DemodBuffer[35] << 9; // b10
|
||||
csn |= DemodBuffer[51] << 8; // b9
|
||||
csn |= DemodBuffer[46] << 7; // b8
|
||||
csn |= DemodBuffer[33] << 6; // b7
|
||||
csn |= DemodBuffer[37] << 5; // b6
|
||||
csn |= DemodBuffer[54] << 4; // b5
|
||||
csn |= DemodBuffer[56] << 3; // b4
|
||||
csn |= DemodBuffer[59] << 2; // b3
|
||||
csn |= DemodBuffer[50] << 1; // b2
|
||||
csn |= DemodBuffer[41] << 0; // b1
|
||||
csn |= g_DemodBuffer[42] << 15; // b16
|
||||
csn |= g_DemodBuffer[45] << 14; // b15
|
||||
csn |= g_DemodBuffer[43] << 13; // b14
|
||||
csn |= g_DemodBuffer[40] << 12; // b13
|
||||
csn |= g_DemodBuffer[52] << 11; // b12
|
||||
csn |= g_DemodBuffer[36] << 10; // b11
|
||||
csn |= g_DemodBuffer[35] << 9; // b10
|
||||
csn |= g_DemodBuffer[51] << 8; // b9
|
||||
csn |= g_DemodBuffer[46] << 7; // b8
|
||||
csn |= g_DemodBuffer[33] << 6; // b7
|
||||
csn |= g_DemodBuffer[37] << 5; // b6
|
||||
csn |= g_DemodBuffer[54] << 4; // b5
|
||||
csn |= g_DemodBuffer[56] << 3; // b4
|
||||
csn |= g_DemodBuffer[59] << 2; // b3
|
||||
csn |= g_DemodBuffer[50] << 1; // b2
|
||||
csn |= g_DemodBuffer[41] << 0; // b1
|
||||
|
||||
uint8_t parity = 0;
|
||||
parity |= DemodBuffer[34] << 1; // b2
|
||||
parity |= DemodBuffer[38] << 0; // b1
|
||||
parity |= g_DemodBuffer[34] << 1; // b2
|
||||
parity |= g_DemodBuffer[38] << 0; // b1
|
||||
|
||||
uint8_t checksum = 0;
|
||||
checksum |= DemodBuffer[62] << 1; // b2
|
||||
checksum |= DemodBuffer[63] << 0; // b1
|
||||
checksum |= g_DemodBuffer[62] << 1; // b2
|
||||
checksum |= g_DemodBuffer[63] << 0; // b1
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Fmt " _GREEN_("26") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u") " Parity: " _GREEN_("%1d%1d")
|
||||
, fc
|
||||
|
@ -214,18 +214,18 @@ int demodIndalaEx(int clk, int invert, int maxErr, bool verbose) {
|
|||
// This doesn't seem to line up with the hot-stamp numbers on any HID cards I have seen, but, leaving it alone since I do not know how those work. -MS
|
||||
PrintAndLogEx(SUCCESS, " Printed | __%04d__ [0x%X]", p1, p1);
|
||||
PrintAndLogEx(SUCCESS, " Internal ID | %" PRIu64, foo);
|
||||
decodeHeden2L(DemodBuffer);
|
||||
decodeHeden2L(g_DemodBuffer);
|
||||
|
||||
} else {
|
||||
uint32_t uid3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t uid4 = bytebits_to_byte(DemodBuffer + 96, 32);
|
||||
uint32_t uid5 = bytebits_to_byte(DemodBuffer + 128, 32);
|
||||
uint32_t uid6 = bytebits_to_byte(DemodBuffer + 160, 32);
|
||||
uint32_t uid7 = bytebits_to_byte(DemodBuffer + 192, 32);
|
||||
uint32_t uid3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
uint32_t uid4 = bytebits_to_byte(g_DemodBuffer + 96, 32);
|
||||
uint32_t uid5 = bytebits_to_byte(g_DemodBuffer + 128, 32);
|
||||
uint32_t uid6 = bytebits_to_byte(g_DemodBuffer + 160, 32);
|
||||
uint32_t uid7 = bytebits_to_byte(g_DemodBuffer + 192, 32);
|
||||
PrintAndLogEx(
|
||||
SUCCESS
|
||||
, "Indala (len %zu) Raw: " _GREEN_("%x%08x%08x%08x%08x%08x%08x")
|
||||
, DemodBufferLen
|
||||
, g_DemodBufferLen
|
||||
, uid1
|
||||
, uid2
|
||||
, uid3
|
||||
|
@ -237,7 +237,7 @@ int demodIndalaEx(int clk, int invert, int maxErr, bool verbose) {
|
|||
}
|
||||
|
||||
if (g_debugMode) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Indala - printing demodbuffer");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Indala - printing DemodBuffer");
|
||||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
@ -314,7 +314,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
|
||||
//clear clock grid and demod plot
|
||||
setClockGrid(0, 0);
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
|
||||
// PrintAndLogEx(NORMAL, "Expecting a bit less than %d raw bits", GraphTraceLen / 32);
|
||||
// loop through raw signal - since we know it is psk1 rf/32 fc/2 skip every other value (+=2)
|
||||
|
|
|
@ -144,7 +144,7 @@ int demodIOProx(bool verbose) {
|
|||
if (crc != calccrc)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - IO prox crc failed");
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: IO prox idx: %d, Len: %zu, Printing demod buffer:", idx, size);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: IO prox idx: %d, Len: %zu, Printing DemodBuffer:", idx, size);
|
||||
printDemodBuff(0, false, false, true);
|
||||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ int demodJablotron(bool verbose) {
|
|||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Jablotron ASKbiphaseDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectJablotron(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectJablotron(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (g_debugMode) {
|
||||
if (ans == -1)
|
||||
|
@ -75,21 +75,21 @@ int demodJablotron(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
setDemodBuff(DemodBuffer, JABLOTRON_ARR_LEN, ans);
|
||||
setDemodBuff(g_DemodBuffer, JABLOTRON_ARR_LEN, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
|
||||
// bytebits_to_byte - uint32_t
|
||||
uint64_t rawid = ((uint64_t)(bytebits_to_byte(DemodBuffer + 16, 8) & 0xff) << 32) | bytebits_to_byte(DemodBuffer + 24, 32);
|
||||
uint64_t rawid = ((uint64_t)(bytebits_to_byte(g_DemodBuffer + 16, 8) & 0xff) << 32) | bytebits_to_byte(g_DemodBuffer + 24, 32);
|
||||
uint64_t id = getJablontronCardId(rawid);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Jablotron - Card: " _GREEN_("%"PRIx64) ", Raw: %08X%08X", id, raw1, raw2);
|
||||
|
||||
uint8_t chksum = raw2 & 0xFF;
|
||||
bool isok = (chksum == jablontron_chksum(DemodBuffer));
|
||||
bool isok = (chksum == jablontron_chksum(g_DemodBuffer));
|
||||
|
||||
PrintAndLogEx(DEBUG, "Checksum: %02X (%s)", chksum, isok ? _GREEN_("ok") : _RED_("Fail"));
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ int demodKeri(bool verbose) {
|
|||
}
|
||||
|
||||
bool invert = false;
|
||||
size_t size = DemodBufferLen;
|
||||
int idx = detectKeri(DemodBuffer, &size, &invert);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int idx = detectKeri(g_DemodBuffer, &size, &invert);
|
||||
if (idx < 0) {
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - KERI: too few bits found");
|
||||
|
@ -119,7 +119,7 @@ int demodKeri(bool verbose) {
|
|||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, size, idx);
|
||||
setDemodBuff(g_DemodBuffer, size, idx);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock));
|
||||
|
||||
/*
|
||||
|
@ -143,22 +143,22 @@ int demodKeri(bool verbose) {
|
|||
uint32_t fc = 0;
|
||||
uint32_t cardid = 0;
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
|
||||
if (invert) {
|
||||
PrintAndLogEx(INFO, "Had to Invert - probably KERI");
|
||||
for (size_t i = 0; i < size; i++)
|
||||
DemodBuffer[i] ^= 1;
|
||||
g_DemodBuffer[i] ^= 1;
|
||||
|
||||
raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
|
||||
CmdPrintDemodBuff("-x");
|
||||
}
|
||||
|
||||
//get internal id
|
||||
// uint32_t ID = bytebits_to_byte(DemodBuffer + 29, 32);
|
||||
// uint32_t ID = bytebits_to_byte(g_DemodBuffer + 29, 32);
|
||||
// Due to the 3 sync bits being at the start of the capture
|
||||
// We can take the last 32bits as the internal ID.
|
||||
uint32_t ID = raw2;
|
||||
|
@ -391,7 +391,7 @@ int detectKeri(uint8_t *dest, size_t *size, bool *invert) {
|
|||
found_size = *size;
|
||||
// if didn't find preamble try again inverting
|
||||
uint8_t preamble_i[] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
|
||||
if (!preambleSearch(DemodBuffer, preamble_i, sizeof(preamble_i), &found_size, &startIdx))
|
||||
if (!preambleSearch(g_DemodBuffer, preamble_i, sizeof(preamble_i), &found_size, &startIdx))
|
||||
return -2;
|
||||
|
||||
*invert ^= 1;
|
||||
|
|
|
@ -34,8 +34,8 @@ int demodMotorola(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectMotorola(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectMotorola(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Motorola: too few bits found");
|
||||
|
@ -48,12 +48,12 @@ int demodMotorola(bool verbose) {
|
|||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 64, ans);
|
||||
setDemodBuff(g_DemodBuffer, 64, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
|
||||
// A0000000E308C0C1
|
||||
// 10100000000000000000000000000000 1110 0011 0000 1000 1100 0000 1100 0001
|
||||
|
@ -74,42 +74,42 @@ int demodMotorola(bool verbose) {
|
|||
|
||||
// FC seems to be guess work. Need more samples
|
||||
// guessing printed FC is 4 digits. 1024? 10bit?
|
||||
// fc |= DemodBuffer[38] << 9; // b10
|
||||
fc |= DemodBuffer[34] << 8; // b9
|
||||
// fc |= g_DemodBuffer[38] << 9; // b10
|
||||
fc |= g_DemodBuffer[34] << 8; // b9
|
||||
|
||||
fc |= DemodBuffer[44] << 7; // b8
|
||||
fc |= DemodBuffer[47] << 6; // b7
|
||||
fc |= DemodBuffer[57] << 5; // b6
|
||||
fc |= DemodBuffer[49] << 4; // b5
|
||||
fc |= g_DemodBuffer[44] << 7; // b8
|
||||
fc |= g_DemodBuffer[47] << 6; // b7
|
||||
fc |= g_DemodBuffer[57] << 5; // b6
|
||||
fc |= g_DemodBuffer[49] << 4; // b5
|
||||
|
||||
// seems to match
|
||||
fc |= DemodBuffer[53] << 3; // b4
|
||||
fc |= DemodBuffer[48] << 2; // b3
|
||||
fc |= DemodBuffer[58] << 1; // b2
|
||||
fc |= DemodBuffer[39] << 0; // b1
|
||||
fc |= g_DemodBuffer[53] << 3; // b4
|
||||
fc |= g_DemodBuffer[48] << 2; // b3
|
||||
fc |= g_DemodBuffer[58] << 1; // b2
|
||||
fc |= g_DemodBuffer[39] << 0; // b1
|
||||
|
||||
// CSN was same as Indala CSN descramble.
|
||||
uint16_t csn = 0;
|
||||
csn |= DemodBuffer[42] << 15; // b16
|
||||
csn |= DemodBuffer[45] << 14; // b15
|
||||
csn |= DemodBuffer[43] << 13; // b14
|
||||
csn |= DemodBuffer[40] << 12; // b13
|
||||
csn |= DemodBuffer[52] << 11; // b12
|
||||
csn |= DemodBuffer[36] << 10; // b11
|
||||
csn |= DemodBuffer[35] << 9; // b10
|
||||
csn |= DemodBuffer[51] << 8; // b9
|
||||
csn |= DemodBuffer[46] << 7; // b8
|
||||
csn |= DemodBuffer[33] << 6; // b7
|
||||
csn |= DemodBuffer[37] << 5; // b6
|
||||
csn |= DemodBuffer[54] << 4; // b5
|
||||
csn |= DemodBuffer[56] << 3; // b4
|
||||
csn |= DemodBuffer[59] << 2; // b3
|
||||
csn |= DemodBuffer[50] << 1; // b2
|
||||
csn |= DemodBuffer[41] << 0; // b1
|
||||
csn |= g_DemodBuffer[42] << 15; // b16
|
||||
csn |= g_DemodBuffer[45] << 14; // b15
|
||||
csn |= g_DemodBuffer[43] << 13; // b14
|
||||
csn |= g_DemodBuffer[40] << 12; // b13
|
||||
csn |= g_DemodBuffer[52] << 11; // b12
|
||||
csn |= g_DemodBuffer[36] << 10; // b11
|
||||
csn |= g_DemodBuffer[35] << 9; // b10
|
||||
csn |= g_DemodBuffer[51] << 8; // b9
|
||||
csn |= g_DemodBuffer[46] << 7; // b8
|
||||
csn |= g_DemodBuffer[33] << 6; // b7
|
||||
csn |= g_DemodBuffer[37] << 5; // b6
|
||||
csn |= g_DemodBuffer[54] << 4; // b5
|
||||
csn |= g_DemodBuffer[56] << 3; // b4
|
||||
csn |= g_DemodBuffer[59] << 2; // b3
|
||||
csn |= g_DemodBuffer[50] << 1; // b2
|
||||
csn |= g_DemodBuffer[41] << 0; // b1
|
||||
|
||||
uint8_t checksum = 0;
|
||||
checksum |= DemodBuffer[62] << 1; // b2
|
||||
checksum |= DemodBuffer[63] << 0; // b1
|
||||
checksum |= g_DemodBuffer[62] << 1; // b2
|
||||
checksum |= g_DemodBuffer[63] << 0; // b1
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Motorola - fmt: " _GREEN_("26") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u") ", Raw: %08X%08X", fc, csn, raw1, raw2);
|
||||
|
|
|
@ -56,14 +56,14 @@ int demodNedap(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size = DemodBufferLen;
|
||||
if (!preambleSearch(DemodBuffer, (uint8_t *) preamble, sizeof(preamble), &size, &offset)) {
|
||||
size = g_DemodBufferLen;
|
||||
if (!preambleSearch(g_DemodBuffer, (uint8_t *) preamble, sizeof(preamble), &size, &offset)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NEDAP: preamble not found");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// set plot
|
||||
setDemodBuff(DemodBuffer, size, offset);
|
||||
setDemodBuff(g_DemodBuffer, size, offset);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (g_DemodClock * offset));
|
||||
|
||||
// sanity checks
|
||||
|
@ -72,7 +72,7 @@ int demodNedap(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (bits_to_array(DemodBuffer, size, data) != PM3_SUCCESS) {
|
||||
if (bits_to_array(g_DemodBuffer, size, data) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NEDAP: bits_to_array error\n");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ static int CmdLFNedapSim(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Simulating NEDAP - Raw: " _YELLOW_("%s"), sprint_hex_inrow(data, max));
|
||||
|
||||
// NEDAP, Biphase = 2, clock 64, inverted, (DIPhase == inverted BIphase)
|
||||
lf_asksim_t *payload = calloc(1, sizeof(lf_asksim_t) + DemodBufferLen);
|
||||
lf_asksim_t *payload = calloc(1, sizeof(lf_asksim_t) + g_DemodBufferLen);
|
||||
payload->encoding = 2;
|
||||
payload->invert = 1;
|
||||
payload->separator = 0;
|
||||
|
@ -537,7 +537,7 @@ static int CmdLFNedapSim(const char *Cmd) {
|
|||
memcpy(payload->data, bs, (max * 8));
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_ASK_SIMULATE, (uint8_t *)payload, sizeof(lf_asksim_t) + DemodBufferLen);
|
||||
SendCommandNG(CMD_LF_ASK_SIMULATE, (uint8_t *)payload, sizeof(lf_asksim_t) + g_DemodBufferLen);
|
||||
free(payload);
|
||||
|
||||
PacketResponseNG resp;
|
||||
|
|
|
@ -131,8 +131,8 @@ int demodNexWatch(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
bool invert = false;
|
||||
size_t size = DemodBufferLen;
|
||||
int idx = detectNexWatch(DemodBuffer, &size, &invert);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int idx = detectNexWatch(g_DemodBuffer, &size, &invert);
|
||||
if (idx < 0) {
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch not enough samples");
|
||||
|
@ -153,42 +153,42 @@ int demodNexWatch(bool verbose) {
|
|||
// skip the 4 first bits from the nexwatch preamble identification (we use 4 extra zeros..)
|
||||
idx += 4;
|
||||
|
||||
setDemodBuff(DemodBuffer, size, idx);
|
||||
setDemodBuff(g_DemodBuffer, size, idx);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock));
|
||||
|
||||
if (invert) {
|
||||
PrintAndLogEx(INFO, "Inverted the demodulated data");
|
||||
for (size_t i = 0; i < size; i++)
|
||||
DemodBuffer[i] ^= 1;
|
||||
g_DemodBuffer[i] ^= 1;
|
||||
}
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 32 + 32, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 32 + 32, 32);
|
||||
|
||||
// get rawid
|
||||
uint32_t rawid = 0;
|
||||
for (uint8_t k = 0; k < 4; k++) {
|
||||
for (uint8_t m = 0; m < 8; m++) {
|
||||
rawid = (rawid << 1) | DemodBuffer[m + k + (m * 4)];
|
||||
rawid = (rawid << 1) | g_DemodBuffer[m + k + (m * 4)];
|
||||
}
|
||||
}
|
||||
|
||||
// descrambled id
|
||||
uint32_t cn = 0;
|
||||
uint32_t scambled = bytebits_to_byte(DemodBuffer + 8 + 32, 32);
|
||||
uint32_t scambled = bytebits_to_byte(g_DemodBuffer + 8 + 32, 32);
|
||||
nexwatch_scamble(DESCRAMBLE, &cn, &scambled);
|
||||
|
||||
uint8_t mode = bytebits_to_byte(DemodBuffer + 72, 4);
|
||||
uint8_t parity = bytebits_to_byte(DemodBuffer + 76, 4);
|
||||
uint8_t chk = bytebits_to_byte(DemodBuffer + 80, 8);
|
||||
uint8_t mode = bytebits_to_byte(g_DemodBuffer + 72, 4);
|
||||
uint8_t parity = bytebits_to_byte(g_DemodBuffer + 76, 4);
|
||||
uint8_t chk = bytebits_to_byte(g_DemodBuffer + 80, 8);
|
||||
|
||||
// parity check
|
||||
// from 32b hex id, 4b mode
|
||||
uint8_t hex[5] = {0};
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
hex[i] = bytebits_to_byte(DemodBuffer + 8 + 32 + (i * 8), 8);
|
||||
hex[i] = bytebits_to_byte(g_DemodBuffer + 8 + 32 + (i * 8), 8);
|
||||
}
|
||||
// mode is only 4 bits.
|
||||
hex[4] &= 0xf0;
|
||||
|
@ -584,10 +584,10 @@ int detectNexWatch(uint8_t *dest, size_t *size, bool *invert) {
|
|||
|
||||
size_t startIdx = 0;
|
||||
|
||||
if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
if (!preambleSearch(g_DemodBuffer, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
// if didn't find preamble try again inverting
|
||||
uint8_t preamble_i[28] = {1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
if (!preambleSearch(DemodBuffer, preamble_i, sizeof(preamble_i), size, &startIdx)) return -4;
|
||||
if (!preambleSearch(g_DemodBuffer, preamble_i, sizeof(preamble_i), size, &startIdx)) return -4;
|
||||
*invert ^= 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ int demodNoralsy(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectNoralsy(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectNoralsy(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (g_debugMode) {
|
||||
if (ans == -1)
|
||||
|
@ -61,13 +61,13 @@ int demodNoralsy(bool verbose) {
|
|||
}
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
|
||||
uint32_t cardid = ((raw2 & 0xFFF00000) >> 20) << 16;
|
||||
cardid |= (raw2 & 0xFF) << 8;
|
||||
|
@ -79,11 +79,11 @@ int demodNoralsy(bool verbose) {
|
|||
year += (year > 60) ? 1900 : 2000;
|
||||
|
||||
// calc checksums
|
||||
uint8_t calc1 = noralsy_chksum(DemodBuffer + 32, 40);
|
||||
uint8_t calc2 = noralsy_chksum(DemodBuffer, 76);
|
||||
uint8_t calc1 = noralsy_chksum(g_DemodBuffer + 32, 40);
|
||||
uint8_t calc2 = noralsy_chksum(g_DemodBuffer, 76);
|
||||
uint8_t chk1 = 0, chk2 = 0;
|
||||
chk1 = bytebits_to_byte(DemodBuffer + 72, 4);
|
||||
chk2 = bytebits_to_byte(DemodBuffer + 76, 4);
|
||||
chk1 = bytebits_to_byte(g_DemodBuffer + 72, 4);
|
||||
chk2 = bytebits_to_byte(g_DemodBuffer + 76, 4);
|
||||
// test checksums
|
||||
if (chk1 != calc1) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Noralsy: checksum 1 failed %x - %x\n", chk1, calc1);
|
||||
|
|
|
@ -124,8 +124,8 @@ int demodPac(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
bool invert = false;
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectPac(DemodBuffer, &size, &invert);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectPac(g_DemodBuffer, &size, &invert);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - PAC: too few bits found");
|
||||
|
@ -141,21 +141,21 @@ int demodPac(bool verbose) {
|
|||
|
||||
if (invert) {
|
||||
for (size_t i = ans; i < ans + 128; i++) {
|
||||
DemodBuffer[i] ^= 1;
|
||||
g_DemodBuffer[i] ^= 1;
|
||||
}
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 128, ans);
|
||||
setDemodBuff(g_DemodBuffer, 128, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw4 = bytebits_to_byte(DemodBuffer + 96, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
uint32_t raw4 = bytebits_to_byte(g_DemodBuffer + 96, 32);
|
||||
|
||||
const size_t idLen = 9; // 8 bytes + null terminator
|
||||
uint8_t cardid[idLen];
|
||||
int retval = pac_buf_to_cardid(DemodBuffer, DemodBufferLen, cardid, sizeof(cardid));
|
||||
int retval = pac_buf_to_cardid(g_DemodBuffer, g_DemodBufferLen, cardid, sizeof(cardid));
|
||||
|
||||
if (retval == PM3_SUCCESS)
|
||||
PrintAndLogEx(SUCCESS, "PAC/Stanley - Card: " _GREEN_("%s") ", Raw: %08X%08X%08X%08X", cardid, raw1, raw2, raw3, raw4);
|
||||
|
|
|
@ -161,7 +161,7 @@ int demodParadox(bool verbose) {
|
|||
rawLo
|
||||
);
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Paradox idx: %d, len: %zu, Printing Demod Buffer:", idx, size);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Paradox idx: %d, len: %zu, Printing DemodBuffer:", idx, size);
|
||||
if (g_debugMode) {
|
||||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ int demodPresco(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error Presco ASKDemod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectPresco(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectPresco(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Presco: too few bits found");
|
||||
|
@ -90,14 +90,14 @@ int demodPresco(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Presco: ans: %d", ans);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 128, ans);
|
||||
setDemodBuff(g_DemodBuffer, 128, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw4 = bytebits_to_byte(DemodBuffer + 96, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
uint32_t raw4 = bytebits_to_byte(g_DemodBuffer + 96, 32);
|
||||
uint32_t fullcode = raw4;
|
||||
uint32_t usercode = fullcode & 0x0000FFFF;
|
||||
uint32_t sitecode = (fullcode >> 24) & 0x000000FF;
|
||||
|
|
|
@ -169,7 +169,7 @@ int demodPyramid(bool verbose) {
|
|||
, (checksum == checkCS) ? _GREEN_("ok") : _RED_("fail")
|
||||
);
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing DemodBuffer:", idx, 128);
|
||||
if (g_debugMode) {
|
||||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ int demodSecurakey(bool verbose) {
|
|||
if (st)
|
||||
return PM3_ESOFT;
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectSecurakey(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectSecurakey(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: too few bits found");
|
||||
|
@ -51,13 +51,13 @@ int demodSecurakey(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ans: %d", ans);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
|
||||
// 26 bit format
|
||||
// preamble ??bitlen reserved EPx xxxxxxxy yyyyyyyy yyyyyyyOP CS? CS2?
|
||||
|
@ -72,7 +72,7 @@ int demodSecurakey(bool verbose) {
|
|||
// standard wiegand parities.
|
||||
// unknown checksum 11 bits? at the end
|
||||
uint8_t bits_no_spacer[85];
|
||||
memcpy(bits_no_spacer, DemodBuffer + 11, 85);
|
||||
memcpy(bits_no_spacer, g_DemodBuffer + 11, 85);
|
||||
|
||||
// remove marker bits (0's every 9th digit after preamble) (pType = 3 (always 0s))
|
||||
size = removeParity(bits_no_spacer, 0, 9, 3, 85);
|
||||
|
|
|
@ -287,8 +287,8 @@ bool t55xxAquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known_
|
|||
continue;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < DemodBufferLen - 32; i++) {
|
||||
uint32_t tmp = PackBits(i, 32, DemodBuffer);
|
||||
for (uint16_t i = 0; i < g_DemodBufferLen - 32; i++) {
|
||||
uint32_t tmp = PackBits(i, 32, g_DemodBuffer);
|
||||
if (tmp == known_block0) {
|
||||
config.offset = i;
|
||||
config.downlink_mode = m;
|
||||
|
@ -727,7 +727,7 @@ bool DecodeT55xxBlock(void) {
|
|||
int ans = 0;
|
||||
bool ST = config.ST;
|
||||
uint8_t bitRate[8] = {8, 16, 32, 40, 50, 64, 100, 128};
|
||||
DemodBufferLen = 0x00;
|
||||
g_DemodBufferLen = 0x00;
|
||||
|
||||
switch (config.modulation) {
|
||||
case DEMOD_FSK:
|
||||
|
@ -750,7 +750,7 @@ bool DecodeT55xxBlock(void) {
|
|||
case DEMOD_PSK2: //inverted won't affect this
|
||||
case DEMOD_PSK3: //not fully implemented
|
||||
ans = PSKDemod(bitRate[config.bitrate], 0, 6, false);
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen);
|
||||
break;
|
||||
case DEMOD_NRZ:
|
||||
ans = NRZrawDemod(bitRate[config.bitrate], config.inverted, 1, false);
|
||||
|
@ -766,7 +766,7 @@ bool DecodeT55xxBlock(void) {
|
|||
}
|
||||
|
||||
static bool DecodeT5555TraceBlock(void) {
|
||||
DemodBufferLen = 0x00;
|
||||
g_DemodBufferLen = 0x00;
|
||||
|
||||
// According to datasheet. Always: RF/64, not inverted, Manchester
|
||||
bool st = false;
|
||||
|
@ -1042,7 +1042,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_FSK2;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1055,7 +1055,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_FSK2a;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1073,7 +1073,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_ASK;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_ASK;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_BI;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1104,7 +1104,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_BIa;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1116,7 +1116,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_NRZ;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1126,7 +1126,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_NRZ;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1143,7 +1143,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_PSK1;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1152,7 +1152,7 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
tests[hits].modulation = DEMOD_PSK1;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = true;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1160,12 +1160,12 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
//ICEMAN: are these PSKDemod calls needed?
|
||||
// PSK2 - needs a call to psk1TOpsk2.
|
||||
if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) {
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen);
|
||||
if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK2;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1173,12 +1173,12 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32
|
|||
} // inverse waves does not affect this demod
|
||||
// PSK3 - needs a call to psk1TOpsk2.
|
||||
if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) {
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen);
|
||||
if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
tests[hits].modulation = DEMOD_PSK3;
|
||||
tests[hits].bitrate = bitRate;
|
||||
tests[hits].inverted = false;
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
|
||||
tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer);
|
||||
tests[hits].ST = false;
|
||||
tests[hits].downlink_mode = downlink_mode;
|
||||
++hits;
|
||||
|
@ -1278,17 +1278,17 @@ bool testKnownConfigBlock(uint32_t block0) {
|
|||
|
||||
bool GetT55xxBlockData(uint32_t *blockdata) {
|
||||
|
||||
if (DemodBufferLen == 0)
|
||||
if (g_DemodBufferLen == 0)
|
||||
return false;
|
||||
|
||||
uint8_t idx = config.offset;
|
||||
|
||||
if (idx + 32 > DemodBufferLen) {
|
||||
PrintAndLogEx(WARNING, "The configured offset %d is too big. Possible offset: %zu)", idx, DemodBufferLen - 32);
|
||||
if (idx + 32 > g_DemodBufferLen) {
|
||||
PrintAndLogEx(WARNING, "The configured offset %d is too big. Possible offset: %zu)", idx, g_DemodBufferLen - 32);
|
||||
return false;
|
||||
}
|
||||
|
||||
*blockdata = PackBits(0, 32, DemodBuffer + idx);
|
||||
*blockdata = PackBits(0, 32, g_DemodBuffer + idx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ void printT55xxBlock(uint8_t blockNum, bool page1) {
|
|||
|
||||
T55x7_SaveBlockData((page1) ? blockNum + 8 : blockNum, val);
|
||||
|
||||
PrintAndLogEx(SUCCESS, " %02d | %08X | %s | %s", blockNum, val, sprint_bin(DemodBuffer + config.offset, 32), sprint_ascii(bytes, 4));
|
||||
PrintAndLogEx(SUCCESS, " %02d | %08X | %s | %s", blockNum, val, sprint_bin(g_DemodBuffer + config.offset, 32), sprint_ascii(bytes, 4));
|
||||
}
|
||||
|
||||
static bool testModulation(uint8_t mode, uint8_t modread) {
|
||||
|
@ -1378,36 +1378,36 @@ static int convertQ5bitRate(uint8_t bitRateRead) {
|
|||
|
||||
static bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk) {
|
||||
|
||||
if (DemodBufferLen < 64) return false;
|
||||
if (g_DemodBufferLen < 64) return false;
|
||||
|
||||
for (uint8_t idx = 28; idx < 64; idx++) {
|
||||
uint8_t si = idx;
|
||||
if (PackBits(si, 28, DemodBuffer) == 0x00) continue;
|
||||
if (PackBits(si, 28, g_DemodBuffer) == 0x00) continue;
|
||||
|
||||
uint8_t safer = PackBits(si, 4, DemodBuffer);
|
||||
uint8_t safer = PackBits(si, 4, g_DemodBuffer);
|
||||
si += 4; //master key
|
||||
uint8_t resv = PackBits(si, 8, DemodBuffer);
|
||||
uint8_t resv = PackBits(si, 8, g_DemodBuffer);
|
||||
si += 8;
|
||||
// 2nibble must be zeroed.
|
||||
if (safer != 0x6 && safer != 0x9) continue;
|
||||
if (resv > 0x00) continue;
|
||||
//uint8_t pageSel = PackBits(si, 1, DemodBuffer); si += 1;
|
||||
//uint8_t fastWrite = PackBits(si, 1, DemodBuffer); si += 1;
|
||||
//uint8_t pageSel = PackBits(si, 1, g_DemodBuffer); si += 1;
|
||||
//uint8_t fastWrite = PackBits(si, 1, g_DemodBuffer); si += 1;
|
||||
si += 1 + 1;
|
||||
int bitRate = PackBits(si, 6, DemodBuffer) * 2 + 2;
|
||||
int bitRate = PackBits(si, 6, g_DemodBuffer) * 2 + 2;
|
||||
si += 6; //bit rate
|
||||
if (bitRate > 128 || bitRate < 8) continue;
|
||||
|
||||
//uint8_t AOR = PackBits(si, 1, DemodBuffer); si += 1;
|
||||
//uint8_t PWD = PackBits(si, 1, DemodBuffer); si += 1;
|
||||
//uint8_t pskcr = PackBits(si, 2, DemodBuffer); si += 2; //could check psk cr
|
||||
//uint8_t inverse = PackBits(si, 1, DemodBuffer); si += 1;
|
||||
//uint8_t AOR = PackBits(si, 1, g_DemodBuffer); si += 1;
|
||||
//uint8_t PWD = PackBits(si, 1, g_DemodBuffer); si += 1;
|
||||
//uint8_t pskcr = PackBits(si, 2, g_DemodBuffer); si += 2; //could check psk cr
|
||||
//uint8_t inverse = PackBits(si, 1, g_DemodBuffer); si += 1;
|
||||
si += 1 + 1 + 2 + 1;
|
||||
uint8_t modread = PackBits(si, 3, DemodBuffer);
|
||||
uint8_t modread = PackBits(si, 3, g_DemodBuffer);
|
||||
si += 3;
|
||||
uint8_t maxBlk = PackBits(si, 3, DemodBuffer);
|
||||
uint8_t maxBlk = PackBits(si, 3, g_DemodBuffer);
|
||||
si += 3;
|
||||
//uint8_t ST = PackBits(si, 1, DemodBuffer); si += 1;
|
||||
//uint8_t ST = PackBits(si, 1, g_DemodBuffer); si += 1;
|
||||
if (maxBlk == 0) continue;
|
||||
|
||||
//test modulation
|
||||
|
@ -1434,28 +1434,28 @@ static bool testBitRate(uint8_t readRate, uint8_t clk) {
|
|||
|
||||
bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5) {
|
||||
|
||||
if (DemodBufferLen < 64) return false;
|
||||
if (g_DemodBufferLen < 64) return false;
|
||||
for (uint8_t idx = 28; idx < 64; idx++) {
|
||||
uint8_t si = idx;
|
||||
if (PackBits(si, 28, DemodBuffer) == 0x00) continue;
|
||||
if (PackBits(si, 28, g_DemodBuffer) == 0x00) continue;
|
||||
|
||||
uint8_t safer = PackBits(si, 4, DemodBuffer);
|
||||
uint8_t safer = PackBits(si, 4, g_DemodBuffer);
|
||||
si += 4; //master key
|
||||
uint8_t resv = PackBits(si, 4, DemodBuffer);
|
||||
uint8_t resv = PackBits(si, 4, g_DemodBuffer);
|
||||
si += 4; //was 7 & +=7+3 //should be only 4 bits if extended mode
|
||||
// 2nibble must be zeroed.
|
||||
// moved test to here, since this gets most faults first.
|
||||
if (resv > 0x00) continue;
|
||||
|
||||
int bitRate = PackBits(si, 6, DemodBuffer);
|
||||
int bitRate = PackBits(si, 6, g_DemodBuffer);
|
||||
si += 6; //bit rate (includes extended mode part of rate)
|
||||
uint8_t extend = PackBits(si, 1, DemodBuffer);
|
||||
uint8_t extend = PackBits(si, 1, g_DemodBuffer);
|
||||
si += 1; //bit 15 extended mode
|
||||
uint8_t modread = PackBits(si, 5, DemodBuffer);
|
||||
uint8_t modread = PackBits(si, 5, g_DemodBuffer);
|
||||
si += 5 + 2 + 1;
|
||||
//uint8_t pskcr = PackBits(si, 2, DemodBuffer); si += 2+1; //could check psk cr
|
||||
//uint8_t nml01 = PackBits(si, 1, DemodBuffer); si += 1+5; //bit 24, 30, 31 could be tested for 0 if not extended mode
|
||||
//uint8_t nml02 = PackBits(si, 2, DemodBuffer); si += 2;
|
||||
//uint8_t pskcr = PackBits(si, 2, g_DemodBuffer); si += 2+1; //could check psk cr
|
||||
//uint8_t nml01 = PackBits(si, 1, g_DemodBuffer); si += 1+5; //bit 24, 30, 31 could be tested for 0 if not extended mode
|
||||
//uint8_t nml02 = PackBits(si, 2, g_DemodBuffer); si += 2;
|
||||
|
||||
//if extended mode
|
||||
bool extMode = ((safer == 0x6 || safer == 0x9) && extend) ? true : false;
|
||||
|
@ -1485,7 +1485,7 @@ int CmdT55xxSpecial(const char *Cmd) {
|
|||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf t55xx special",
|
||||
"Show block changes with 64 different offsets, data taken from Demod buffer.",
|
||||
"Show block changes with 64 different offsets, data taken from DemodBuffer.",
|
||||
"lf t55xx special\n"
|
||||
);
|
||||
|
||||
|
@ -1504,7 +1504,7 @@ int CmdT55xxSpecial(const char *Cmd) {
|
|||
for (; j < 64; ++j) {
|
||||
|
||||
for (i = 0; i < 32; ++i)
|
||||
bits[i] = DemodBuffer[j + i];
|
||||
bits[i] = g_DemodBuffer[j + i];
|
||||
|
||||
uint32_t blockData = PackBits(0, 32, bits);
|
||||
|
||||
|
@ -1742,7 +1742,7 @@ static int CmdT55xxReadTrace(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
if (DemodBufferLen == 0) {
|
||||
if (g_DemodBufferLen == 0) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -1750,11 +1750,11 @@ static int CmdT55xxReadTrace(const char *Cmd) {
|
|||
uint8_t repeat = (config.offset > 5) ? 32 : 0;
|
||||
|
||||
uint8_t si = config.offset + repeat;
|
||||
uint32_t bl1 = PackBits(si, 32, DemodBuffer);
|
||||
uint32_t bl2 = PackBits(si + 32, 32, DemodBuffer);
|
||||
uint32_t bl1 = PackBits(si, 32, g_DemodBuffer);
|
||||
uint32_t bl2 = PackBits(si + 32, 32, g_DemodBuffer);
|
||||
|
||||
if (config.Q5) {
|
||||
uint32_t hdr = PackBits(si, 9, DemodBuffer);
|
||||
uint32_t hdr = PackBits(si, 9, g_DemodBuffer);
|
||||
si += 9;
|
||||
|
||||
if (hdr != 0x1FF) {
|
||||
|
@ -1764,42 +1764,42 @@ static int CmdT55xxReadTrace(const char *Cmd) {
|
|||
|
||||
t5555_tracedata_t data = {.bl1 = bl1, .bl2 = bl2, .icr = 0, .lotidc = '?', .lotid = 0, .wafer = 0, .dw = 0};
|
||||
|
||||
data.icr = PackBits(si, 2, DemodBuffer);
|
||||
data.icr = PackBits(si, 2, g_DemodBuffer);
|
||||
si += 2;
|
||||
data.lotidc = 'Z' - PackBits(si, 2, DemodBuffer);
|
||||
data.lotidc = 'Z' - PackBits(si, 2, g_DemodBuffer);
|
||||
si += 3;
|
||||
|
||||
data.lotid = PackBits(si, 4, DemodBuffer);
|
||||
data.lotid = PackBits(si, 4, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.lotid <<= 4;
|
||||
data.lotid |= PackBits(si, 4, DemodBuffer);
|
||||
data.lotid |= PackBits(si, 4, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.lotid <<= 4;
|
||||
data.lotid |= PackBits(si, 4, DemodBuffer);
|
||||
data.lotid |= PackBits(si, 4, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.lotid <<= 4;
|
||||
data.lotid |= PackBits(si, 4, DemodBuffer);
|
||||
data.lotid |= PackBits(si, 4, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.lotid <<= 1;
|
||||
data.lotid |= PackBits(si, 1, DemodBuffer);
|
||||
data.lotid |= PackBits(si, 1, g_DemodBuffer);
|
||||
si += 1;
|
||||
|
||||
data.wafer = PackBits(si, 3, DemodBuffer);
|
||||
data.wafer = PackBits(si, 3, g_DemodBuffer);
|
||||
si += 4;
|
||||
data.wafer <<= 2;
|
||||
data.wafer |= PackBits(si, 2, DemodBuffer);
|
||||
data.wafer |= PackBits(si, 2, g_DemodBuffer);
|
||||
si += 2;
|
||||
|
||||
data.dw = PackBits(si, 2, DemodBuffer);
|
||||
data.dw = PackBits(si, 2, g_DemodBuffer);
|
||||
si += 3;
|
||||
data.dw <<= 4;
|
||||
data.dw |= PackBits(si, 4, DemodBuffer);
|
||||
data.dw |= PackBits(si, 4, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.dw <<= 4;
|
||||
data.dw |= PackBits(si, 4, DemodBuffer);
|
||||
data.dw |= PackBits(si, 4, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.dw <<= 4;
|
||||
data.dw |= PackBits(si, 4, DemodBuffer);
|
||||
data.dw |= PackBits(si, 4, g_DemodBuffer);
|
||||
|
||||
printT5555Trace(data, repeat);
|
||||
|
||||
|
@ -1807,28 +1807,28 @@ static int CmdT55xxReadTrace(const char *Cmd) {
|
|||
|
||||
t55x7_tracedata_t data = {.bl1 = bl1, .bl2 = bl2, .acl = 0, .mfc = 0, .cid = 0, .year = 0, .quarter = 0, .icr = 0, .lotid = 0, .wafer = 0, .dw = 0};
|
||||
|
||||
data.acl = PackBits(si, 8, DemodBuffer);
|
||||
data.acl = PackBits(si, 8, g_DemodBuffer);
|
||||
si += 8;
|
||||
if (data.acl != 0xE0) {
|
||||
PrintAndLogEx(FAILED, "The modulation is most likely wrong since the ACL is not 0xE0. ");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
data.mfc = PackBits(si, 8, DemodBuffer);
|
||||
data.mfc = PackBits(si, 8, g_DemodBuffer);
|
||||
si += 8;
|
||||
data.cid = PackBits(si, 5, DemodBuffer);
|
||||
data.cid = PackBits(si, 5, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.icr = PackBits(si, 3, DemodBuffer);
|
||||
data.icr = PackBits(si, 3, g_DemodBuffer);
|
||||
si += 3;
|
||||
data.year = PackBits(si, 4, DemodBuffer);
|
||||
data.year = PackBits(si, 4, g_DemodBuffer);
|
||||
si += 4;
|
||||
data.quarter = PackBits(si, 2, DemodBuffer);
|
||||
data.quarter = PackBits(si, 2, g_DemodBuffer);
|
||||
si += 2;
|
||||
data.lotid = PackBits(si, 14, DemodBuffer);
|
||||
data.lotid = PackBits(si, 14, g_DemodBuffer);
|
||||
si += 14;
|
||||
data.wafer = PackBits(si, 5, DemodBuffer);
|
||||
data.wafer = PackBits(si, 5, g_DemodBuffer);
|
||||
si += 5;
|
||||
data.dw = PackBits(si, 15, DemodBuffer);
|
||||
data.dw = PackBits(si, 15, g_DemodBuffer);
|
||||
|
||||
struct tm *ct, tm_buf;
|
||||
time_t now = time(NULL);
|
||||
|
@ -1861,8 +1861,8 @@ void printT55x7Trace(t55x7_tracedata_t data, uint8_t repeat) {
|
|||
PrintAndLogEx(INFO, " Die Number..... %d", data.dw);
|
||||
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(INFO, " Raw Data - Page 1");
|
||||
PrintAndLogEx(INFO, " Block 1... %08X - %s", data.bl1, sprint_bin(DemodBuffer + config.offset + repeat, 32));
|
||||
PrintAndLogEx(INFO, " Block 2... %08X - %s", data.bl2, sprint_bin(DemodBuffer + config.offset + repeat + 32, 32));
|
||||
PrintAndLogEx(INFO, " Block 1... %08X - %s", data.bl1, sprint_bin(g_DemodBuffer + config.offset + repeat, 32));
|
||||
PrintAndLogEx(INFO, " Block 2... %08X - %s", data.bl2, sprint_bin(g_DemodBuffer + config.offset + repeat + 32, 32));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
/*
|
||||
|
@ -1902,8 +1902,8 @@ void printT5555Trace(t5555_tracedata_t data, uint8_t repeat) {
|
|||
PrintAndLogEx(INFO, " Die Number..... %d", data.dw);
|
||||
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(INFO, " Raw Data - Page 1");
|
||||
PrintAndLogEx(INFO, " Block 1... %08X - %s", data.bl1, sprint_bin(DemodBuffer + config.offset + repeat, 32));
|
||||
PrintAndLogEx(INFO, " Block 2... %08X - %s", data.bl2, sprint_bin(DemodBuffer + config.offset + repeat + 32, 32));
|
||||
PrintAndLogEx(INFO, " Block 1... %08X - %s", data.bl1, sprint_bin(g_DemodBuffer + config.offset + repeat, 32));
|
||||
PrintAndLogEx(INFO, " Block 2... %08X - %s", data.bl2, sprint_bin(g_DemodBuffer + config.offset + repeat + 32, 32));
|
||||
|
||||
/*
|
||||
** Q5 **
|
||||
|
@ -2109,12 +2109,12 @@ static int CmdT55xxInfo(const char *Cmd) {
|
|||
}
|
||||
|
||||
// too little space to start with
|
||||
if (DemodBufferLen < 32 + config.offset) {
|
||||
if (g_DemodBufferLen < 32 + config.offset) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//PrintAndLogEx(NORMAL, "Offset+32 ==%d\n DemodLen == %d", config.offset + 32, DemodBufferLen);
|
||||
block0 = PackBits(config.offset, 32, DemodBuffer);
|
||||
//PrintAndLogEx(NORMAL, "Offset+32 ==%d\n DemodLen == %d", config.offset + 32, g_DemodBufferLen);
|
||||
block0 = PackBits(config.offset, 32, g_DemodBuffer);
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
@ -2185,7 +2185,7 @@ static int CmdT55xxInfo(const char *Cmd) {
|
|||
if (gotdata)
|
||||
PrintAndLogEx(INFO, " " _GREEN_("%08X"), block0);
|
||||
else
|
||||
PrintAndLogEx(INFO, " " _GREEN_("%08X") " - %s", block0, sprint_bin(DemodBuffer + config.offset, 32));
|
||||
PrintAndLogEx(INFO, " " _GREEN_("%08X") " - %s", block0, sprint_bin(g_DemodBuffer + config.offset, 32));
|
||||
|
||||
if (((!gotdata) && (!config.Q5)) || (gotdata && (!dataasq5))) {
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Fingerprint") " ------------");
|
||||
|
@ -3518,13 +3518,13 @@ bool tryDetectP1(bool getData) {
|
|||
ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, &firstClockEdge);
|
||||
if (ans && ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5))) {
|
||||
if ((FSKrawDemod(0, 0, 0, 0, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
if ((FSKrawDemod(0, 1, 0, 0, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3534,27 +3534,27 @@ bool tryDetectP1(bool getData) {
|
|||
clk = GetAskClock("", false);
|
||||
if (clk > 0) {
|
||||
if ((ASKDemod_ext(0, 0, 1, 0, false, false, false, 1, &st) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
st = true;
|
||||
if ((ASKDemod_ext(0, 1, 1, 0, false, false, false, 1, &st) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((ASKbiphaseDemod(0, 0, 0, 2, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((ASKbiphaseDemod(0, 0, 1, 2, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3563,13 +3563,13 @@ bool tryDetectP1(bool getData) {
|
|||
clk = GetNrzClock("", false); //has the most false positives :(
|
||||
if (clk > 0) {
|
||||
if ((NRZrawDemod(0, 0, 1, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
if ((NRZrawDemod(0, 1, 1, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3583,22 +3583,22 @@ bool tryDetectP1(bool getData) {
|
|||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
//CmdLtrim("-i 160");
|
||||
if ((PSKDemod(0, 0, 6, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
//save_restoreGB(GRAPH_RESTORE);
|
||||
return true;
|
||||
}
|
||||
if ((PSKDemod(0, 1, 6, false) == PM3_SUCCESS) &&
|
||||
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
//save_restoreGB(GRAPH_RESTORE);
|
||||
return true;
|
||||
}
|
||||
// PSK2 - needs a call to psk1TOpsk2.
|
||||
if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) {
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
if (preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
|
||||
(DemodBufferLen == 32 || DemodBufferLen == 64)) {
|
||||
psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen);
|
||||
if (preambleSearchEx(g_DemodBuffer, preamble, sizeof(preamble), &g_DemodBufferLen, &startIdx, false) &&
|
||||
(g_DemodBufferLen == 32 || g_DemodBufferLen == 64)) {
|
||||
//save_restoreGB(GRAPH_RESTORE);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ int demodVerichip(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - VERICHIP: NRZ Demod failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectVerichip(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectVerichip(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - VERICHIP: too few bits found");
|
||||
|
@ -59,14 +59,14 @@ int demodVerichip(bool verbose) {
|
|||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 128, ans);
|
||||
setDemodBuff(g_DemodBuffer, 128, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw4 = bytebits_to_byte(DemodBuffer + 96, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
uint32_t raw4 = bytebits_to_byte(g_DemodBuffer + 96, 32);
|
||||
|
||||
// preamble then appears to have marker bits of "10" CS?
|
||||
// 11111111001000000 10 01001100 10 00001101 10 00001101 10 00001101 10 00001101 10 00001101 10 00001101 10 00001101 10 00001101 10 10001100 10 100000001
|
||||
|
|
|
@ -34,21 +34,21 @@ int demodViking(bool verbose) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectViking(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectViking(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Viking Demod %d %s", ans, (ans == -5) ? _RED_("[chksum error]") : "");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer + ans, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + ans + 32, 32);
|
||||
uint32_t cardid = bytebits_to_byte(DemodBuffer + ans + 24, 32);
|
||||
uint8_t checksum = bytebits_to_byte(DemodBuffer + ans + 32 + 24, 8);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer + ans, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + ans + 32, 32);
|
||||
uint32_t cardid = bytebits_to_byte(g_DemodBuffer + ans + 24, 32);
|
||||
uint8_t checksum = bytebits_to_byte(g_DemodBuffer + ans + 32 + 24, 8);
|
||||
PrintAndLogEx(SUCCESS, "Viking - Card " _GREEN_("%08X") ", Raw: %08X%08X", cardid, raw1, raw2);
|
||||
PrintAndLogEx(DEBUG, "Checksum: %02X", checksum);
|
||||
setDemodBuff(DemodBuffer, 64, ans);
|
||||
setDemodBuff(g_DemodBuffer, 64, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -87,8 +87,8 @@ int demodVisa2k(bool verbose) {
|
|||
save_restoreGB(GRAPH_RESTORE);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectVisa2k(DemodBuffer, &size);
|
||||
size_t size = g_DemodBufferLen;
|
||||
int ans = detectVisa2k(g_DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: too few bits found");
|
||||
|
@ -102,13 +102,13 @@ int demodVisa2k(bool verbose) {
|
|||
save_restoreGB(GRAPH_RESTORE);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(DemodBuffer, 96, ans);
|
||||
setDemodBuff(g_DemodBuffer, 96, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans * g_DemodClock));
|
||||
|
||||
//got a good demod
|
||||
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(DemodBuffer + 64, 32);
|
||||
uint32_t raw1 = bytebits_to_byte(g_DemodBuffer, 32);
|
||||
uint32_t raw2 = bytebits_to_byte(g_DemodBuffer + 32, 32);
|
||||
uint32_t raw3 = bytebits_to_byte(g_DemodBuffer + 64, 32);
|
||||
|
||||
// chksum
|
||||
uint8_t calc = visa_chksum(raw2);
|
||||
|
|
|
@ -46,7 +46,7 @@ size_t ClearGraph(bool redraw) {
|
|||
GraphStart = 0;
|
||||
GraphStop = 0;
|
||||
|
||||
DemodBufferLen = 0;
|
||||
g_DemodBufferLen = 0;
|
||||
if (redraw)
|
||||
RepaintGraphWindow();
|
||||
|
||||
|
|
|
@ -711,8 +711,8 @@ void Plot::paintEvent(QPaintEvent *event) {
|
|||
|
||||
//Start painting graph
|
||||
PlotGraph(GraphBuffer, GraphTraceLen, plotRect, infoRect, &painter, 0);
|
||||
if (showDemod && DemodBufferLen > 8) {
|
||||
PlotDemod(DemodBuffer, DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
|
||||
if (showDemod && g_DemodBufferLen > 8) {
|
||||
PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
|
||||
}
|
||||
if (g_useOverlays) {
|
||||
//init graph variables
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue