]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge branch 'master' of https://github.com/Proxmark/proxmark3
authoriceman1001 <iceman@iuse.se>
Mon, 16 Mar 2015 12:13:18 +0000 (13:13 +0100)
committericeman1001 <iceman@iuse.se>
Mon, 16 Mar 2015 12:13:18 +0000 (13:13 +0100)
Conflicts:
armsrc/lfops.c
client/cmddata.c
common/crc.c
common/crc.h
common/lfdemod.c
include/crc.h
include/crc.h.old

1  2 
armsrc/lfops.c
client/cmddata.c
client/cmddata.h
client/cmdhfmf.c
client/cmdlf.c
common/lfdemod.c

diff --cc armsrc/lfops.c
index 59bbb8a625a77a02d62244623a17001a4871dbee,2a5573d1cf156a6125c872bc16f19072fa5b8020..c205788440835c8857a8c0838d08d8f038ce7a1a
@@@ -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;
 -        for (i=0; i<size; i++){
+     if (encoding==2){  //biphase
+         uint8_t phase=0;
-         askSimBit(BitStream[i]^invert, &n, clk, manchester);
 +    for (i=0; i<size; i++){
 -        }
+             biphaseSimBit(BitStream[i]^invert, &n, clk, &phase);
-     if (manchester==0 && BitStream[0]==BitStream[size-1]){ //run a second set inverted (for biphase phase)
 +    }
 -            for (i=0; i<size; i++){
+         if (BitStream[0]==BitStream[size-1]){ //run a second set inverted to keep phase in check
-             askSimBit(BitStream[i]^invert^1, &n, clk, manchester);
 +        for (i=0; i<size; i++){
 -            }    
+                 biphaseSimBit(BitStream[i]^invert, &n, clk, &phase);
+             }
+         }
+     } else {  // ask/manchester || ask/raw
+         for (i=0; i<size; i++){
+             askSimBit(BitStream[i]^invert, &n, clk, encoding);
+         }
+         if (encoding==0 && BitStream[0]==BitStream[size-1]){ //run a second set inverted (for biphase phase)
+             for (i=0; i<size; i++){
+                 askSimBit(BitStream[i]^invert^1, &n, clk, encoding);
++        }    
          }    
      }
+     
      if (separator==1) Dbprintf("sorry but separator option not yet available"); 
  
-     Dbprintf("Simulating with clk: %d, invert: %d, manchester: %d, separator: %d, n: %d",clk, invert, manchester, separator, n);
+     Dbprintf("Simulating with clk: %d, invert: %d, encoding: %d, separator: %d, n: %d",clk, invert, encoding, separator, n);
      //DEBUG
      //Dbprintf("First 32:");
      //uint8_t *dest = BigBuf_get_addr();
@@@ -815,8 -845,9 +843,9 @@@ void CmdEM410xdemod(int findone, int *h
  {
      uint8_t *dest = BigBuf_get_addr();
  
 -    size_t size=0, idx=0;
 +      size_t size=0, idx=0;
      int clk=0, invert=0, errCnt=0, maxErr=20;
+     uint32_t hi=0;
      uint64_t lo=0;
      // Configure to go in 125Khz listen mode
      LFSetupFPGAForADC(95, true);
          WDT_HIT();
  
          if (errCnt>=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;
index 9b88d83230c03a54ab728ca51df339cdf6a14b5d,a3d58523ff2d610540eedb31d6aa497b4d458e96..ceec94893858fb60ecfe145794ea19b967d2b49f
@@@ -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;
+       }
+     }
    }
 -    GraphTraceLen = GraphTraceLen - window;
 -    memcpy(GraphBuffer, CorrelBuffer, GraphTraceLen * sizeof (int));
+   if (verbose && Correlation > 0) PrintAndLog("Possible Correlation: %d samples",Correlation);
+   if (SaveGrph){
 +  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;
  }
  
Simple merge
Simple merge
diff --cc client/cmdlf.c
Simple merge
index a14f2613fd11817bac9a7998357b23e13444205f,0a81c6b8fdd1818239830beb3a67f21e2a4ae16a..7ab8a38815771ef2f7598243788a31fc01707b7e
@@@ -1604,30 -1603,25 +1603,25 @@@ int pskRawDemod(uint8_t dest[], size_t 
    //find first phase shift
    for (i=0; i<loopCnt; i++){
      if (dest[i]+fc < dest[i+1] && dest[i+1] >= 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;
Impressum, Datenschutz