]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge branch 'master' of https://github.com/iceman1001/proxmark3
authoriceman <iceman@iuse.se>
Wed, 10 Feb 2016 12:29:23 +0000 (13:29 +0100)
committericeman <iceman@iuse.se>
Wed, 10 Feb 2016 12:29:23 +0000 (13:29 +0100)
Conflicts:
client/cmdhfmf.c
client/cmdmain.c

1  2 
client/cmdhfmf.c
client/cmdmain.c

diff --combined client/cmdhfmf.c
index 80c072f5033ee1154aad279b8440f605d8c80e5b,c54a0592839854ddb85531063a8a948e6ef44a92..d6cae59f0bfa46101b142cbbc43c842ce4462067
@@@ -53,7 -53,7 +53,7 @@@ start
  \r
        // wait cycle\r
        while (true) {\r
-               printf(".");\r
+         printf(".");\r
                fflush(stdout);\r
                if (ukbhit()) {\r
                        tmpchar = getchar();\r
                }\r
                \r
                UsbCommand resp;\r
-               if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {\r
+               if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {\r
                        isOK  = resp.arg[0];\r
+                       printf("\n\n");\r
                        switch (isOK) {\r
                                case -1 : PrintAndLog("Button pressed. Aborted.\n"); break;\r
                                case -2 : PrintAndLog("Card is not vulnerable to Darkside attack (doesn't send NACK on authentication requests).\n"); break;\r
                                case -3 : PrintAndLog("Card is not vulnerable to Darkside attack (its random number generator is not predictable).\n"); break;\r
                                case -4 : PrintAndLog("Card is not vulnerable to Darkside attack (its random number generator seems to be based on the wellknown");\r
-                                         PrintAndLog("generating polynomial with 16 effective bits only, but shows unexpected behaviour.\n"); break;\r
+                                                 PrintAndLog("generating polynomial with 16 effective bits only, but shows unexpected behaviour.\n"); break;\r
                                default: ;\r
                        }\r
-                       uid = (uint32_t)bytes_to_num(resp.d.asBytes, 4);\r
+                       uid = (uint32_t)bytes_to_num(resp.d.asBytes +  0, 4);\r
                        nt =  (uint32_t)bytes_to_num(resp.d.asBytes +  4, 4);\r
                        par_list = bytes_to_num(resp.d.asBytes +  8, 8);\r
                        ks_list = bytes_to_num(resp.d.asBytes +  16, 8);\r
@@@ -706,13 -707,12 +707,14 @@@ int CmdHF14AMfNested(const char *Cmd
                clock_t t2 = clock() - t1;\r
                if ( t2 > 0 )\r
                        PrintAndLog("Time to check 6 known keys: %.0f ticks %4.2f sec", (float)t2, ((float)t2)/CLOCKS_PER_SEC);\r
 -      \r
 +\r
 +              PrintAndLog("enter nested..."); \r
                \r
                // nested sectors\r
                iterations = 0;\r
+               PrintAndLog("enter nested...");\r
                bool calibrate = true;\r
 +\r
                for (i = 0; i < NESTED_SECTOR_RETRY; i++) {\r
                        for (uint8_t sectorNo = 0; sectorNo < SectorsCnt; ++sectorNo) {\r
                                for (trgKeyType = 0; trgKeyType < 2; ++trgKeyType) { \r
                                                case -5 :\r
                                                        calibrate = false;\r
                                                        iterations++;\r
-                                                       e_sector[sectorNo].foundKey[trgKeyType] = TRUE;\r
+                                                       e_sector[sectorNo].foundKey[trgKeyType] = 1;\r
                                                        e_sector[sectorNo].Key[trgKeyType] = bytes_to_num(keyBlock, 6);\r
                                                        continue;\r
                                                        \r
                                }\r
                        }\r
                }\r
 +              \r
 +              t1 = clock() - t1;\r
 +              if ( t1 > 0 )\r
 +                      PrintAndLog("Time in nested: %.0f ticks %4.2f sec (%4.2f sec per key)\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/iterations/CLOCKS_PER_SEC);\r
  \r
                // 20160116 If Sector A is found, but not Sector B,  try just reading it of the tag?\r
                PrintAndLog("trying to read key B...");\r
                                SendCommand(&c);\r
  \r
                                UsbCommand resp;\r
-                               if ( !WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;\r
+                               if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500)) continue;\r
                                        \r
                                uint8_t isOK  = resp.arg[0] & 0xff;\r
                                if (!isOK) continue;\r
                                key64 = bytes_to_num(data+10, 6);\r
                                if (key64) {\r
                                        PrintAndLog("Data:%s", sprint_hex(data+10, 6));\r
 -                                      e_sector[i].foundKey[1] = 1;\r
 +                                      e_sector[i].foundKey[1] = TRUE;\r
                                        e_sector[i].Key[1] = key64;\r
                                }\r
                        }\r
                }\r
 -              \r
 -              t1 = clock() - t1;\r
 -              if ( t1 > 0 )\r
 -                      PrintAndLog("Time in nested: %.0f ticks %4.2f sec (%4.2f sec per key)\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/iterations/CLOCKS_PER_SEC);\r
 +\r
                \r
                //print them\r
                printKeyTable( SectorsCnt, e_sector );\r
@@@ -1048,7 -1047,7 +1050,7 @@@ int CmdHF14AMfChk(const char *Cmd
                                }\r
                                keyBlock = p;\r
                        }\r
 -                      PrintAndLog("check key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,\r
 +                      PrintAndLog("key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,\r
                        (keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],\r
                        (keyBlock + 6*keycnt)[3], (keyBlock + 6*keycnt)[4],     (keyBlock + 6*keycnt)[5], 6);\r
                        keycnt++;\r
                                        }\r
                                        memset(keyBlock + 6 * keycnt, 0, 6);\r
                                        num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);\r
 -                                      PrintAndLog("check custom key[%2d] %012"llx, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));\r
 +                                      PrintAndLog("check key[%2d] %012"llx, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));\r
                                        keycnt++;\r
                                        memset(buf, 0, sizeof(buf));\r
                                }\r
        if (keycnt == 0) {\r
                PrintAndLog("No key specified, trying default keys");\r
                for (;keycnt < defaultKeysSize; keycnt++)\r
 -                      PrintAndLog("check default key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,\r
 +                      PrintAndLog("key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,\r
                                (keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],\r
                                (keyBlock + 6*keycnt)[3], (keyBlock + 6*keycnt)[4],     (keyBlock + 6*keycnt)[5], 6);\r
        }\r
        }\r
  \r
        uint8_t trgKeyType = 0;\r
 +      uint32_t max_keys = keycnt > (USB_CMD_DATA_SIZE/6) ? (USB_CMD_DATA_SIZE/6) : keycnt;\r
        \r
        // time\r
        clock_t t1 = clock();\r
        \r
        // check keys.\r
        for (trgKeyType = 0; trgKeyType < 2; ++trgKeyType) {\r
 +\r
                int b = blockNo;\r
                for (int i = 0; i < SectorsCnt; ++i) {\r
                        \r
                        // skip already found keys.\r
                        if (e_sector[i].foundKey[trgKeyType]) continue;\r
                        \r
 -                      uint32_t max_keys = keycnt > (USB_CMD_DATA_SIZE/6) ? (USB_CMD_DATA_SIZE/6) : keycnt;\r
+                       \r
                        for (uint32_t c = 0; c < keycnt; c += max_keys) {\r
                                \r
                                uint32_t size = keycnt-c > max_keys ? max_keys : keycnt-c;\r
                                \r
                                res = mfCheckKeys(b, trgKeyType, true, size, &keyBlock[6*c], &key64);\r
                                if (!res) {\r
 -                                      PrintAndLog("Sector:%3d Block:%3d, key type: %C  -- Found key [%012"llx"]", i, b, trgKeyType ? 'B':'A', key64);\r
 +                                      //PrintAndLog("Sector:%3d Block:%3d, key type: %C  -- Found key [%012"llx"]", i, b, trgKeyType ? 'B':'A', key64);\r
                                                                                 \r
                                        e_sector[i].Key[trgKeyType] = key64;\r
                                        e_sector[i].foundKey[trgKeyType] = TRUE;\r
                        b < 127 ? ( b +=4 ) : ( b += 16 );      \r
                }\r
        }\r
 +      \r
 +      t1 = clock() - t1;\r
 +      if ( t1 > 0 )\r
 +              printf("Time in checkkeys: %.0f ticks  %1.2f sec (%1.2f sec per key)\n\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/keycnt/CLOCKS_PER_SEC);\r
 +\r
        // 20160116 If Sector A is found, but not Sector B,  try just reading it of the tag?\r
        PrintAndLog("testing to read B...");\r
        for (i = 0; i < SectorsCnt; i++) {\r
                        }\r
                }\r
        }\r
 -      \r
 -      t1 = clock() - t1;\r
 -      if ( t1 > 0 )\r
 -              printf("Time in checkkeys: %.0f ticks  %1.2f sec (%1.2f sec per key)\n\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/keycnt/CLOCKS_PER_SEC);\r
 +\r
  \r
        //print them\r
        printKeyTable( SectorsCnt, e_sector );\r
diff --combined client/cmdmain.c
index 1357c436d2519c9e728fb943087035c1d14a20af,9072d49a0fc9d33a1d671c79fbb1ec196b5eec43..58783030d24e4b8db1097654ef85d03d5db7c750
@@@ -120,7 -120,6 +120,7 @@@ int getCommand(UsbCommand* response
      //Pick out the next unread command
      UsbCommand* last_unread = &cmdBuffer[cmd_tail];
      memcpy(response, last_unread, sizeof(UsbCommand));
 +
      //Increment tail - this is a circular buffer, so modulo buffer size
      cmd_tail = (cmd_tail +1 ) % CMD_BUFFER_SIZE;
  
@@@ -147,10 -146,10 +147,10 @@@ bool WaitForResponseTimeout(uint32_t cm
        for ( size_t dm_seconds = 0; dm_seconds < ms_timeout/10; dm_seconds++ ) {
  
                while( getCommand(response) ) {
 -                      if(response->cmd == cmd){
 -                              return true;
 -                      }
 +                      if(response->cmd == cmd)
 +                              return true;                    
                }
 +
                msleep(10); // XXX ugh
                if (dm_seconds == 200) { // Two seconds elapsed
                        PrintAndLog("Waiting for a response from the proxmark...");
@@@ -182,24 -181,27 +182,26 @@@ void UsbCommandReceived(UsbCommand *UC
                // First check if we are handling a debug message
                case CMD_DEBUG_PRINT_STRING: {
                        char s[USB_CMD_DATA_SIZE+1];
-                       memset(s, 0x00, sizeof(s));
-                       size_t len = MIN(UC->arg[0], USB_CMD_DATA_SIZE);
+                       memset(s, 0x00, sizeof(s)); 
+                       size_t len = MIN(UC->arg[0],USB_CMD_DATA_SIZE);
                        memcpy(s, UC->d.asBytes, len);
                        PrintAndLog("#db# %s", s);
+                       return;
                } break;
  
 -              case CMD_DEBUG_PRINT_INTEGERS: {
 -                      PrintAndLog("#db# %08x, %08x, %08x       \r\n", UC->arg[0], UC->arg[1], UC->arg[2]);
 -                      return;
 -              } break;
 +              case CMD_DEBUG_PRINT_INTEGERS:
 +                      PrintAndLog("#db# %08x, %08x, %08x", UC->arg[0], UC->arg[1], UC->arg[2]);
 +                      break;
  
 -              case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K: {
 -                      memcpy(sample_buf+(UC->arg[0]),UC->d.asBytes,UC->arg[1]);
 -                      return;
 -              } break;
 +              case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K:
 +                      memcpy( sample_buf + (UC->arg[0]), UC->d.asBytes, UC->arg[1]);
 +                      break;
  
                default: {
                        storeCommand(UC);
                        break;
                }
        }
++
  }
  
Impressum, Datenschutz