mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
chg: unify debug messages for FSK demod in AWID,HID,IO,PARADOX,PYRAMID, all neat and same.
This commit is contained in:
parent
dc0e0aa93f
commit
eae8c2f7be
8 changed files with 153 additions and 117 deletions
|
@ -549,8 +549,13 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt)
|
|||
|
||||
// prepare a waveform pattern in the buffer based on the ID given then
|
||||
// simulate a HID tag until the button is pressed
|
||||
void CmdHIDsimTAG(int hi, int lo, int ledcontrol)
|
||||
{
|
||||
void CmdHIDsimTAG(int hi, int lo, int ledcontrol) {
|
||||
|
||||
if (hi > 0xFFF) {
|
||||
DbpString("Tags can only have 44 bits. - USE lf simfsk for larger tags");
|
||||
return;
|
||||
}
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
set_tracing(false);
|
||||
|
||||
|
@ -565,11 +570,7 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol)
|
|||
nor 1 bits, they are special patterns (a = set of 12 fc8 and b = set of 10 fc10)
|
||||
*/
|
||||
|
||||
if (hi > 0xFFF) {
|
||||
DbpString("Tags can only have 44 bits. - USE lf simfsk for larger tags");
|
||||
return;
|
||||
}
|
||||
fc(0,&n);
|
||||
fc(0, &n);
|
||||
// special start of frame marker containing invalid bit sequences
|
||||
fc(8, &n); fc(8, &n); // invalid
|
||||
fc(8, &n); fc(10, &n); // logical 0
|
||||
|
@ -579,8 +580,10 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol)
|
|||
WDT_HIT();
|
||||
// manchester encode bits 43 to 32
|
||||
for (i=11; i>=0; i--) {
|
||||
if ((i%4)==3) fc(0,&n);
|
||||
if ((hi>>i)&1) {
|
||||
|
||||
if ((i%4)==3) fc(0, &n);
|
||||
|
||||
if ((hi>>i) & 1) {
|
||||
fc(10, &n); fc(8, &n); // low-high transition
|
||||
} else {
|
||||
fc(8, &n); fc(10, &n); // high-low transition
|
||||
|
@ -590,8 +593,10 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol)
|
|||
WDT_HIT();
|
||||
// manchester encode bits 31 to 0
|
||||
for (i=31; i>=0; i--) {
|
||||
if ((i%4)==3) fc(0,&n);
|
||||
if ((lo>>i)&1) {
|
||||
|
||||
if ((i%4)==3) fc(0, &n);
|
||||
|
||||
if ((lo>>i) & 1) {
|
||||
fc(10, &n); fc(8, &n); // low-high transition
|
||||
} else {
|
||||
fc(8, &n); fc(10, &n); // high-low transition
|
||||
|
|
|
@ -248,7 +248,6 @@ int CmdAWIDDemod(const char *Cmd) {
|
|||
}
|
||||
//get binary from fsk wave
|
||||
int waveIdx = 0;
|
||||
|
||||
int idx = detectAWID(bits, &size, &waveIdx);
|
||||
if (idx <= 0){
|
||||
if (g_debugMode){
|
||||
|
@ -261,9 +260,9 @@ int CmdAWIDDemod(const char *Cmd) {
|
|||
else if (idx == -4)
|
||||
PrintAndLog("DEBUG: Error - AWID preamble not found");
|
||||
else if (idx == -5)
|
||||
PrintAndLog("DEBUG: Error - AWID size not correct: %d", size);
|
||||
PrintAndLog("DEBUG: Error - AWID size not correct, size %d", size);
|
||||
else
|
||||
PrintAndLog("DEBUG: Error - AWID error %d",idx);
|
||||
PrintAndLog("DEBUG: Error - AWID error demoding fsk %d",idx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -364,7 +363,7 @@ int CmdAWIDDemod(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (g_debugMode){
|
||||
PrintAndLog("DEBUG: AWID idx: %d, Len: %d Printing Demod Buffer:", idx, 96);
|
||||
PrintAndLog("DEBUG: AWID idx: %d, Len: %d Printing Demod Buffer:", idx, size);
|
||||
printDemodBuff();
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -128,13 +128,15 @@ int CmdHIDDemod(const char *Cmd) {
|
|||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint32_t hi2=0, hi=0, lo=0;
|
||||
|
||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t BitLen = getFromGraphBuf(BitStream);
|
||||
if (BitLen==0) return 0;
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size==0) {
|
||||
PrintAndLog("DEBUG: Error - HID not enough samples");
|
||||
return 0;
|
||||
}
|
||||
//get binary from fsk wave
|
||||
int waveIdx = 0;
|
||||
int idx = HIDdemodFSK(BitStream,&BitLen,&hi2,&hi,&lo, &waveIdx);
|
||||
|
||||
int idx = HIDdemodFSK(bits, &size, &hi2, &hi, &lo, &waveIdx);
|
||||
if (idx < 0) {
|
||||
if (g_debugMode){
|
||||
if (idx==-1){
|
||||
|
@ -146,13 +148,16 @@ int CmdHIDDemod(const char *Cmd) {
|
|||
} else if (idx == -4) {
|
||||
PrintAndLog("DEBUG: Error - HID preamble not found");
|
||||
} else if (idx == -5) {
|
||||
PrintAndLog("DEBUG: Error - HID error in Manchester data, SIZE: %d", BitLen);
|
||||
PrintAndLog("DEBUG: Error - HID error in Manchester data, size %d", size);
|
||||
} else {
|
||||
PrintAndLog("DEBUG: Error - HID error demoding fsk %d", idx);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
setDemodBuf(bits, size, idx);
|
||||
setClockGrid(50, waveIdx + (idx*50));
|
||||
|
||||
if (hi2==0 && hi==0 && lo==0) {
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - HID no values found");
|
||||
|
@ -201,11 +206,8 @@ int CmdHIDDemod(const char *Cmd) {
|
|||
PrintAndLog("HID Prox TAG ID: %x%08x (%u) - Format Len: %ubit - FC: %u - Card: %u", hi, lo, (lo>>1) & 0xFFFF, fmtLen, fc, cardnum);
|
||||
}
|
||||
|
||||
setDemodBuf(BitStream, BitLen, idx);
|
||||
setClockGrid(50, waveIdx + (idx*50));
|
||||
|
||||
if (g_debugMode){
|
||||
PrintAndLog("DEBUG: HID idx: %d, Len: %d, Printing Demod Buffer:", idx, BitLen);
|
||||
PrintAndLog("DEBUG: HID idx: %d, Len: %d, Printing Demod Buffer:", idx, size);
|
||||
printDemodBuff();
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -83,21 +83,15 @@ int CmdIOProxRead_device(const char *Cmd) {
|
|||
int CmdIOProxDemod(const char *Cmd) {
|
||||
int retval = 0;
|
||||
int idx = 0;
|
||||
char crcStr[20];
|
||||
memset(crcStr, 0x00, sizeof(crcStr) );
|
||||
|
||||
//something in graphbuffer?
|
||||
if (GraphTraceLen < 65) {
|
||||
if (g_debugMode)PrintAndLog("DEBUG: Error - IO prox not enough samples in GraphBuffer");
|
||||
return retval;
|
||||
}
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN]={0};
|
||||
size_t bitlen = getFromGraphBuf(bits);
|
||||
if (bitlen == 0) return retval;
|
||||
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size < 65) {
|
||||
if (g_debugMode)PrintAndLog("DEBUG: Error - IO prox not enough samples in GraphBuffer");
|
||||
return 0;
|
||||
}
|
||||
//get binary from fsk wave
|
||||
int waveIdx = 0;
|
||||
//get binary from fsk wave
|
||||
idx = detectIOProx(bits, &bitlen, &waveIdx);
|
||||
idx = detectIOProx(bits, &size, &waveIdx);
|
||||
if (idx < 0){
|
||||
if (g_debugMode){
|
||||
if (idx == -1){
|
||||
|
@ -109,22 +103,25 @@ int CmdIOProxDemod(const char *Cmd) {
|
|||
} else if (idx == -4) {
|
||||
PrintAndLog("DEBUG: Error - IO prox preamble not found");
|
||||
} else if (idx == -5) {
|
||||
PrintAndLog("DEBUG: Error - IO size not correct, size %d", size);
|
||||
} else if (idx == -6) {
|
||||
PrintAndLog("DEBUG: Error - IO prox separator bits not found");
|
||||
} else {
|
||||
PrintAndLog("DEBUG: Error - IO prox error demoding fsk %d", idx);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
setDemodBuf(bits, size, idx);
|
||||
setClockGrid(64, waveIdx + (idx*64));
|
||||
|
||||
if (idx==0){
|
||||
if (g_debugMode){
|
||||
PrintAndLog("DEBUG: Error - IO prox data not found - FSK Bits: %d", bitlen);
|
||||
if (bitlen > 92) PrintAndLog("%s", sprint_bin_break(bits,92,16));
|
||||
PrintAndLog("DEBUG: Error - IO prox data not found - FSK Bits: %d", size);
|
||||
if (size > 92) PrintAndLog("%s", sprint_bin_break(bits, 92, 16));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
setDemodBuf(bits, bitlen, idx);
|
||||
setClockGrid(64, waveIdx + (idx*64));
|
||||
|
||||
//Index map
|
||||
//0 10 20 30 40 50 60
|
||||
|
@ -159,6 +156,9 @@ int CmdIOProxDemod(const char *Cmd) {
|
|||
calccrc &= 0xff;
|
||||
calccrc = 0xff - calccrc;
|
||||
|
||||
char crcStr[20];
|
||||
memset(crcStr, 0x00, sizeof(crcStr) );
|
||||
|
||||
if (crc == calccrc) {
|
||||
snprintf(crcStr, 3, "ok");
|
||||
retval = 1;
|
||||
|
@ -172,7 +172,7 @@ int CmdIOProxDemod(const char *Cmd) {
|
|||
PrintAndLog("IO Prox XSF(%02d)%02x:%05d (%08x%08x) [crc %s]", version, facilitycode, number, code, code2, crcStr);
|
||||
|
||||
if (g_debugMode){
|
||||
PrintAndLog("DEBUG: IO prox idx: %d, Len: %d, Printing demod buffer:", idx, 64);
|
||||
PrintAndLog("DEBUG: IO prox idx: %d, Len: %d, Printing demod buffer:", idx, size);
|
||||
printDemodBuff();
|
||||
}
|
||||
return retval;
|
||||
|
|
|
@ -38,31 +38,37 @@ int usage_lf_paradox_sim(void) {
|
|||
|
||||
// loop to get raw paradox waveform then FSK demodulate the TAG ID from it
|
||||
int detectParadox(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo, int *waveStartIdx) {
|
||||
if (justNoise(dest, *size)) return -1;
|
||||
//make sure buffer has data
|
||||
if (*size < 96*50) return -1;
|
||||
|
||||
if (justNoise(dest, *size)) return -2;
|
||||
|
||||
size_t numStart = 0, startIdx = 0;
|
||||
// FSK demodulator
|
||||
*size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx); //fsk2a
|
||||
if (*size < 96) return -2;
|
||||
*size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx); // paradox fsk2a
|
||||
|
||||
//did we get a good demod?
|
||||
if (*size < 96) return -3;
|
||||
|
||||
// 00001111 bit pattern represent start of frame, 01 pattern represents a 0 and 10 represents a 1
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {0,0,0,0,1,1,1,1};
|
||||
if (preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -3; //preamble not found
|
||||
return -4; //preamble not found
|
||||
|
||||
numStart = startIdx + sizeof(preamble);
|
||||
size_t numStart = startIdx + sizeof(preamble);
|
||||
// final loop, go over previously decoded FSK data and manchester decode into usable tag ID
|
||||
for (size_t idx = numStart; (idx-numStart) < *size - sizeof(preamble); idx+=2){
|
||||
if (dest[idx] == dest[idx+1])
|
||||
return -4; //not manchester data
|
||||
return -5; //not manchester data
|
||||
|
||||
*hi2 = (*hi2 << 1) | (*hi >> 31);
|
||||
*hi = (*hi << 1) | (*lo >> 31);
|
||||
//Then, shift in a 0 or one into low
|
||||
*lo <<= 1;
|
||||
if (dest[idx] && !dest[idx+1]) // 1 0
|
||||
*lo = (*lo << 1) | 1;
|
||||
*lo |= 1;
|
||||
else // 0 1
|
||||
*lo = (*lo << 1) | 0;
|
||||
*lo |= 0;
|
||||
}
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
@ -73,33 +79,43 @@ int detectParadox(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint
|
|||
int CmdParadoxDemod(const char *Cmd) {
|
||||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN]={0};
|
||||
size_t BitLen = getFromGraphBuf(bits);
|
||||
if (BitLen==0) return 0;
|
||||
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size==0) {
|
||||
PrintAndLog("DEBUG: Error - Paradox not enough samples");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t hi2=0, hi=0, lo=0;
|
||||
int waveIdx=0;
|
||||
//get binary from fsk wave
|
||||
int idx = detectParadox(bits, &BitLen, &hi2, &hi, &lo, &waveIdx);
|
||||
int idx = detectParadox(bits, &size, &hi2, &hi, &lo, &waveIdx);
|
||||
if (idx < 0){
|
||||
if (g_debugMode){
|
||||
if (idx == -1){
|
||||
PrintAndLog("DEBUG: Error - Paradox just noise detected");
|
||||
PrintAndLog("DEBUG: Error - Paradox not enough samples");
|
||||
} else if (idx == -2) {
|
||||
PrintAndLog("DEBUG: Error - Paradox error demoding fsk");
|
||||
PrintAndLog("DEBUG: Error - Paradox just noise detected");
|
||||
} else if (idx == -3) {
|
||||
PrintAndLog("DEBUG: Error - Paradox preamble not found");
|
||||
PrintAndLog("DEBUG: Error - Paradox problem during FSK demod");
|
||||
} else if (idx == -4) {
|
||||
PrintAndLog("DEBUG: Error - Paradox error in Manchester data");
|
||||
PrintAndLog("DEBUG: Error - Paradox preamble not found");
|
||||
} else if (idx == -5) {
|
||||
PrintAndLog("DEBUG: Error - Paradox error in Manchester data, size %d", size);
|
||||
} else {
|
||||
PrintAndLog("DEBUG: Error - Paradox error demoding fsk %d", idx);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
setDemodBuf(bits, size, idx);
|
||||
setClockGrid(50, waveIdx + (idx*50));
|
||||
|
||||
if (hi2==0 && hi==0 && lo==0){
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - Paradox no value found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t fc = ((hi & 0x3)<<6) | (lo>>26);
|
||||
uint32_t cardnum = (lo>>10) & 0xFFFF;
|
||||
uint32_t rawLo = bytebits_to_byte(bits + idx + 64, 32);
|
||||
|
@ -115,12 +131,9 @@ int CmdParadoxDemod(const char *Cmd) {
|
|||
rawHi,
|
||||
rawLo
|
||||
);
|
||||
|
||||
setDemodBuf(bits, BitLen, idx);
|
||||
setClockGrid(50, waveIdx + (idx*50));
|
||||
|
||||
if (g_debugMode){
|
||||
PrintAndLog("DEBUG: Paradox idx: %d, len: %d, Printing Demod Buffer:", idx, BitLen);
|
||||
PrintAndLog("DEBUG: Paradox idx: %d, len: %d, Printing Demod Buffer:", idx, size);
|
||||
printDemodBuff();
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -47,19 +47,25 @@ int usage_lf_pyramid_sim(void) {
|
|||
// FSK Demod then try to locate a Farpointe Data (pyramid) ID
|
||||
int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
||||
//make sure buffer has data
|
||||
if (*size < 128*50) return -5;
|
||||
if (*size < 128*50) return -1;
|
||||
|
||||
//test samples are not just noise
|
||||
if (justNoise(dest, *size)) return -1;
|
||||
if (justNoise(dest, *size)) return -2;
|
||||
|
||||
// FSK demodulator RF/50 FSK 10,8
|
||||
*size = fskdemod(dest, *size, 50, 0, 10, 8, waveStartIdx); // pyramid fsk2
|
||||
|
||||
//did we get a good demod?
|
||||
if (*size < 128) return -3;
|
||||
|
||||
// FSK demodulator
|
||||
*size = fskdemod(dest, *size, 50, 0, 10, 8, waveStartIdx); // fsk2 RF/50
|
||||
if (*size < 128) return -2; //did we get a good demod?
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -4; //preamble not found
|
||||
if (*size != 128) return -3;
|
||||
|
||||
// wrong size? (between to preambles)
|
||||
if (*size != 128) return -5;
|
||||
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
|
@ -99,30 +105,35 @@ int GetPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
|
|||
//print full Farpointe Data/Pyramid Prox ID and some bit format details if found
|
||||
int CmdPyramidDemod(const char *Cmd) {
|
||||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
|
||||
size_t size = getFromGraphBuf(BitStream);
|
||||
if (size==0) return 0;
|
||||
|
||||
int waveIdx=0;
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN]={0};
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size==0) {
|
||||
PrintAndLog("DEBUG: Error - Pyramid not enough samples");
|
||||
return 0;
|
||||
}
|
||||
//get binary from fsk wave
|
||||
int idx = detectPyramid(BitStream, &size, &waveIdx);
|
||||
int waveIdx=0;
|
||||
int idx = detectPyramid(bits, &size, &waveIdx);
|
||||
if (idx < 0){
|
||||
if (g_debugMode){
|
||||
if (idx == -5)
|
||||
if (idx == -1)
|
||||
PrintAndLog("DEBUG: Error - Pyramid: not enough samples");
|
||||
else if (idx == -1)
|
||||
PrintAndLog("DEBUG: Error - Pyramid: only noise found");
|
||||
else if (idx == -2)
|
||||
PrintAndLog("DEBUG: Error - Pyramid: problem during FSK demod");
|
||||
PrintAndLog("DEBUG: Error - Pyramid: only noise found");
|
||||
else if (idx == -3)
|
||||
PrintAndLog("DEBUG: Error - Pyramid: size not correct: %d", size);
|
||||
PrintAndLog("DEBUG: Error - Pyramid: problem during FSK demod");
|
||||
else if (idx == -4)
|
||||
PrintAndLog("DEBUG: Error - Pyramid: preamble not found");
|
||||
PrintAndLog("DEBUG: Error - Pyramid: preamble not found");
|
||||
else if (idx == -5)
|
||||
PrintAndLog("DEBUG: Error - Pyramid: size not correct: %d", size);
|
||||
else
|
||||
PrintAndLog("DEBUG: Error - Pyramid: idx: %d",idx);
|
||||
PrintAndLog("DEBUG: Error - Pyramid: error demoding fsk idx: %d",idx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
setDemodBuf(bits, size, idx);
|
||||
setClockGrid(50, waveIdx + (idx*50));
|
||||
|
||||
// Index map
|
||||
// 0 10 20 30 40 50 60
|
||||
// | | | | | | |
|
||||
|
@ -145,24 +156,22 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
// (26 bit format shown)
|
||||
|
||||
//get bytes for checksum calc
|
||||
uint8_t checksum = bytebits_to_byte(BitStream + idx + 120, 8);
|
||||
uint8_t checksum = bytebits_to_byte(bits + idx + 120, 8);
|
||||
uint8_t csBuff[14] = {0x00};
|
||||
for (uint8_t i = 0; i < 13; i++){
|
||||
csBuff[i] = bytebits_to_byte(BitStream + idx + 16 + (i*8), 8);
|
||||
csBuff[i] = bytebits_to_byte(bits + idx + 16 + (i*8), 8);
|
||||
}
|
||||
//check checksum calc
|
||||
//checksum calc thanks to ICEMAN!!
|
||||
uint32_t checkCS = CRC8Maxim(csBuff, 13);
|
||||
|
||||
//get raw ID before removing parities
|
||||
uint32_t rawLo = bytebits_to_byte(BitStream+idx+96, 32);
|
||||
uint32_t rawHi = bytebits_to_byte(BitStream+idx+64, 32);
|
||||
uint32_t rawHi2 = bytebits_to_byte(BitStream+idx+32, 32);
|
||||
uint32_t rawHi3 = bytebits_to_byte(BitStream+idx, 32);
|
||||
setDemodBuf(BitStream, 128, idx);
|
||||
setClockGrid(50, waveIdx + (idx*50));
|
||||
uint32_t rawLo = bytebits_to_byte(bits+idx+96, 32);
|
||||
uint32_t rawHi = bytebits_to_byte(bits+idx+64, 32);
|
||||
uint32_t rawHi2 = bytebits_to_byte(bits+idx+32, 32);
|
||||
uint32_t rawHi3 = bytebits_to_byte(bits+idx, 32);
|
||||
|
||||
size = removeParity(BitStream, idx+8, 8, 1, 120);
|
||||
size = removeParity(bits, idx+8, 8, 1, 120);
|
||||
if (size != 105){
|
||||
if (g_debugMode) {
|
||||
if ( size == 0)
|
||||
|
@ -199,7 +208,7 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
//find start bit to get fmtLen
|
||||
int j;
|
||||
for (j=0; j < size; ++j){
|
||||
if(BitStream[j]) break;
|
||||
if(bits[j]) break;
|
||||
}
|
||||
|
||||
uint8_t fmtLen = size-j-8;
|
||||
|
@ -208,23 +217,23 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
uint32_t code1 = 0;
|
||||
|
||||
if ( fmtLen == 26 ){
|
||||
fc = bytebits_to_byte(BitStream+73, 8);
|
||||
cardnum = bytebits_to_byte(BitStream+81, 16);
|
||||
code1 = bytebits_to_byte(BitStream+72,fmtLen);
|
||||
fc = bytebits_to_byte(bits+73, 8);
|
||||
cardnum = bytebits_to_byte(bits+81, 16);
|
||||
code1 = bytebits_to_byte(bits+72,fmtLen);
|
||||
PrintAndLog("Pyramid ID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x, Raw: %08x%08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi3, rawHi2, rawHi, rawLo);
|
||||
} else if (fmtLen == 45) {
|
||||
fmtLen = 42; //end = 10 bits not 7 like 26 bit fmt
|
||||
fc = bytebits_to_byte(BitStream+53, 10);
|
||||
cardnum = bytebits_to_byte(BitStream+63, 32);
|
||||
fc = bytebits_to_byte(bits+53, 10);
|
||||
cardnum = bytebits_to_byte(bits+63, 32);
|
||||
PrintAndLog("Pyramid ID Found - BitLength: %d, FC: %d, Card: %d - Raw: %08x%08x%08x%08x", fmtLen, fc, cardnum, rawHi3, rawHi2, rawHi, rawLo);
|
||||
} else {
|
||||
cardnum = bytebits_to_byte(BitStream+81, 16);
|
||||
cardnum = bytebits_to_byte(bits+81, 16);
|
||||
if (fmtLen>32){
|
||||
//code1 = bytebits_to_byte(BitStream+(size-fmtLen),fmtLen-32);
|
||||
//code2 = bytebits_to_byte(BitStream+(size-32),32);
|
||||
//code1 = bytebits_to_byte(bits+(size-fmtLen),fmtLen-32);
|
||||
//code2 = bytebits_to_byte(bits+(size-32),32);
|
||||
PrintAndLog("Pyramid ID Found - BitLength: %d -unknown BitLength- (%d), Raw: %08x%08x%08x%08x", fmtLen, cardnum, rawHi3, rawHi2, rawHi, rawLo);
|
||||
} else{
|
||||
//code1 = bytebits_to_byte(BitStream+(size-fmtLen),fmtLen);
|
||||
//code1 = bytebits_to_byte(bits+(size-fmtLen),fmtLen);
|
||||
PrintAndLog("Pyramid ID Found - BitLength: %d -unknown BitLength- (%d), Raw: %08x%08x%08x%08x", fmtLen, cardnum, rawHi3, rawHi2, rawHi, rawLo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea
|
|||
if ( breaks > 0 && len % breaks != 0)
|
||||
rowlen = ( len+(len/breaks) > MAX_BIN_BREAK_LENGTH ) ? MAX_BIN_BREAK_LENGTH : len+(len/breaks);
|
||||
|
||||
printf("(sprint_bin_break) rowlen %d\n", rowlen);
|
||||
//printf("(sprint_bin_break) rowlen %d\n", rowlen);
|
||||
|
||||
static char buf[MAX_BIN_BREAK_LENGTH]; // 3072 + end of line characters if broken at 8 bits
|
||||
//clear memory
|
||||
|
|
|
@ -1428,16 +1428,19 @@ int nrzRawDemod(uint8_t *dest, size_t *size, int *clk, int *invert, int *startId
|
|||
|
||||
//translate wave to 11111100000 (1 for each short wave [higher freq] 0 for each long wave [lower freq])
|
||||
size_t fsk_wave_demod(uint8_t * dest, size_t size, uint8_t fchigh, uint8_t fclow, int *startIdx) {
|
||||
size_t last_transition = 0;
|
||||
size_t idx = 1;
|
||||
|
||||
if ( size < 1024 ) return 0; // not enough samples
|
||||
|
||||
if (fchigh == 0) fchigh = 10;
|
||||
if (fclow == 0) fclow = 8;
|
||||
|
||||
//set the threshold close to 0 (graph) or 128 std to avoid static
|
||||
size_t preLastSample = 0;
|
||||
size_t LastSample = 0;
|
||||
size_t currSample = 0;
|
||||
if ( size < 1024 ) return 0; // not enough samples
|
||||
|
||||
size_t last_transition = 0;
|
||||
size_t idx = 1;
|
||||
|
||||
//find start of modulating data in trace
|
||||
idx = findModStart(dest, size, fchigh);
|
||||
// Need to threshold first sample
|
||||
|
@ -1685,16 +1688,19 @@ int detectAWID(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
|||
if (justNoise(dest, *size)) return -2;
|
||||
|
||||
// FSK2a demodulator clock 50, invert 1, fcHigh 10, fcLow 8
|
||||
*size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx);
|
||||
*size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx); //awid fsk2a
|
||||
|
||||
//did we get a good demod?
|
||||
if (*size < 96) return -3;
|
||||
|
||||
uint8_t preamble[] = {0,0,0,0,0,0,0,1};
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {0,0,0,0,0,0,0,1};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -4; //preamble not found
|
||||
|
||||
// wrong size? (between to preambles)
|
||||
if (*size != 96) return -5;
|
||||
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
|
@ -1746,19 +1752,18 @@ int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32
|
|||
if (justNoise(dest, *size)) return -2;
|
||||
|
||||
// FSK demodulator fsk2a so invert and fc/10/8
|
||||
*size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx);
|
||||
*size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx); //hid fsk2a
|
||||
|
||||
//did we get a good demod?
|
||||
if (*size < 96*2) return -3;
|
||||
|
||||
// 00011101 bit pattern represent start of frame, 01 pattern represents a 0 and 10 represents a 1
|
||||
uint8_t preamble[] = {0,0,0,1,1,1,0,1};
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {0,0,0,1,1,1,0,1};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -4; //preamble not found
|
||||
|
||||
size_t numStart = 0;
|
||||
numStart = startIdx + sizeof(preamble);
|
||||
size_t numStart = startIdx + sizeof(preamble);
|
||||
// final loop, go over previously decoded FSK data and manchester decode into usable tag ID
|
||||
for (size_t idx = numStart; (idx-numStart) < *size - sizeof(preamble); idx+=2){
|
||||
if (dest[idx] == dest[idx+1]){
|
||||
|
@ -1796,7 +1801,7 @@ int detectIOProx(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
|||
if (justNoise(dest, *size)) return -2;
|
||||
|
||||
// FSK demodulator RF/64, fsk2a so invert, and fc/10/8
|
||||
*size = fskdemod(dest, *size, 64, 1, 10, 8, waveStartIdx);
|
||||
*size = fskdemod(dest, *size, 64, 1, 10, 8, waveStartIdx); //io fsk2a
|
||||
|
||||
//did we get a good demod?
|
||||
if (*size < 64) return -3;
|
||||
|
@ -1810,15 +1815,18 @@ int detectIOProx(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
|||
//
|
||||
//XSF(version)facility:codeone+codetwo
|
||||
|
||||
uint8_t preamble[] = {0,0,0,0,0,0,0,0,0,1};
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {0,0,0,0,0,0,0,0,0,1};
|
||||
if (! preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -4; //preamble not found
|
||||
|
||||
// wrong size? (between to preambles)
|
||||
if (*size != 64) return -5;
|
||||
|
||||
if (!dest[startIdx+8] && dest[startIdx+17]==1 && dest[startIdx+26]==1 && dest[startIdx+35]==1 && dest[startIdx+44]==1 && dest[startIdx+53]==1){
|
||||
//confirmed proper separator bits found
|
||||
//return start position
|
||||
return (int) startIdx;
|
||||
}
|
||||
return -5;
|
||||
return -6;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue