]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmfdes.c
FIX: 'hf mf mifare' - special zero parity attack vector now works. Thanks to the...
[proxmark3-svn] / client / cmdhfmfdes.c
index 516b41bd72d258147e46037fead2ee861cdc2e08..a00592330e9d4ad37733128afce4997f3df53753 100644 (file)
@@ -12,7 +12,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-//#include <openssl/des.h>
 #include "loclass/des.h"
 #include "cmdmain.h"
 #include "proxmark3.h"
@@ -160,7 +159,7 @@ int CmdHF14ADesInfo(const char *Cmd){
        PrintAndLog("      Vendor Id      : %s", getTagInfo(resp.d.asBytes[7]));
        PrintAndLog("      Type           : 0x%02X",resp.d.asBytes[8]);
        PrintAndLog("      Subtype        : 0x%02X",resp.d.asBytes[9]);
-       PrintAndLog("      Version        : %d.%d",resp.d.asBytes[10], resp.d.asBytes[11]);
+       PrintAndLog("      Version        : %s",GetVersionStr(resp.d.asBytes[10], resp.d.asBytes[11]) );
        PrintAndLog("      Storage size   : %s",GetCardSizeStr(resp.d.asBytes[12]));
        PrintAndLog("      Protocol       : %s",GetProtocolStr(resp.d.asBytes[13]));
        PrintAndLog("  -----------------------------------------------------------");
@@ -218,7 +217,7 @@ int CmdHF14ADesInfo(const char *Cmd){
 */
 char * GetCardSizeStr( uint8_t fsize ){
  
-       static char buf[30];
+       static char buf[30] = {0x00};
        char *retStr = buf;
 
        uint16_t usize = 1 << ((fsize >>1) + 1);
@@ -234,7 +233,7 @@ char * GetCardSizeStr( uint8_t fsize ){
 
 char * GetProtocolStr(uint8_t id){
 
-       static char buf[30];
+       static char buf[30] = {0x00};
        char *retStr = buf;
 
        if ( id == 0x05)
@@ -244,6 +243,22 @@ char * GetProtocolStr(uint8_t id){
        return buf;
 }
 
+char * GetVersionStr(uint8_t major, uint8_t minor){
+
+       static char buf[30] = {0x00};
+       char *retStr = buf;
+
+       if ( major == 0x00)
+               sprintf(retStr,"%d.%d (Desfire MF3ICD40)", major, minor);       
+       else if ( major == 0x01 && minor == 0x00)
+               sprintf(retStr,"%d.%d (Desfire EV1)", major, minor);
+       else if ( major == 0x12 && minor == 0x00)
+               sprintf(retStr,"%d.%d (Desfire EV2)", major, minor);
+       else
+               sprintf(retStr,"%d.%d (Unknown)", major, minor);
+       return buf;
+}
+
 void GetKeySettings( uint8_t *aid){
        
        char messStr[512] = {0x00};
@@ -353,7 +368,7 @@ void GetKeySettings( uint8_t *aid){
                        PrintAndLog("   Can't read Application Master key settings");
                } else {
                        // Access rights.
-                       uint8_t rights = (resp.d.asBytes[3] >> 4 && 0xff);
+                       uint8_t rights = (resp.d.asBytes[3] >> 4 & 0xff);
                        switch (rights){
                                case 0x00:
                                        str = "AMK authentication is necessary to change any key (default)";
@@ -612,7 +627,7 @@ int CmdHF14ADesAuth(const char *Cmd){
        
        c.d.asBytes[0] = keylength;
        memcpy(c.d.asBytes+1, key, keylength);
-       
+       clearCommandBuffer();
     SendCommand(&c);
        UsbCommand resp;
        
@@ -637,8 +652,7 @@ int CmdHF14ADesAuth(const char *Cmd){
 }
 
 
-static command_t CommandTable[] =
-{
+static command_t CommandTable[] = {
   {"help",             CmdHelp,                                        1, "This help"},
   {"info",             CmdHF14ADesInfo,                        0, "Get MIFARE DesFire information"},
   {"enum",             CmdHF14ADesEnumApplications,0, "Tries enumerate all applications"},
@@ -648,18 +662,16 @@ static command_t CommandTable[] =
   {NULL, NULL, 0, NULL}
 };
 
-int CmdHFMFDes(const char *Cmd)
-{
+int CmdHFMFDes(const char *Cmd) {
    // flush
-   WaitForResponseTimeout(CMD_ACK,NULL,100);
-   CmdsParse(CommandTable, Cmd);
-  return 0;
+       clearCommandBuffer();
+       CmdsParse(CommandTable, Cmd);
+       return 0;
 }
 
-int CmdHelp(const char *Cmd)
-{
-  CmdsHelp(CommandTable);
-  return 0;
+int CmdHelp(const char *Cmd) {
+       CmdsHelp(CommandTable);
+       return 0;
 }
 
 
Impressum, Datenschutz