]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: 'lf presco' demod fixes.
authoriceman1001 <iceman@iuse.se>
Wed, 14 Dec 2016 23:01:31 +0000 (00:01 +0100)
committericeman1001 <iceman@iuse.se>
Wed, 14 Dec 2016 23:01:31 +0000 (00:01 +0100)
ADD: 'lf search' now also looks for Presco.

I know that the helptext is wrong (d should be p)

client/cmdlf.c
client/cmdlfpresco.c
client/cmdlfpresco.h
common/lfdemod.c

index 63e8a2b5012dbde937055476ae2e1de23301036f..e157baffbfc8ca9e763e4275038dc96f07a303cb 100644 (file)
@@ -1104,6 +1104,11 @@ int CmdLFfind(const char *Cmd) {
                PrintAndLog("\nValid Visa2000 ID Found!");
                return 1;
        }
+       ans=CmdPrescoDemod("");
+       if (ans>0) {
+               PrintAndLog("\nValid Presco ID Found!");
+               return 1;
+       }
        // TIdemod?
        
 
index 3bf5e1be68c54831e8a837bf5267680883a0747d..8a9f8c5d7df610290cd54157cefa542af1fb7f40 100644 (file)
@@ -54,7 +54,7 @@ int GetWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode
                        case 'H':
                                hex = true;
                                //get hex
-                               *fullcode = param_get32ex(Cmd, cmdp+1, 0, 10);
+                               *fullcode = param_get32ex(Cmd, cmdp+1, 0, 16);
                                cmdp+=2;
                                break;
                        case 'P':
@@ -115,34 +115,44 @@ int GetPrescoBits(uint32_t fullcode, uint8_t *prescoBits) {
 
 //see ASKDemod for what args are accepted
 int CmdPrescoDemod(const char *Cmd) {
-       if (!ASKDemod(Cmd, false, false, 1)) {
-               if (g_debugMode) PrintAndLog("ASKDemod failed");
+       bool st = true;
+       //if (!ASKDemod(Cmd, false, false, 1)) {
+       if (!ASKDemod_ext("32 0 0", FALSE, FALSE, 1, &st)) {
+               if (g_debugMode) PrintAndLog("DEBUG: Error Presco ASKDemod failed");
                return 0;
        }
        size_t size = DemodBufferLen;
        //call lfdemod.c demod for Viking
        int ans = PrescoDemod(DemodBuffer, &size);
        if (ans < 0) {
-               if (g_debugMode) PrintAndLog("Error Presco_Demod %d", ans);
+               if (g_debugMode){
+                       if (ans == -1)
+                               PrintAndLog("DEBUG: Error - Presco: too few bits found");
+                       else if (ans == -2)
+                               PrintAndLog("DEBUG: Error - Presco: preamble not found");
+                       else if (ans == -3)
+                               PrintAndLog("DEBUG: Error - Presco: Size not correct: %d", size);
+                       else
+                               PrintAndLog("DEBUG: Error - Presco: ans: %d", ans);
+               }
                return 0;
        }
+       setDemodBuf(DemodBuffer, 128, ans);
+       
        //got a good demod
-       uint32_t raw1 = bytebits_to_byte(DemodBuffer+ans, 32);
-       uint32_t raw2 = bytebits_to_byte(DemodBuffer+ans+32, 32);
-       uint32_t raw3 = bytebits_to_byte(DemodBuffer+ans+64, 32);
-       uint32_t raw4 = bytebits_to_byte(DemodBuffer+ans+96, 32);
+       uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
+       uint32_t raw2 = bytebits_to_byte(DemodBuffer+32, 32);
+       uint32_t raw3 = bytebits_to_byte(DemodBuffer+64, 32);
+       uint32_t raw4 = bytebits_to_byte(DemodBuffer+96, 32);
        uint32_t cardid = raw4;
-       PrintAndLog("Presco Tag Found: Card ID %08X", cardid);
-       PrintAndLog("Raw: %08X%08X%08X%08X", raw1,raw2,raw3,raw4);
-       setDemodBuf(DemodBuffer+ans, 128, 0);
-       
+       PrintAndLog("Presco Tag Found: Card ID %08X, Raw: %08X%08X%08X%08X", cardid, raw1, raw2, raw3, raw4);
+
        uint32_t sitecode = 0, usercode = 0, fullcode = 0;
-       bool Q5=false;
+       bool Q5 = false;
        char cmd[12] = {0};
        sprintf(cmd, "H %08X", cardid);
        GetWiegandFromPresco(cmd, &sitecode, &usercode, &fullcode, &Q5);
        PrintAndLog("SiteCode %u, UserCode %u, FullCode, %08X", sitecode, usercode, fullcode);
-       
        return 1;
 }
 
@@ -239,8 +249,8 @@ int CmdPrescoSim(const char *Cmd) {
 static command_t CommandTable[] = {
     {"help",   CmdHelp,                1, "This help"},
        {"read",        CmdPrescoRead,  0, "Attempt to read and Extract tag data"},
-       {"clone", CmdPrescoClone, 0, "d <9 digit ID> or h <hex> [Q5] clone presco tag"},
-       {"sim",   CmdPrescoSim,   0, "d <9 digit ID> or h <hex> simulate presco tag"},
+       {"clone",       CmdPrescoClone, 0, "d <9 digit ID> or h <hex> [Q5] clone presco tag"},
+       {"sim",         CmdPrescoSim,   0, "d <9 digit ID> or h <hex> simulate presco tag"},
     {NULL, NULL, 0, NULL}
 };
 
index 69f68fd6e6132cbafa911d21c367aeeb187ae654..1157dbbb467db15adbb514abb32827e89504ebac 100644 (file)
@@ -21,6 +21,8 @@
 int CmdLFPresco(const char *Cmd);
 int CmdPrescoClone(const char *Cmd);
 int CmdPrescoSim(const char *Cmd);
+int CmdPrescoRead(const char *Cmd);
+int CmdPrescoDemod(const char *Cmd);
 
 int GetWiegandFromPresco(const char *id, uint32_t *sitecode, uint32_t *usercode, uint32_t *fullcode, bool *Q5);
 
index 11340ef003d0b1255e844b3a45cb9d6e6138337d..731496026375c87e1ea69fbb546a0893c03299f9 100644 (file)
@@ -711,13 +711,12 @@ int Visa2kDemod_AM(uint8_t *dest, size_t *size) {
 
 // find presco preamble 0x10D in already demoded data
 int PrescoDemod(uint8_t *dest, size_t *size) {
-       //make sure buffer has data
-       if (*size < 64*2) return -2;
-
+       if (*size < 128*2) return -1; //make sure buffer has data
        size_t startIdx = 0;
-       uint8_t preamble[] = {1,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0};
+       uint8_t preamble[] = {0,0,0,1,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0};
        uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
-       if (errChk == 0) return -4; //preamble not found
+       if (errChk == 0) return -2; //preamble not found
+       if (*size != 128) return -3; //wrong demoded size
        //return start position
        return (int) startIdx;
 }
Impressum, Datenschutz