]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
CHG: renamed struct sector -> sector_t
authoriceman1001 <iceman@iuse.se>
Mon, 6 Mar 2017 18:11:08 +0000 (19:11 +0100)
committericeman1001 <iceman@iuse.se>
Mon, 6 Mar 2017 18:11:08 +0000 (19:11 +0100)
CHG: defines on armside
CHG: #define WIN32 ->  _WIN32
CHG: started to enhance "hf mf chkkeys"
REM: removed some duplicates etc in default keys.

12 files changed:
armsrc/appmain.c
armsrc/apps.h
armsrc/mifarecmd.c
armsrc/optimized_cipher.h
client/cmdhfmf.c
client/cmdhfmf.h
client/hid-flasher/proxendian.h
client/hid-flasher/sleep.h
client/lualibs/mf_default_keys.lua
client/mifarehost.c
client/mifarehost.h
client/scripts/mfkeys.lua

index d976febc612eb577e205bd1096247106fb60352c..bcff74763c48b7c05dc52612f2d0f20658137152 100644 (file)
@@ -9,6 +9,7 @@
 // The main application code. This is the first thing called after start.c
 // executes.
 //-----------------------------------------------------------------------------
+#include <stdarg.h>
 #include "usb_cdc.h"
 #include "proxmark3.h"
 #include "apps.h"
index 0cb375e6fd42073c793015b66c9c03729f53d4af..4f1b622aa159a4a07b08599bd0e948e27581cdba 100644 (file)
@@ -29,7 +29,6 @@ extern "C" {
 #include "pcf7931.h"
 #include "desfire.h"
 #include "iso14443b.h"
-//#include "iso14443a.h"
 #include "emvcard.h"
 
 extern int rsamples;   // = 0;
index 2ab076b626575975a396f905dc2510633124cef1..1e398bc8e08c9ae2a134e64d1a0925d1b519c19b 100644 (file)
@@ -956,9 +956,13 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
 // \r
 //-----------------------------------------------------------------------------\r
 void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {\r
-       uint8_t blockNo = arg0 & 0xff;\r
-       uint8_t keyType = (arg0 >> 8) & 0xff;\r
-       bool clearTrace = arg1;\r
+#define STD_SEARCH 1\r
+#define EXT_SEARCH 2\r
+\r
+       uint8_t blockNo = arg0 & 0xFF;\r
+       uint8_t keyType = (arg0 >> 8) & 0xFF;\r
+       uint8_t searchType = (arg1 >> 8 ) & 0xFF;\r
+       bool clearTrace = arg1 & 0xFF;\r
        uint8_t keyCount = arg2;\r
        uint64_t ui64Key = 0;\r
        \r
@@ -1026,8 +1030,16 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
                        \r
                        continue;\r
                }\r
-               isOK = 1;\r
-               break;\r
+               \r
+               // found a key.\r
+               //\r
+               //if ( searchType == EXT_SEARCH) {\r
+                       \r
+               //}\r
+               //else {\r
+                       isOK = 1;\r
+                       break;\r
+               //}\r
        }\r
        \r
        LED_B_ON();\r
index 6f428bf5e6423af080ba8b1b2703e4107aa762a2..7398069f0d4ba093d9b48ccb2944c8ccab51093b 100644 (file)
@@ -2,8 +2,7 @@
 #define OPTIMIZED_CIPHER_H
 
 #include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
