]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
ADD: @pwpiwi 's latest code from his 'hardnested' branch.
[proxmark3-svn] / client / cmdhfmf.c
index 0a24f6da33c72a1e8036c4baa662144624147dd0..d43a0ef2448c39a4a51c32e23d89f088df30cdf8 100644 (file)
@@ -799,14 +799,16 @@ int CmdHF14AMfNestedHard(const char *Cmd)
        uint8_t trgBlockNo = 0;\r
        uint8_t trgKeyType = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
+       uint8_t trgkey[6] = {0, 0, 0, 0, 0, 0};\r
        \r
        char ctmp;\r
        ctmp = param_getchar(Cmd, 0);\r
+\r
        if (ctmp != 'R' && ctmp != 'r' && strlen(Cmd) < 20) {\r
                PrintAndLog("Usage:");\r
                PrintAndLog("      hf mf hardnested <block number> <key A|B> <key (12 hex symbols)>");\r
-               PrintAndLog("                       <target block number> <target key A|B> [w] [s]");\r
-               PrintAndLog("  or  hf mf hardnested r");\r
+               PrintAndLog("                       <target block number> <target key A|B> [known target key (12 hex symbols)] [w] [s]");\r
+               PrintAndLog("  or  hf mf hardnested r [known target key]");\r
                PrintAndLog(" ");\r
                PrintAndLog("Options: ");\r
                PrintAndLog("      w: Acquire nonces and write them to binary file nonces.bin");\r
@@ -817,17 +819,22 @@ int CmdHF14AMfNestedHard(const char *Cmd)
                PrintAndLog("      sample2: hf mf hardnested 0 A FFFFFFFFFFFF 4 A w");\r
                PrintAndLog("      sample3: hf mf hardnested 0 A FFFFFFFFFFFF 4 A w s");\r
                PrintAndLog("      sample4: hf mf hardnested r");\r
-\r
+               PrintAndLog(" ");\r
+               PrintAndLog("Add the known target key to check if it is present in the remaining key space:");\r
+               PrintAndLog("      sample5: hf mf hardnested 0 A A0A1A2A3A4A5 4 A FFFFFFFFFFFF");\r
                return 0;\r
        }       \r
        \r
+       bool know_target_key = false;\r
        bool nonce_file_read = false;\r
        bool nonce_file_write = false;\r
        bool slow = false;\r
        \r
        if (ctmp == 'R' || ctmp == 'r') {\r
-\r
                nonce_file_read = true;\r
+               if (!param_gethex(Cmd, 1, trgkey, 12)) {\r
+                       know_target_key = true;\r
+               }\r
 \r
        } else {\r
 \r
@@ -857,6 +864,12 @@ int CmdHF14AMfNestedHard(const char *Cmd)
                }\r
 \r
                uint16_t i = 5;\r
+\r
+               if (!param_gethex(Cmd, 5, trgkey, 12)) {\r
+                       know_target_key = true;\r
+                       i++;\r
+               }\r
+\r
                while ((ctmp = param_getchar(Cmd, i))) {\r
                        if (ctmp == 's' || ctmp == 'S') {\r
                                slow = true;\r
@@ -870,12 +883,16 @@ int CmdHF14AMfNestedHard(const char *Cmd)
                }\r
        }\r
 \r
-       PrintAndLog("--target block no:%3d, target key type:%c, file action: %s, Slow: %s ", \r
+       PrintAndLog("--target block no:%3d, target key type:%c, known target key: 0x%02x%02x%02x%02x%02x%02x%s, file action: %s, Slow: %s ", \r
                        trgBlockNo, \r
                        trgKeyType?'B':'A', \r
+                       trgkey[0], trgkey[1], trgkey[2], trgkey[3], trgkey[4], trgkey[5],\r
+                       know_target_key?"":" (not set)",\r
                        nonce_file_write?"write":nonce_file_read?"read":"none",\r
                        slow?"Yes":"No");\r
-       int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, nonce_file_read, nonce_file_write, slow);\r
+\r
+       int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key?trgkey:NULL, nonce_file_read, nonce_file_write, slow);\r
+\r
        if (isOK) {\r
                switch (isOK) {\r
                        case 1 : PrintAndLog("Error: No response from Proxmark.\n"); break;\r
Impressum, Datenschutz