mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -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
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue