]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
add some Q5 functionality - add t55xx wipe cmd
authormarshmellow42 <marshmellowrf@gmail.com>
Thu, 12 Nov 2015 05:27:24 +0000 (00:27 -0500)
committermarshmellow42 <marshmellowrf@gmail.com>
Thu, 12 Nov 2015 05:27:24 +0000 (00:27 -0500)
not fully tested yet

client/cmddata.c
client/cmdlf.c
client/cmdlft55xx.c
client/cmdlft55xx.h

index 580352780720f8ce12f71885477b04ad3e312293..75f44d8f1c9b2229789e29bd50f46e6b9772e0d6 100644 (file)
@@ -646,7 +646,7 @@ int CmdVikingDemod(const char *Cmd)
                return 0;
        }
        size_t size = DemodBufferLen;
                return 0;
        }
        size_t size = DemodBufferLen;
-       //call lfdemod.c demod for gProxII
+       //call lfdemod.c demod for Viking
        int ans = VikingDemod_AM(DemodBuffer, &size);
        if (ans < 0) {
                if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans);
        int ans = VikingDemod_AM(DemodBuffer, &size);
        if (ans < 0) {
                if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans);
@@ -1507,6 +1507,10 @@ int CmdFDXBdemodBI(const char *Cmd){
                if (g_debugMode) PrintAndLog("Error FDXBDemod , no startmarker found :: %d",preambleIndex);
                return 0;
        }
                if (g_debugMode) PrintAndLog("Error FDXBDemod , no startmarker found :: %d",preambleIndex);
                return 0;
        }
+       if (size != 128) {
+               if (g_debugMode) PrintAndLog("Error incorrect data length found");
+               return 0;
+       }
 
        setDemodBuf(BitStream, 128, preambleIndex);
 
 
        setDemodBuf(BitStream, 128, preambleIndex);
 
index 616d932a25251aa46cf2fc3bee614b4702bb7675..602f1b9dca0e2b5b38a455e79998feaf45ba8172 100644 (file)
@@ -124,7 +124,7 @@ int CmdFlexdemod(const char *Cmd)
                }
        }
 
                }
        }
 
-#define LONG_WAIT 100
+ #define LONG_WAIT 100
        int start;
        for (start = 0; start < GraphTraceLen - LONG_WAIT; start++) {
                int first = GraphBuffer[start];
        int start;
        for (start = 0; start < GraphTraceLen - LONG_WAIT; start++) {
                int first = GraphBuffer[start];
@@ -206,10 +206,13 @@ int CmdIndalaDemod(const char *Cmd)
        uint8_t rawbits[4096];
        int rawbit = 0;
        int worst = 0, worstPos = 0;
        uint8_t rawbits[4096];
        int rawbit = 0;
        int worst = 0, worstPos = 0;
- // PrintAndLog("Expecting a bit less than %d raw bits", GraphTraceLen / 32);
+       // PrintAndLog("Expecting a bit less than %d raw bits", GraphTraceLen / 32);
+       
+       // loop through raw signal - since we know it is psk1 rf/32 fc/2 skip every other value (+=2)
        for (i = 0; i < GraphTraceLen-1; i += 2) {
                count += 1;
                if ((GraphBuffer[i] > GraphBuffer[i + 1]) && (state != 1)) {
        for (i = 0; i < GraphTraceLen-1; i += 2) {
                count += 1;
                if ((GraphBuffer[i] > GraphBuffer[i + 1]) && (state != 1)) {
+                       // appears redundant - marshmellow
                        if (state == 0) {
                                for (j = 0; j <  count - 8; j += 16) {
                                        rawbits[rawbit++] = 0;
                        if (state == 0) {
                                for (j = 0; j <  count - 8; j += 16) {
                                        rawbits[rawbit++] = 0;
@@ -222,6 +225,7 @@ int CmdIndalaDemod(const char *Cmd)
                        state = 1;
                        count = 0;
                } else if ((GraphBuffer[i] < GraphBuffer[i + 1]) && (state != 0)) {
                        state = 1;
                        count = 0;
                } else if ((GraphBuffer[i] < GraphBuffer[i + 1]) && (state != 0)) {
+                       //appears redundant
                        if (state == 1) {
                                for (j = 0; j <  count - 8; j += 16) {
                                        rawbits[rawbit++] = 1;
                        if (state == 1) {
                                for (j = 0; j <  count - 8; j += 16) {
                                        rawbits[rawbit++] = 1;
index 55b4ab65284a8f921f9199fa31f4bce894f810ac..37f332be5a198984c9ad49db1d3e982572662c9a 100644 (file)
@@ -31,7 +31,7 @@
 #define REGULAR_READ_MODE_BLOCK 0xFF\r
 \r
 // Default configuration\r
 #define REGULAR_READ_MODE_BLOCK 0xFF\r
 \r
 // Default configuration\r
-t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00};\r
+t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00, .Q5 = FALSE };\r
 \r
 t55xx_conf_block_t Get_t55xx_Config(){\r
        return config;\r
 \r
 t55xx_conf_block_t Get_t55xx_Config(){\r
        return config;\r
@@ -41,13 +41,14 @@ void Set_t55xx_Config(t55xx_conf_block_t conf){
 }\r
 \r
 int usage_t55xx_config(){\r
 }\r
 \r
 int usage_t55xx_config(){\r
-       PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>]");\r
+       PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>] [Q5]");\r
        PrintAndLog("Options:");\r
        PrintAndLog("       h                        This help");\r
        PrintAndLog("Options:");\r
        PrintAndLog("       h                        This help");\r
-       PrintAndLog("       b <8|16|32|40|50|64|100|128>     Set bitrate");\r
+       PrintAndLog("       b <8|16|32|40|50|64|100|128>  Set bitrate");\r
        PrintAndLog("       d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa>  Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A");\r
        PrintAndLog("       d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa>  Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A");\r
-       PrintAndLog("       i [1]                            Invert data signal, defaults to normal");\r
-       PrintAndLog("       o [offset]                       Set offset, where data should start decode in bitstream");\r
+       PrintAndLog("       i [1]                         Invert data signal, defaults to normal");\r
+       PrintAndLog("       o [offset]                    Set offset, where data should start decode in bitstream");\r
+       PrintAndLog("       Q5                            Set as Q5(T5555) chip instead of T55x7");\r
        PrintAndLog("");\r
        PrintAndLog("Examples:");\r
        PrintAndLog("      lf t55xx config d FSK          - FSK demodulation");\r
        PrintAndLog("");\r
        PrintAndLog("Examples:");\r
        PrintAndLog("      lf t55xx config d FSK          - FSK demodulation");\r
@@ -155,6 +156,7 @@ int CmdT55xxSetConfig(const char *Cmd) {
        uint8_t bitRate = 0;\r
        uint8_t rates[9] = {8,16,32,40,50,64,100,128,0};\r
        uint8_t cmdp = 0;\r
        uint8_t bitRate = 0;\r
        uint8_t rates[9] = {8,16,32,40,50,64,100,128,0};\r
        uint8_t cmdp = 0;\r
+       config.Q5 = FALSE;\r
        bool errors = FALSE;\r
        while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
        bool errors = FALSE;\r
        while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
@@ -227,6 +229,11 @@ int CmdT55xxSetConfig(const char *Cmd) {
                                config.offset = offset;\r
                        cmdp+=2;\r
                        break;\r
                                config.offset = offset;\r
                        cmdp+=2;\r
                        break;\r
+               case 'Q':\r
+               case 'q':               \r
+                       config.Q5 = TRUE;\r
+                       cmdp++;\r
+                       break;\r
                default:\r
                        PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
                        errors = TRUE;\r
                default:\r
                        PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
                        errors = TRUE;\r
@@ -399,18 +406,18 @@ bool tryDetectModulation(){
        save_restoreGB(1);\r
        if (GetFskClock("", FALSE, FALSE)){ \r
                fskClocks(&fc1, &fc2, &clk, FALSE);\r
        save_restoreGB(1);\r
        if (GetFskClock("", FALSE, FALSE)){ \r
                fskClocks(&fc1, &fc2, &clk, FALSE);\r
-               if ( FSKrawDemod("0 0", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate)){\r
+               if ( FSKrawDemod("0 0", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)){\r
                        tests[hits].modulation = DEMOD_FSK;\r
                        if (fc1==8 && fc2 == 5)\r
                                tests[hits].modulation = DEMOD_FSK1a;\r
                        tests[hits].modulation = DEMOD_FSK;\r
                        if (fc1==8 && fc2 == 5)\r
                                tests[hits].modulation = DEMOD_FSK1a;\r
-                       else if (fc1==10 && fc2 == 8)\r
+                       else if (fc1==10 && fc2 == 8)\r
                                tests[hits].modulation = DEMOD_FSK2;\r
                        tests[hits].bitrate = bitRate;\r
                        tests[hits].inverted = FALSE;\r
                        tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                        ++hits;\r
                }\r
                                tests[hits].modulation = DEMOD_FSK2;\r
                        tests[hits].bitrate = bitRate;\r
                        tests[hits].inverted = FALSE;\r
                        tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                        ++hits;\r
                }\r
-               if ( FSKrawDemod("0 1", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate)) {\r
+               if ( FSKrawDemod("0 1", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                        tests[hits].modulation = DEMOD_FSK;\r
                        if (fc1 == 8 && fc2 == 5)\r
                                tests[hits].modulation = DEMOD_FSK1;\r
                        tests[hits].modulation = DEMOD_FSK;\r
                        if (fc1 == 8 && fc2 == 5)\r
                                tests[hits].modulation = DEMOD_FSK1;\r
@@ -425,28 +432,28 @@ bool tryDetectModulation(){
        } else {\r
                clk = GetAskClock("", FALSE, FALSE);\r
                if (clk>0) {\r
        } else {\r
                clk = GetAskClock("", FALSE, FALSE);\r
                if (clk>0) {\r
-                       if ( ASKDemod("0 0 0", FALSE, FALSE, 1) && test(DEMOD_ASK, &tests[hits].offset, &bitRate)) {\r
+                       if ( ASKDemod("0 0 0", FALSE, FALSE, 1) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_ASK;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
                                tests[hits].modulation = DEMOD_ASK;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
-                       if ( ASKDemod("0 1 0", FALSE, FALSE, 1)  && test(DEMOD_ASK, &tests[hits].offset, &bitRate)) {\r
+                       if ( ASKDemod("0 1 0", FALSE, FALSE, 1)  && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_ASK;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
                                tests[hits].modulation = DEMOD_ASK;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
-                       if ( ASKbiphaseDemod("0 0 0 0", FALSE) && test(DEMOD_BI, &tests[hits].offset, &bitRate) ) {\r
+                       if ( ASKbiphaseDemod("0 0 0 0", FALSE) && test(DEMOD_BI, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5) ) {\r
                                tests[hits].modulation = DEMOD_BI;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
                                tests[hits].modulation = DEMOD_BI;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
-                       if ( ASKbiphaseDemod("0 0 1 0", FALSE) && test(DEMOD_BIa, &tests[hits].offset, &bitRate) ) {\r
+                       if ( ASKbiphaseDemod("0 0 1 0", FALSE) && test(DEMOD_BIa, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5) ) {\r
                                tests[hits].modulation = DEMOD_BIa;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
                                tests[hits].modulation = DEMOD_BIa;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
@@ -458,7 +465,7 @@ bool tryDetectModulation(){
                save_restoreGB(0);\r
                clk = GetNrzClock("", FALSE, FALSE);\r
                if (clk>0) {\r
                save_restoreGB(0);\r
                clk = GetNrzClock("", FALSE, FALSE);\r
                if (clk>0) {\r
-                       if ( NRZrawDemod("0 0 1", FALSE)  && test(DEMOD_NRZ, &tests[hits].offset, &bitRate)) {\r
+                       if ( NRZrawDemod("0 0 1", FALSE)  && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_NRZ;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].modulation = DEMOD_NRZ;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
@@ -466,7 +473,7 @@ bool tryDetectModulation(){
                                ++hits;\r
                        }\r
 \r
                                ++hits;\r
                        }\r
 \r
-                       if ( NRZrawDemod("0 1 1", FALSE)  && test(DEMOD_NRZ, &tests[hits].offset, &bitRate)) {\r
+                       if ( NRZrawDemod("0 1 1", FALSE)  && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_NRZ;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
                                tests[hits].modulation = DEMOD_NRZ;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
@@ -479,14 +486,14 @@ bool tryDetectModulation(){
                save_restoreGB(0);\r
                clk = GetPskClock("", FALSE, FALSE);\r
                if (clk>0) {\r
                save_restoreGB(0);\r
                clk = GetPskClock("", FALSE, FALSE);\r
                if (clk>0) {\r
-                       if ( PSKDemod("0 0 1", FALSE) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate)) {\r
+                       if ( PSKDemod("0 0 1", FALSE) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_PSK1;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
                                tests[hits].modulation = DEMOD_PSK1;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = FALSE;\r
                                tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                                ++hits;\r
                        }\r
-                       if ( PSKDemod("0 1 1", FALSE) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate)) {\r
+                       if ( PSKDemod("0 1 1", FALSE) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_PSK1;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
                                tests[hits].modulation = DEMOD_PSK1;\r
                                tests[hits].bitrate = bitRate;\r
                                tests[hits].inverted = TRUE;\r
@@ -496,7 +503,7 @@ bool tryDetectModulation(){
                        // PSK2 - needs a call to psk1TOpsk2.\r
                        if ( PSKDemod("0 0 1", FALSE)) {\r
                                psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
                        // PSK2 - needs a call to psk1TOpsk2.\r
                        if ( PSKDemod("0 0 1", FALSE)) {\r
                                psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
-                               if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate)){\r
+                               if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)){\r
                                        tests[hits].modulation = DEMOD_PSK2;\r
                                        tests[hits].bitrate = bitRate;\r
                                        tests[hits].inverted = FALSE;\r
                                        tests[hits].modulation = DEMOD_PSK2;\r
                                        tests[hits].bitrate = bitRate;\r
                                        tests[hits].inverted = FALSE;\r
@@ -507,7 +514,7 @@ bool tryDetectModulation(){
                        // PSK3 - needs a call to psk1TOpsk2.\r
                        if ( PSKDemod("0 0 1", FALSE)) {\r
                                psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
                        // PSK3 - needs a call to psk1TOpsk2.\r
                        if ( PSKDemod("0 0 1", FALSE)) {\r
                                psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
-                               if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate)){\r
+                               if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)){\r
                                        tests[hits].modulation = DEMOD_PSK3;\r
                                        tests[hits].bitrate = bitRate;\r
                                        tests[hits].inverted = FALSE;\r
                                        tests[hits].modulation = DEMOD_PSK3;\r
                                        tests[hits].bitrate = bitRate;\r
                                        tests[hits].inverted = FALSE;\r
@@ -569,37 +576,28 @@ bool testModulation(uint8_t mode, uint8_t modread){
        return FALSE;\r
 }\r
 \r
        return FALSE;\r
 }\r
 \r
-bool testBitRate(uint8_t readRate, uint8_t mod){\r
-       uint8_t expected[8] = {8, 16, 32, 40, 50, 64, 100, 128};\r
-       uint8_t detRate = 0;\r
-       switch( mod ){\r
+bool testQ5Modulation(uint8_t  mode, uint8_t   modread){\r
+       switch( mode ){\r
                case DEMOD_FSK:\r
                case DEMOD_FSK:\r
-               case DEMOD_FSK1:\r
-               case DEMOD_FSK1a:\r
-               case DEMOD_FSK2:\r
-               case DEMOD_FSK2a:\r
-                       detRate = GetFskClock("",FALSE, FALSE); \r
-                       if (expected[readRate] == detRate) \r
-                               return TRUE;\r
+                       if (modread >= 4 && modread <= 5) return TRUE;\r
                        break;\r
                case DEMOD_ASK:\r
                        break;\r
                case DEMOD_ASK:\r
-               case DEMOD_BI:\r
-               case DEMOD_BIa:\r
-                       detRate = GetAskClock("",FALSE, FALSE); \r
-                       if (expected[readRate] == detRate) \r
-                               return TRUE;\r
+                       if (modread == 0) return TRUE;\r
                        break;\r
                case DEMOD_PSK1:\r
                        break;\r
                case DEMOD_PSK1:\r
+                       if (modread == 1) return TRUE;\r
+                       break;\r
                case DEMOD_PSK2:\r
                case DEMOD_PSK2:\r
+                       if (modread == 2) return TRUE;\r
+                       break;\r
                case DEMOD_PSK3:\r
                case DEMOD_PSK3:\r
-                       detRate = GetPskClock("",FALSE, FALSE); \r
-                       if (expected[readRate] == detRate)\r
-                               return TRUE;\r
+                       if (modread == 3) return TRUE;\r
                        break;\r
                case DEMOD_NRZ:\r
                        break;\r
                case DEMOD_NRZ:\r
-                       detRate = GetNrzClock("",FALSE, FALSE); \r
-                       if (expected[readRate] == detRate)\r
-                               return TRUE;\r
+                       if (modread == 7) return TRUE;\r
+                       break;\r
+               case DEMOD_BI:\r
+                       if (modread == 6) return TRUE;\r
                        break;\r
                default:\r
                        return FALSE;\r
                        break;\r
                default:\r
                        return FALSE;\r
@@ -607,7 +605,55 @@ bool testBitRate(uint8_t readRate, uint8_t mod){
        return FALSE;\r
 }\r
 \r
        return FALSE;\r
 }\r
 \r
-bool test(uint8_t mode, uint8_t *offset, int *fndBitRate){\r
+bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t    clk){\r
+\r
+       if ( DemodBufferLen < 64 ) return FALSE;\r
+       uint8_t si = 0;\r
+       for (uint8_t idx = 0; idx < 64; idx++){\r
+               si = idx;\r
+               if ( PackBits(si, 32, DemodBuffer) == 0x00 ) continue;\r
+\r
+               uint8_t safer     = PackBits(si, 4, DemodBuffer); si += 4;     //master key\r
+               uint8_t resv      = PackBits(si, 8, DemodBuffer); si += 8;\r
+               // 2nibble must be zeroed.\r
+               // moved test to here, since this gets most faults first.\r
+               if (safer != 0x6) continue;\r
+               if ( resv > 0x00) continue;\r
+               //uint8_t       pageSel   = PackBits(si, 1, DemodBuffer); si += 1;\r
+               //uint8_t fastWrite = PackBits(si, 1, DemodBuffer); si += 1;\r
+               si += 1+1;\r
+               int bitRate       = PackBits(si, 5, DemodBuffer)*2 + 2; si += 5;     //bit rate\r
+               if (bitRate > 128) continue;\r
+\r
+               si += 1+1+2+1;\r
+               //uint8_t AOR       = PackBits(si, 1, DemodBuffer); si += 1;     //bit 15 extended mode\r
+               //uint8_t PWD       = PackBits(si, 1, DemodBuffer); si += 1; \r
+               //uint8_t pskcr     = PackBits(si, 2, DemodBuffer); si += 2;  //could check psk cr\r
+               //uint8_t inverse   = PackBits(si, 1, DemodBuffer); si += 1;\r
+               uint8_t modread   = PackBits(si, 3, DemodBuffer); si += 3;   //bit 24, 30, 31 could be tested for 0 if not extended mode\r
+               //uint8_t maxBlk    = PackBits(si, 2, DemodBuffer); si += 2;\r
+               //uint8_t ST        = PackBits(si, 1, DemodBuffer); si += 1;\r
+\r
+               //test modulation\r
+               if (!testQ5Modulation(mode, modread)) continue;\r
+               if (bitRate != clk) continue;\r
+               *fndBitRate = bitRate;\r
+               *offset = idx;\r
+\r
+               return TRUE;\r
+       }\r
+       return FALSE;\r
+}\r
+\r
+bool testBitRate(uint8_t readRate, uint8_t clk){\r
+       uint8_t expected[8] = {8, 16, 32, 40, 50, 64, 100, 128};\r
+       if (expected[readRate] == clk)\r
+               return true;\r
+\r
+       return false;\r
+}\r
+\r
+bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5){\r
 \r
        if ( DemodBufferLen < 64 ) return FALSE;\r
        uint8_t si = 0;\r
 \r
        if ( DemodBufferLen < 64 ) return FALSE;\r
        uint8_t si = 0;\r
@@ -638,9 +684,14 @@ bool test(uint8_t mode, uint8_t *offset, int *fndBitRate){
                }\r
                //test modulation\r
                if (!testModulation(mode, modread)) continue;\r
                }\r
                //test modulation\r
                if (!testModulation(mode, modread)) continue;\r
-               if (!testBitRate(bitRate, mode)) continue;\r
+               if (!testBitRate(bitRate, clk)) continue;\r
                *fndBitRate = bitRate;\r
                *offset = idx;\r
                *fndBitRate = bitRate;\r
                *offset = idx;\r
+               *Q5 = FALSE;\r
+               return TRUE;\r
+       }\r
+       if (testQ5(mode, offset, fndBitRate, clk)) {\r
+               *Q5 = TRUE;\r
                return TRUE;\r
        }\r
        return FALSE;\r
                return TRUE;\r
        }\r
        return FALSE;\r
@@ -687,6 +738,7 @@ int special(const char *Cmd) {
 }\r
 \r
 int printConfiguration( t55xx_conf_block_t b){\r
 }\r
 \r
 int printConfiguration( t55xx_conf_block_t b){\r
+       PrintAndLog("Chip Type  : %s", (b.Q5) ? "T5555(Q5)" : "T55x7");\r
        PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );\r
        PrintAndLog("Bit Rate   : %s", GetBitRateStr(b.bitrate) );\r
        PrintAndLog("Inverted   : %s", (b.inverted) ? "Yes" : "No" );\r
        PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );\r
        PrintAndLog("Bit Rate   : %s", GetBitRateStr(b.bitrate) );\r
        PrintAndLog("Inverted   : %s", (b.inverted) ? "Yes" : "No" );\r
@@ -835,11 +887,11 @@ int CmdT55xxReadTrace(const char *Cmd) {
        else\r
                year += 2010;\r
 \r
        else\r
                year += 2010;\r
 \r
+       if (config.Q5) PrintAndLog("*** Warning *** Info read off a Q5 will not work as expected");\r
        if ( acl != 0xE0 ) {\r
                PrintAndLog("The modulation is most likely wrong since the ACL is not 0xE0. ");\r
                return 0;\r
        }\r
        if ( acl != 0xE0 ) {\r
                PrintAndLog("The modulation is most likely wrong since the ACL is not 0xE0. ");\r
                return 0;\r
        }\r
-\r
        PrintAndLog("");\r
        PrintAndLog("-- T55xx Trace Information ----------------------------------");\r
        PrintAndLog("-------------------------------------------------------------");\r
        PrintAndLog("");\r
        PrintAndLog("-- T55xx Trace Information ----------------------------------");\r
        PrintAndLog("-------------------------------------------------------------");\r
@@ -916,7 +968,7 @@ int CmdT55xxInfo(const char *Cmd){
        uint32_t fw       = PackBits(si, 1, DemodBuffer); si += 1;\r
        uint32_t inv      = PackBits(si, 1, DemodBuffer); si += 1;      \r
        uint32_t por      = PackBits(si, 1, DemodBuffer); si += 1;\r
        uint32_t fw       = PackBits(si, 1, DemodBuffer); si += 1;\r
        uint32_t inv      = PackBits(si, 1, DemodBuffer); si += 1;      \r
        uint32_t por      = PackBits(si, 1, DemodBuffer); si += 1;\r
-               \r
+       if (config.Q5) PrintAndLog("*** Warning *** Info read off a Q5 will not work as expected");\r
        PrintAndLog("");\r
        PrintAndLog("-- T55xx Configuration & Tag Information --------------------");\r
        PrintAndLog("-------------------------------------------------------------");\r
        PrintAndLog("");\r
        PrintAndLog("-- T55xx Configuration & Tag Information --------------------");\r
        PrintAndLog("-------------------------------------------------------------");\r
@@ -1189,6 +1241,26 @@ int CmdResetRead(const char *Cmd) {
        return 1;\r
 }\r
 \r
        return 1;\r
 }\r
 \r
+int CmdT55xxWipe(const char *Cmd) {\r
+       char writeData[20] = {0};\r
+       char *ptrData = writeData;\r
+       uint8_t blk = 0;\r
+       PrintAndLog("\nBeginning Wipe of a T55xx tag (assuming the tag is not password protected)\n");\r
+       //try with the default password to reset block 0  (with a pwd should work even if pwd bit not set)\r
+       snprintf(ptrData,sizeof(writeData),"b %d d 00088040 p 0", blk);\r
+       if (!CmdT55xxWriteBlock(ptrData)){\r
+               PrintAndLog("Error writing blk %d", blk);\r
+       }\r
+       blk = 1;\r
+       for (; blk<8; blk++) {\r
+               snprintf(ptrData,sizeof(writeData),"b %d d 0", blk);\r
+               if (!CmdT55xxWriteBlock(ptrData)){\r
+                       PrintAndLog("Error writing blk %d", blk);\r
+               }\r
+       }\r
+       return 0;\r
+}\r
+\r
 static command_t CommandTable[] =\r
 {\r
   {"help",     CmdHelp,           1, "This help"},\r
 static command_t CommandTable[] =\r
 {\r
   {"help",     CmdHelp,           1, "This help"},\r
@@ -1202,6 +1274,7 @@ static command_t CommandTable[] =
   {"dump",     CmdT55xxDump,      0, "[password] [o] Dump T55xx card block 0-7. Optional [password], [override]"},\r
   {"special",  special,           0, "Show block changes with 64 different offsets"},\r
   {"wakeup",   CmdT55xxWakeUp,    0, "Send AOR wakeup command"},\r
   {"dump",     CmdT55xxDump,      0, "[password] [o] Dump T55xx card block 0-7. Optional [password], [override]"},\r
   {"special",  special,           0, "Show block changes with 64 different offsets"},\r
   {"wakeup",   CmdT55xxWakeUp,    0, "Send AOR wakeup command"},\r
+  {"wipe",     CmdT55xxWipe,      0, "Wipe a T55xx tag and set defaults (will destroy any data on tag)"},\r
   {NULL, NULL, 0, NULL}\r
 };\r
 \r
   {NULL, NULL, 0, NULL}\r
 };\r
 \r
index d513407987280dece9cebd78cf8905af3f5c09cb..424e85abd7183a641b236c96a956b3e638bc371e 100644 (file)
@@ -38,6 +38,7 @@ typedef struct {
                RF_100 = 0x06,\r
                RF_128 = 0x07,\r
        } bitrate;\r
                RF_100 = 0x06,\r
                RF_128 = 0x07,\r
        } bitrate;\r
+       bool Q5;\r
 } t55xx_conf_block_t;\r
 t55xx_conf_block_t Get_t55xx_Config();\r
 void Set_t55xx_Config(t55xx_conf_block_t conf);\r
 } t55xx_conf_block_t;\r
 t55xx_conf_block_t Get_t55xx_Config();\r
 void Set_t55xx_Config(t55xx_conf_block_t conf);\r
@@ -51,6 +52,7 @@ int CmdT55xxReadTrace(const char *Cmd);
 int CmdT55xxInfo(const char *Cmd);\r
 int CmdT55xxDetect(const char *Cmd);\r
 int CmdResetRead(const char *Cmd);\r
 int CmdT55xxInfo(const char *Cmd);\r
 int CmdT55xxDetect(const char *Cmd);\r
 int CmdResetRead(const char *Cmd);\r
+int CmdT55xxWipe(const char *Cmd);\r
 \r
 char * GetBitRateStr(uint32_t id);\r
 char * GetSaferStr(uint32_t id);\r
 \r
 char * GetBitRateStr(uint32_t id);\r
 char * GetSaferStr(uint32_t id);\r
@@ -63,7 +65,7 @@ int printConfiguration( t55xx_conf_block_t b);
 \r
 bool DecodeT55xxBlock();\r
 bool tryDetectModulation();\r
 \r
 bool DecodeT55xxBlock();\r
 bool tryDetectModulation();\r
-bool test(uint8_t mode, uint8_t *offset, int *fndBitRate);\r
+bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5);\r
 int special(const char *Cmd);\r
 int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password );\r
 \r
 int special(const char *Cmd);\r
 int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password );\r
 \r
Impressum, Datenschutz