+#include <stddef.h>
 #include <stdbool.h>
 
 /**
index ede88cb7996d01d6acf1b73ae59ba5e4e72110a8..793863b09655108e67a9a482d96b3d0a2188d9fd 100644 (file)
@@ -721,7 +721,7 @@ int CmdHF14AMfRestore(const char *Cmd) {
 \r
 int CmdHF14AMfNested(const char *Cmd) {\r
        int i, j, res, iterations;\r
-       sector *e_sector = NULL;\r
+       sector_t *e_sector = NULL;\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t trgBlockNo = 0;\r
@@ -823,7 +823,7 @@ int CmdHF14AMfNested(const char *Cmd) {
                time_t start, end;\r
                time(&start);\r
                \r
-               e_sector = calloc(SectorsCnt, sizeof(sector));\r
+               e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
                if (e_sector == NULL) return 1;\r
                \r
                //test current key and additional standard keys first\r
@@ -1083,7 +1083,7 @@ int CmdHF14AMfChk(const char *Cmd) {
        uint8_t *keyBlock = NULL, *p;\r
        uint8_t stKeyBlock = 20;\r
        \r
-       sector *e_sector = NULL;\r
+       sector_t *e_sector = NULL;\r
        \r
        int i, res;\r
        int     keycnt = 0;\r
@@ -1230,7 +1230,7 @@ int CmdHF14AMfChk(const char *Cmd) {
        }\r
        \r
        // initialize storage for found keys\r
-       e_sector = calloc(SectorsCnt, sizeof(sector));\r
+       e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
        if (e_sector == NULL) {\r
                free(keyBlock);\r
                return 1;\r
@@ -1362,13 +1362,13 @@ int CmdHF14AMfChk(const char *Cmd) {
        return 0;\r
 }\r
 \r
-sector *k_sector = NULL;\r
+sector_t *k_sector = NULL;\r
 uint8_t k_sectorsCount = 16;\r
 static void emptySectorTable(){\r
 \r
        // initialize storage for found keys\r
        if (k_sector == NULL)\r
-               k_sector = calloc(k_sectorsCount, sizeof(sector));\r
+               k_sector = calloc(k_sectorsCount, sizeof(sector_t));\r
        if (k_sector == NULL) \r
                return;\r
                \r
@@ -1720,7 +1720,7 @@ int CmdHF14AMfKeyBrute(const char *Cmd) {
        return 0;       \r
 }\r
 \r
-void printKeyTable( uint8_t sectorscnt, sector *e_sector ){\r
+void printKeyTable( uint8_t sectorscnt, sector_t *e_sector ){\r
        PrintAndLog("|---|----------------|---|----------------|---|");\r
        PrintAndLog("|sec|key A           |res|key B           |res|");\r
        PrintAndLog("|---|----------------|---|----------------|---|");\r
index 26df2df46b935c63d66888664197c3b46dfc95e8..e102dbd0edb7655f3153883bca0aaa50025b3537 100644 (file)
 #include <string.h>\r
 #include <ctype.h>\r
 #include "proxmark3.h"\r
-\r
 #include "iso14443crc.h"\r
 #include "data.h"\r
 #include "ui.h"\r
 #include "cmdparser.h"\r
 #include "common.h"\r
 #include "util.h"\r
-//#include "mifarehost.h"\r
 #include "mifare.h" // nonces_t struct\r
 #include "cmdhfmfhard.h"\r
 #include "nonce2key/nonce2key.h"\r
@@ -63,5 +61,5 @@ int CmdHf14MfDecryptBytes(const char *Cmd);
 \r
 void showSectorTable(void);\r
 void readerAttack(nonces_t data, bool setEmulatorMem, bool verbose);\r
-void printKeyTable( uint8_t sectorscnt, sector *e_sector );\r
+void printKeyTable( uint8_t sectorscnt, sector_t *e_sector );\r
 #endif\r
index 4a386a0ddd244cd47d200b360348928a8cbc85ad..4f5a45194aa65126e2cc8409f7b0dd24a906676f 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <stdint.h>
 
-#ifdef WIN32
+#ifdef _WIN32
 # define HOST_LITTLE_ENDIAN
 #else
 # include <sys/types.h>
index 81f4e06031943aee3c8de7b131388492d8462f80..62d9f4d16974e27ecbc85926589c2fb8b173046a 100644 (file)
@@ -11,7 +11,7 @@
 #ifndef SLEEP_H__
 #define SLEEP_H__
 
-#ifdef WIN32
+#ifdef _WIN32
 #include <windows.h>
 #define sleep(n) Sleep(1000 * n)
 #define msleep(n) Sleep(n)
index 28f56ea85a1bcabebd535e59b9e4ab34c15fade6..9a496b19c3cf0b28d2fc29889bb10809cb620e0d 100644 (file)
@@ -181,27 +181,27 @@ local _keys = {
     hotel system cards,
        http://www.proxmark.org/forum/viewtopic.php?id=2430
     --]]       
-         '44ab09010845',
-      '85fed980ea5a',
+       '44ab09010845',
+    '85fed980ea5a',
          
-        --[[
-        VIGIK1
-        --]]
-        '314B49474956',
-        '564c505f4d41',
+       --[[
+       VIGIK1
+       --]]
+       '314B49474956',
+       '564c505f4d41',
         
-        --[[
-        BCARD keyB
-        --]]
-        'f4a9ef2afc6d',
+       --[[
+       BCARD keyB
+       --]]
+       'f4a9ef2afc6d',
         
-        --[[    
-        --]]
-        'a9f953def0a3',
+       --[[     
+       --]]
+       'a9f953def0a3',
         
-        --[[
-        mystery Key A and B for Mifare 1k EV1 (S50) Sector 17!
-        --]]
+       --[[
+       mystery Key A and B for Mifare 1k EV1 (S50) Sector 17!
+       --]]
        '75ccb59c9bed',
        '4b791bea7bcc',
        
@@ -451,6 +451,9 @@ local _keys = {
        '0ffbf65b5a14',
        'c5cfe06d9ea3',
        'c0dece673829', 
+       --[[
+       --]]
+       'a56c2df9a26d',
 }
 
 ---
index d1bfa69abba271feb6212f575429b5a3a0082195..5d39221f161f423ee6bd39cfb96f836d7ab69df0 100644 (file)
@@ -192,8 +192,10 @@ out:
 }\r
 \r
 int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key){\r
-       *key = 0;\r
-       UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType<<8)), clear_trace, keycnt}};\r
+#define STD_SEARCH 1\r
+#define EXT_SEARCH 2\r
+       *key = 0;       \r
+       UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), ((EXT_SEARCH << 8) | clear_trace), keycnt}};\r
        memcpy(c.d.asBytes, keyBlock, 6 * keycnt);\r
        clearCommandBuffer();\r
        SendCommand(&c);\r
index 4f6b984a9026e3dd77bec23ef0f9246699e277bb..e172bd391a4ec31008057c862c3bac139b3ebe65 100644 (file)
@@ -58,7 +58,7 @@ typedef struct {
 typedef struct {\r
        uint64_t Key[2];\r
        int foundKey[2];\r
-} sector;\r
+} sector_t;\r
  \r
 extern int compar_int(const void * a, const void * b);\r
 extern char logHexFileName[FILE_PATH_SIZE];\r
index 804b6115c39f444c617181aa029714c3a35b598b..937c917246252285b119bf0555a6a8103842f6c0 100644 (file)
@@ -30,6 +30,7 @@ If you want to add more, just put them inside /lualibs/mf_default_keys.lua\n"):f
 
 Arguments:
        -h             : this help
+       -p             : print keys
 ]]
 
 local TIMEOUT = 10000 -- 10 seconds
@@ -179,12 +180,20 @@ local function dumptofile(results)
                file:close()
        end
 end
+local function printkeys() 
+       for i=0,#keys do
+               print(i,keys[i])
+               
+       end
+       print ('Number of keys: '..#keys)
+end
 
 local function main( args)
 
        -- Arguments for the script
-       for o, a in getopt.getopt(args, 'h') do
+       for o, a in getopt.getopt(args, 'hp') do
                if o == "h" then return help() end                      
+               if o == "p" then return printkeys() end
        end
        
        result, err = reader.read1443a()
Impressum, Datenschutz