]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
hf mf dump bugfix: wrongly tried key A instead of key B for a specific Access Condition
authorpwpiwi <pwpiwi@users.noreply.github.com>
Fri, 12 Sep 2014 05:45:04 +0000 (07:45 +0200)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Fri, 12 Sep 2014 05:45:04 +0000 (07:45 +0200)
client/cmdhfmf.c

index 9ccfef95c3b5ff53a3b4c6fe804dcadce070dfed..b66aa3a6d59d220d685c8b57ce657b3f415feee8 100644 (file)
@@ -572,17 +572,19 @@ int CmdHF14AMfDump(const char *Cmd)
                        uint8_t isOK  = resp.arg[0] & 0xff;\r
                        uint8_t *data  = resp.d.asBytes;\r
                        if (isOK){\r
-                               rights[sectorNo][0] = ((data[7] & 0x10)>>4) | ((data[8] & 0x1)<<1) | ((data[8] & 0x10)>>2);\r
-                               rights[sectorNo][1] = ((data[7] & 0x20)>>5) | ((data[8] & 0x2)<<0) | ((data[8] & 0x20)>>3);\r
-                               rights[sectorNo][2] = ((data[7] & 0x40)>>6) | ((data[8] & 0x4)>>1) | ((data[8] & 0x40)>>4);\r
-                               rights[sectorNo][3] = ((data[7] & 0x80)>>7) | ((data[8] & 0x8)>>2) | ((data[8] & 0x80)>>5);\r
+                               rights[sectorNo][0] = ((data[7] & 0x10)>>2) | ((data[8] & 0x1)<<1) | ((data[8] & 0x10)>>4); // C1C2C3 for data area 0\r
+                               rights[sectorNo][1] = ((data[7] & 0x20)>>3) | ((data[8] & 0x2)<<0) | ((data[8] & 0x20)>>5); // C1C2C3 for data area 1\r
+                               rights[sectorNo][2] = ((data[7] & 0x40)>>4) | ((data[8] & 0x4)>>1) | ((data[8] & 0x40)>>6); // C1C2C3 for data area 2\r
+                               rights[sectorNo][3] = ((data[7] & 0x80)>>5) | ((data[8] & 0x8)>>2) | ((data[8] & 0x80)>>7); // C1C2C3 for sector trailer\r
                        } else {\r
                                PrintAndLog("Could not get access rights for sector %2d. Trying with defaults...", sectorNo);\r
-                               rights[sectorNo][0] = rights[sectorNo][1] = rights[sectorNo][2] = rights[sectorNo][3] = 0x01;\r
+                               rights[sectorNo][0] = rights[sectorNo][1] = rights[sectorNo][2] = 0x00;\r
+                               rights[sectorNo][3] = 0x01;\r
                        }\r
                } else {\r
                        PrintAndLog("Command execute timeout when trying to read access rights for sector %2d. Trying with defaults...", sectorNo);\r
-                       rights[sectorNo][0] = rights[sectorNo][1] = rights[sectorNo][2] = rights[sectorNo][3] = 0x01;\r
+                       rights[sectorNo][0] = rights[sectorNo][1] = rights[sectorNo][2] = 0x00;\r
+                       rights[sectorNo][3] = 0x01;\r
                }\r
        }\r
        \r
@@ -603,12 +605,12 @@ int CmdHF14AMfDump(const char *Cmd)
                                received = WaitForResponseTimeout(CMD_ACK,&resp,1500);\r
                        } else {                                                                                                // data block. Check if it can be read with key A or key B\r
                                uint8_t data_area = sectorNo<32?blockNo:blockNo/5;\r
-                               if ((rights[sectorNo][data_area] == 3) || (rights[sectorNo][data_area] == 5)) {                 // only key B would work\r
+                               if ((rights[sectorNo][data_area] == 0x03) || (rights[sectorNo][data_area] == 0x05)) {   // only key B would work\r
                                        UsbCommand c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 1, 0}};\r
                                        memcpy(c.d.asBytes, keyB[sectorNo], 6);\r
                                        SendCommand(&c);\r
                                        received = WaitForResponseTimeout(CMD_ACK,&resp,1500);\r
-                               } else if (rights[sectorNo][data_area] == 7) {                                                                                  // no key would work\r
+                               } else if (rights[sectorNo][data_area] == 0x07) {                                                                               // no key would work\r
                                        isOK = false;\r
                                        PrintAndLog("Access rights do not allow reading of sector %2d block %3d", sectorNo, blockNo);\r
                                } else {                                                                                                                                                                // key A would work\r
Impressum, Datenschutz