]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
CHG: 'lf cotag demod' - now finds FC/CN Thanks to @marshmellow42
authoriceman1001 <iceman@iuse.se>
Thu, 2 Feb 2017 18:15:36 +0000 (19:15 +0100)
committericeman1001 <iceman@iuse.se>
Thu, 2 Feb 2017 18:15:36 +0000 (19:15 +0100)
CHG:  'lf search' - now detects COTAG

armsrc/lfsampling.c
client/cmdlf.c
client/cmdlfcotag.c
client/cmdlfcotag.h
client/cmdlfjablotron.c
include/proxmark3.h

index 841bfab86313f15343befefa4bf8d6b887e5fa99..def7431ded510908bb3572da80fe486586031d65 100644 (file)
@@ -371,8 +371,8 @@ uint32_t doCotagAcquisitionManchester() {
        uint8_t *dest = BigBuf_get_addr();
        uint16_t bufsize = BigBuf_max_traceLen();
        
-       if ( bufsize > 320 )
-               bufsize = 320;
+       if ( bufsize > COTAG_BITS )
+               bufsize = COTAG_BITS;
 
        dest[0] = 0;    
        uint8_t sample = 0, firsthigh = 0, firstlow = 0; 
index 31e747d332aba32b6d3cfb1bdd5100db36010434..8931fc757ad0b17ad81545d1b4a7eed4f45b6150 100644 (file)
@@ -1116,6 +1116,14 @@ int CmdLFfind(const char *Cmd) {
                PrintAndLog("\nValid Presco ID Found!");
                return 1;
        }
+       // ICEMAN;  always call save_restorGB for COTAG. Will break graphbuffer
+       save_restoreGB(1)
+       ans=CmdCOTAGRead("");
+       if (ans>0){
+               PrintAndLog("\nValid COTAG ID Found!");
+               return 1;
+       }
+       save_restoreGB(0)
        // TIdemod?
 
 /*     
@@ -1126,7 +1134,6 @@ int CmdLFfind(const char *Cmd) {
                }
        }
 */
-
        PrintAndLog("\nNo Known Tags Found!\n");
        if (testRaw=='u' || testRaw=='U'){
                //test unknown tag formats (raw mode)
index ef935bb0daf737081682f754213e0717a79a899c..3c1c3caa0553c64322b71c66c9fad2d4f6edb728 100644 (file)
@@ -8,7 +8,7 @@
 // Low frequency COTAG commands
 //-----------------------------------------------------------------------------
 #include "cmdlfcotag.h"  // COTAG function declarations
+
 static int CmdHelp(const char *Cmd);
 
 int usage_lf_cotag_read(void){
@@ -24,8 +24,37 @@ int usage_lf_cotag_read(void){
        PrintAndLog("        lf cotag read 1");
        return 0;
 }
+
+// COTAG demod should be able to use GraphBuffer,
+// when data load samples
 int CmdCOTAGDemod(const char *Cmd) {
-       return 0;
+
+       uint8_t bits[COTAG_BITS] = {0};
+       size_t bitlen = COTAG_BITS;
+       memcpy(bits, DemodBuffer, COTAG_BITS);
+       
+       int err = manrawdecode(bits, &bitlen, 1);
+       if (err){
+               if (g_debugMode) PrintAndLog("DEBUG: Error - COTAG too many errors: %d", err);
+               return -1;
+       }
+
+       setDemodBuf(bits, bitlen, 0);
+
+       //got a good demod
+       uint16_t cn = bytebits_to_byteLSBF(bits+1, 16);
+       uint32_t fc = bytebits_to_byteLSBF(bits+1+16, 8);
+       
+       /*
+       fc 161:   1010 0001 -> LSB 1000 0101
+       cn 33593  1000 0011 0011 1001 -> LSB 1001 1100 1100 0001
+        cccc cccc cccc cccc                     ffffffff
+         0 1001 1100 1100 0001 1000 0101 0000 0000 100001010000000001111011100000011010000010000000000000000000000000000000000000000000000000000000100111001100000110000101000
+        1001 1100 1100 0001                     10000101                                                                                         
+       */
+       //PrintAndLog("COTAG Found: FC %u, CN: %u Raw: %08X%08X%08X", fc, cn); //, raw1 ,raw2, raw3);
+       PrintAndLog("COTAG Found: FC %u, CN: %u", fc, cn); 
+       return 1;
 }
 
 // When reading a COTAG.
@@ -36,8 +65,7 @@ int CmdCOTAGRead(const char *Cmd) {
        
        if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_cotag_read();
        
-       uint8_t bits[320] = {0};
-       uint32_t rawsignal = 0;
+       uint32_t rawsignal = 1;
        sscanf(Cmd, "%u", &rawsignal);
  
        UsbCommand c = {CMD_COTAG, {rawsignal, 0, 0}};
@@ -45,7 +73,7 @@ int CmdCOTAGRead(const char *Cmd) {
        SendCommand(&c);
        if ( !WaitForResponseTimeout(CMD_ACK, NULL, 7000) ) {
                PrintAndLog("command execution time out");
-               return 1;       
+               return -1;      
        }
        
        switch ( rawsignal ){
@@ -56,24 +84,14 @@ int CmdCOTAGRead(const char *Cmd) {
                        getSamples("", true); break;
                }
                case 1: {
-                       GetFromBigBuf(bits, sizeof(bits), 0);
+                       GetFromBigBuf(DemodBuffer, COTAG_BITS, 0);
+                       DemodBufferLen = COTAG_BITS;
                        UsbCommand response;
-                       if ( !WaitForResponseTimeout(CMD_ACK, &response, 500) ) {
-                               if (g_debugMode) PrintAndLog("timeout while waiting for reply.");
-                               return 1;
-                       }
-                       
-                       size_t size = sizeof(bits);
-                       int err = manrawdecode(bits, &size, 1);
-                       if (err){
-                               if (g_debugMode) PrintAndLog("DEBUG: Error - COTAG too many errors: %d", err);
-                               return 0;
+                       if ( !WaitForResponseTimeout(CMD_ACK, &response, 1000) ) {
+                               PrintAndLog("timeout while waiting for reply.");
+                               return -1;
                        }
-                       PrintAndLog("%s", sprint_bin(bits, size));
-                       setDemodBuf(bits, size, 0);
-                       
-                       // CmdCOTAGDemod();
-                       break;
+                       return CmdCOTAGDemod("");
                }
        }       
        return 0;
index ab808b4015abb292b6103459674ffbb0388c7644..265f60d965898ae865521fd7c8ca842a5b3641c9 100644 (file)
 #ifndef CMDLFCOTAG_H__
 #define CMDLFCOTAG_H__
 
+#include "proxmark3.h"  // Definitions, USB controls, COTAG_BITS
 #include "util.h"       // FALSE / TRUE
-#include "proxmark3.h"  // Definitions, USB controls, etc
 #include "cmddata.h"   // getSamples
 #include "cmdparser.h"  // CmdsParse, CmdsHelp
 #include "cmdmain.h"
 #include "ui.h"                        // PrintAndLog
 #include "cmdlf.h"             // Setconfig 
 
+#ifndef COTAG_BITS
+#define COTAG_BITS 320
+#endif
+
 int CmdLFCOTAG(const char *Cmd);
 int CmdCOTAGRead(const char *Cmd);
 int CmdCOTAGDemod(const char *Cmd);
index 95fe2922bf6880c5e3c073b1e18874478718bf30..f1da737db610f981e940a4c1098438c734694951 100644 (file)
@@ -105,8 +105,7 @@ int CmdJablotronDemod(const char *Cmd) {
        uint64_t rawid = bytebits_to_byte(DemodBuffer+16, 40);
        uint64_t id = getJablontronCardId(rawid);
 
-       PrintAndLog("Jablotron Tag Found: Card ID %u", id);
-       PrintAndLog("Raw: %08X%08X", raw1 ,raw2);
+       PrintAndLog("Jablotron Tag Found: Card ID %u  :: Raw: %08X%08X", id, raw1 ,raw2);
 
        uint8_t chksum = raw2 & 0xFF;
        PrintAndLog("Checksum: %02X [%s]",
index 4a59636e7f6cc156e438a332208116ccd3eb9439..4fb1a30b4060ffa7c11b7ca1a72712041b94f085 100644 (file)
 #define TRUE 1
 #define FALSE 0
 
+#ifndef COTAG_BITS
+#define COTAG_BITS 320
+#endif
+
 //#define PACKED __attribute__((__packed__))
 
 #define LED_A_ON()             HIGH(GPIO_LED_A)
Impressum, Datenschutz