]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: adding a test to see if we managed to get the correct demodulation from an...
authoriceman1001 <iceman@iuse.se>
Thu, 12 Mar 2015 22:04:02 +0000 (23:04 +0100)
committericeman1001 <iceman@iuse.se>
Thu, 12 Mar 2015 22:04:02 +0000 (23:04 +0100)
   By checking if the configuration data (page 0, block 0)  has some settings that must be the same.   think  reserved 7bits, This is a trail and error approach.
But together with setting a manual configuration to read a tag and this automatic verification it will help out alot I think.

client/cmdlft55xx.c
client/cmdlft55xx.h

index 7a377cc9bac4d6187596acb3950bd4bc05dd3a33..29b8032e1348412014165aa91818c42cfb42d188 100644 (file)
@@ -218,45 +218,67 @@ int CmdReadBlk(const char *Cmd)
        \r
        if (CmdDetectClockRate("f")){ //wave is almost certainly FSK\r
                // FSK\r
-               if ( FSKrawDemod("0 0", FALSE))\r
+               if ( FSKrawDemod("0 0", FALSE) && test())\r
                        printT55xx("FSK");\r
                // FSK inverted\r
-               if ( FSKrawDemod("0 1", FALSE)) \r
+               if ( FSKrawDemod("0 1", FALSE) && test()\r
                        printT55xx("FSK inv");\r
     } else {\r
                // ASK/MAN (autoclock, normal, maxerrors 1)\r
-               if ( ASKmanDemod("0 0 1", FALSE, FALSE) )\r
+               if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test()) \r
                        printT55xx("ASK/MAN");\r
                \r
                // ASK/MAN (autoclock, inverted, maxerrors 1)\r
-               if ( ASKmanDemod("0 1 1", FALSE, FALSE) )\r
+               if ( ASKmanDemod("0 1 1", FALSE, FALSE)  && test()) \r
                        printT55xx("ASK/MAN Inv");\r
 \r
                // NZR (autoclock, normal, maxerrors 1)\r
-               if  ( NRZrawDemod("0 0 1", FALSE) )\r
+               if ( NRZrawDemod("0 0 1", FALSE)  && test()) \r
                        printT55xx("NZR");\r
                // NZR (autoclock, inverted, maxerrors 1)\r
-               if  ( NRZrawDemod("0 1 1", FALSE) )\r
+               if ( NRZrawDemod("0 1 1", FALSE)  && test()) \r
                        printT55xx("NZR inv");\r
                \r
                // PSK (autoclock, normal, maxerrors 1)\r
-               if (!PSKDemod("0 0 1", FALSE))\r
+               if ( PSKDemod("0 0 1", FALSE)  && test()) \r
                        printT55xx("PSK");\r
 \r
                // PSK (autoclock, inverted, maxerrors 1)\r
-               if (!PSKDemod("0 1 1", FALSE))\r
+               if ( PSKDemod("0 1 1", FALSE) && test()) \r
                        printT55xx("PSK inv");\r
                \r
                //PSK2?\r
                \r
-               // if (!BiphaseRawDecode("0",FALSE))\r
+               // if (!BiphaseRawDecode("0",FALSE)  && test()) \r
                        // printT55xx("BIPHASE");\r
                \r
-               // if (!BiphaseRawDecode("1",FALSE))\r
+               // if (!BiphaseRawDecode("1",FALSE) && test()) \r
                        // printT55xx("BIPHASE inv");\r
        }\r
        return 0;\r
 }\r
+bool test(){\r
+\r
+       if ( !DemodBufferLen) \r
+               return false;\r
+       \r
+       uint8_t si = 1;\r
+       uint8_t safer    = PackBits(si, 4, DemodBuffer); si += 4;       \r
+       uint8_t resv     = PackBits(si, 7, DemodBuffer); si += 7+3;\r
+       uint8_t extend   = PackBits(si, 1, DemodBuffer); si += 1;\r
+\r
+       //PrintAndLog("test: %X %X %X ", safer, resv, extend);\r
+       \r
+       // 2nibble must be zeroed.\r
+       if ( resv > 0x00) return FALSE;\r
+\r
+       if ( safer == 0x6 || safer == 0x9){\r
+               if ( extend == 0x00)\r
+                       return TRUE;\r
+       }\r
+       if ( resv== 0x00) return TRUE;\r
+       return FALSE;\r
+}\r
 \r
 void printT55xx(const char *demodStr){\r
        \r
@@ -434,7 +456,7 @@ int CmdInfo(const char *Cmd){
        uint32_t resv     = PackBits(si, 7, bits); si += 7;\r
        uint32_t dbr      = PackBits(si, 3, bits); si += 3;\r
        uint32_t extend   = PackBits(si, 1, bits); si += 1;\r
-       uint32_t datamodulation   = PackBits(si, 5, bits); si += 5;\r
+       uint32_t datamod  = PackBits(si, 5, bits); si += 5;\r
        uint32_t pskcf    = PackBits(si, 2, bits); si += 2;\r
        uint32_t aor      = PackBits(si, 1, bits); si += 1;     \r
        uint32_t otp      = PackBits(si, 1, bits); si += 1;     \r
@@ -452,14 +474,14 @@ int CmdInfo(const char *Cmd){
        PrintAndLog(" reserved                  : %d", resv);\r
        PrintAndLog(" Data bit rate             : %s", GetBitRateStr(dbr));\r
        PrintAndLog(" eXtended mode             : %s", (extend) ? "Yes - Warning":"No");\r
-       PrintAndLog(" Modulation                : %s", GetModulationStr(datamodulation) );\r
+       PrintAndLog(" Modulation                : %s", GetModulationStr(datamod));\r
        PrintAndLog(" PSK clock freq            : %d", pskcf);\r
        PrintAndLog(" AOR - Answer on Request   : %s", (aor) ? "Yes":"No");\r
        PrintAndLog(" OTP - One Time Pad        : %s", (otp) ? "Yes - Warning":"No" );\r
        PrintAndLog(" Max block                 : %d", maxblk);\r
        PrintAndLog(" Password mode             : %s", (pwd) ? "Yes":"No");\r
        PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");\r
-       PrintAndLog(" Fast Write                : %s", (fw) ? "Yes":"No");\r
+       PrintAndLog(" Fast Write                : %s", (fw)  ? "Yes":"No");\r
        PrintAndLog(" Inverse data              : %s", (inv) ? "Yes":"No");\r
        PrintAndLog(" POR-Delay                 : %s", (por) ? "Yes":"No");\r
        PrintAndLog("-------------------------------------------------------------");\r
@@ -543,10 +565,10 @@ char * GetSaferStr(uint32_t id){
        \r
        sprintf(retStr,"%d",id);\r
        if (id == 6) {\r
-               sprintf(retStr,"%d - pasdwd",id);\r
+               sprintf(retStr,"%d - passwd",id);\r
        }\r
        if (id == 9 ){\r
-               sprintf(retStr,"%d - testmode ",id);\r
+               sprintf(retStr,"%d - testmode",id);\r
        }\r
        \r
        return buf;\r
index 7ae0159b9026a9ecb2550e854427f9d13117ee66..31ffa499fed0a6813e1cd1a29dbb592b9508c8ee 100644 (file)
@@ -22,4 +22,5 @@ char * GetSaferStr(uint32_t id);
 char * GetModulationStr( uint32_t id);\r
 uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bitstream);\r
 void printT55xx(const char *demodStr);\r
+bool test();\r
 #endif\r
Impressum, Datenschutz