From: iceman1001 Date: Mon, 16 Mar 2015 12:13:18 +0000 (+0100) Subject: Merge branch 'master' of https://github.com/Proxmark/proxmark3 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/05446d5bc3d9263efc6a12026f6cf84bb421735e Merge branch 'master' of https://github.com/Proxmark/proxmark3 Conflicts: armsrc/lfops.c client/cmddata.c common/crc.c common/crc.h common/lfdemod.c include/crc.h include/crc.h.old --- 05446d5bc3d9263efc6a12026f6cf84bb421735e diff --cc armsrc/lfops.c index 59bbb8a6,2a5573d1..c2057884 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@@ -635,20 -651,34 +649,34 @@@ void CmdASKsimTag(uint16_t arg1, uint16 int ledcontrol = 1; int n=0, i=0; uint8_t clk = (arg1 >> 8) & 0xFF; - uint8_t manchester = arg1 & 1; + uint8_t encoding = arg1 & 1; uint8_t separator = arg2 & 1; uint8_t invert = (arg2 >> 8) & 1; + + if (encoding==2){ //biphase + uint8_t phase=0; - for (i=0; i=0){ - lo = Em410xDecode(dest, &size, &idx); + errCnt = Em410xDecode(dest, &size, &idx, &hi, &lo); //Dbprintf("DEBUG: EM GOT"); - if (lo>0){ + if (errCnt){ + if (size>64){ + Dbprintf("EM XL TAG ID: %06x%08x%08x - (%05d_%03d_%08d)", + hi, + (uint32_t)(lo>>32), + (uint32_t)lo, + (uint32_t)(lo&0xFFFF), + (uint32_t)((lo>>16LL) & 0xFF), + (uint32_t)(lo & 0xFFFFFF)); + } else { - Dbprintf("EM TAG ID: %02x%08x - (%05d_%03d_%08d)", - (uint32_t)(lo>>32), - (uint32_t)lo, - (uint32_t)(lo&0xFFFF), - (uint32_t)((lo>>16LL) & 0xFF), - (uint32_t)(lo & 0xFFFFFF)); - } + Dbprintf("EM TAG ID: %02x%08x - (%05d_%03d_%08d)", + (uint32_t)(lo>>32), + (uint32_t)lo, + (uint32_t)(lo&0xFFFF), + (uint32_t)((lo>>16LL) & 0xFF), + (uint32_t)(lo & 0xFFFFFF)); + } + } if (findone){ if (ledcontrol) LED_A_OFF(); *high=lo>>32; diff --cc client/cmddata.c index 9b88d832,a3d58523..ceec9489 --- a/client/cmddata.c +++ b/client/cmddata.c @@@ -277,16 -272,21 +278,21 @@@ void printEM410x(uint32_t hi, uint64_t id2lo=(id2lo<<1LL) | ((id & (iii << (i+((ii-1)*8)))) >> (i+((ii-1)*8))); } } - //output em id + if (hi){ + //output 88 bit em id + PrintAndLog("EM TAG ID : %06x%016llx", hi, id); + } else{ + //output 40 bit em id - PrintAndLog("EM TAG ID : %010llx", id); - PrintAndLog("Unique TAG ID: %010llx", id2lo); - PrintAndLog("DEZ 8 : %08lld",id & 0xFFFFFF); - PrintAndLog("DEZ 10 : %010lld",id & 0xFFFFFF); - PrintAndLog("DEZ 5.5 : %05lld.%05lld",(id>>16LL) & 0xFFFF,(id & 0xFFFF)); - PrintAndLog("DEZ 3.5A : %03lld.%05lld",(id>>32ll),(id & 0xFFFF)); - PrintAndLog("DEZ 14/IK2 : %014lld",id); - PrintAndLog("DEZ 15/IK3 : %015lld",id2lo); + PrintAndLog("EM TAG ID : %010llx", id); + PrintAndLog("Unique TAG ID: %010llx", id2lo); + PrintAndLog("DEZ 8 : %08lld",id & 0xFFFFFF); + PrintAndLog("DEZ 10 : %010lld",id & 0xFFFFFF); + PrintAndLog("DEZ 5.5 : %05lld.%05lld",(id>>16LL) & 0xFFFF,(id & 0xFFFF)); + PrintAndLog("DEZ 3.5A : %03lld.%05lld",(id>>32ll),(id & 0xFFFF)); + PrintAndLog("DEZ 14/IK2 : %014lld",id); + PrintAndLog("DEZ 15/IK3 : %015lld",id2lo); - PrintAndLog("Other : %05lld_%03lld_%08lld",(id&0xFFFF),((id>>16LL) & 0xFF),(id & 0xFFFFFF)); + PrintAndLog("Other : %05lld_%03lld_%08lld",(id&0xFFFF),((id>>16LL) & 0xFF),(id & 0xFFFFFF)); - } ++ } } return; } @@@ -625,33 -658,17 +664,17 @@@ int Cmdaskbiphdemod(const char *Cmd //if successful it will push askraw data back to demod buffer ready for emulation int CmdG_Prox_II_Demod(const char *Cmd) { - int ans = ASKrawDemod(Cmd, FALSE); - if (ans <= 0) { - if (g_debugMode) PrintAndLog("Error AskrawDemod: %d",ans); - return ans; + if (!ASKbiphaseDemod(Cmd, FALSE)){ + if (g_debugMode) PrintAndLog("ASKbiphaseDemod failed 1st try"); + return 0; } size_t size = DemodBufferLen; - ans = BiphaseRawDecode(DemodBuffer, &size, 0, 0); - if (ans !=0) { - if (g_debugMode) PrintAndLog("Error BiphaseRawDecode: %d",ans); - return ans; - } //call lfdemod.c demod for gProxII - ans = gProxII_Demod(DemodBuffer, &size); + int ans = gProxII_Demod(DemodBuffer, &size); if (ans < 0){ - if (g_debugMode) PrintAndLog("Error gProxII_Demod 1st Try: %d",ans); - //try biphase again - ans = BiphaseRawDecode(DemodBuffer, &size, 1, 0); - if (ans != 0) { - if (g_debugMode) PrintAndLog("Error BiphaseRawDecode: %d",ans); - return ans; - } - ans = gProxII_Demod(DemodBuffer, &size); - if (ans < 0) { - if (g_debugMode) PrintAndLog("Error gProxII_Demod 1st Try: %d",ans); - return ans; + if (g_debugMode) PrintAndLog("Error gProxII_Demod"); + return 0; - } + } - } //got a good demod uint32_t ByteStream[65] = {0x00}; uint8_t xorKey=0; @@@ -759,11 -765,45 +771,45 @@@ int AutoCorrelate(int window, bool Save sum += (GraphBuffer[j]*GraphBuffer[i + j]) / 256; } CorrelBuffer[i] = sum; + if (sum >= maxSum-100 && sum <= maxSum+100){ + //another max + Correlation = i-lastMax; + lastMax = i; + if (sum > maxSum) maxSum = sum; + } else if (sum > maxSum){ + maxSum=sum; + lastMax = i; - } ++ } + } + if (Correlation==0){ + //try again with wider margin + for (int i = 0; i < GraphTraceLen - window; i++){ + if (CorrelBuffer[i] >= maxSum-(maxSum*0.05) && CorrelBuffer[i] <= maxSum+(maxSum*0.05)){ + //another max + Correlation = i-lastMax; + lastMax = i; + //if (CorrelBuffer[i] > maxSum) maxSum = sum; + } + } } + if (verbose && Correlation > 0) PrintAndLog("Possible Correlation: %d samples",Correlation); + + if (SaveGrph){ - GraphTraceLen = GraphTraceLen - window; - memcpy(GraphBuffer, CorrelBuffer, GraphTraceLen * sizeof (int)); + GraphTraceLen = GraphTraceLen - window; + memcpy(GraphBuffer, CorrelBuffer, GraphTraceLen * sizeof (int)); + RepaintGraphWindow(); + } + return Correlation; + } - RepaintGraphWindow(); + int usage_data_autocorr(void) + { + //print help + PrintAndLog("Usage: data autocorr [window] [g]"); + PrintAndLog("Options: "); + PrintAndLog(" h This help"); + PrintAndLog(" [window] window length for correlation - default = 4000"); + PrintAndLog(" g save back to GraphBuffer (overwrite)"); return 0; } diff --cc common/lfdemod.c index a14f2613,0a81c6b8..7ab8a388 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@@ -1604,30 -1603,25 +1603,25 @@@ int pskRawDemod(uint8_t dest[], size_t //find first phase shift for (i=0; i= dest[i+2]){ - if (waveStart == 0) { - waveStart = i+1; - avgWaveVal=dest[i+1]; - //PrintAndLog("DEBUG: waveStart: %d",waveStart); - } else { - waveEnd = i+1; - //PrintAndLog("DEBUG: waveEnd: %d",waveEnd); - waveLenCnt = waveEnd-waveStart; + waveEnd = i+1; + //PrintAndLog("DEBUG: waveEnd: %d",waveEnd); + waveLenCnt = waveEnd-waveStart; - lastAvgWaveVal = avgWaveVal/waveLenCnt; - if (waveLenCnt > fc){ + if (waveLenCnt > fc && waveStart > fc){ //not first peak and is a large wave + lastAvgWaveVal = avgWaveVal/(waveLenCnt); - firstFullWave = waveStart; - fullWaveLen=waveLenCnt; - //if average wave value is > graph 0 then it is an up wave or a 1 + firstFullWave = waveStart; + fullWaveLen=waveLenCnt; + //if average wave value is > graph 0 then it is an up wave or a 1 - if (lastAvgWaveVal > 128) curPhase^=1; + if (lastAvgWaveVal > 123) curPhase^=1; //fudge graph 0 a little 123 vs 128 - break; - } + break; + } - waveStart=0; - avgWaveVal=0; + waveStart = i+1; + avgWaveVal = 0; - } + } + avgWaveVal+=dest[i+2]; - } + } - avgWaveVal+=dest[i+1]; - } //PrintAndLog("DEBUG: firstFullWave: %d, waveLen: %d",firstFullWave,fullWaveLen); lastClkBit = firstFullWave; //set start of wave as clock align + //PrintAndLog("DEBUG: clk: %d, lastClkBit: %d", *clock, lastClkBit); waveStart = 0; errCnt=0; size_t numBits=0;