]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: @marshmellow42 's changes / fixes.
authoriceman1001 <iceman@iuse.se>
Sun, 31 May 2015 19:47:33 +0000 (21:47 +0200)
committericeman1001 <iceman@iuse.se>
Sun, 31 May 2015 19:47:33 +0000 (21:47 +0200)
armsrc/iso14443a.c
armsrc/mifarecmd.c
armsrc/mifareutil.c
armsrc/mifareutil.h
client/cmddata.c
client/cmdlft55xx.c
client/scripting.c

index 200e31f25ee1a2991067948232bb8a11138d3648..84fbd661422b34c6520f8e346df9de67e0407824 100644 (file)
@@ -673,6 +673,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
                                        }
                                        /* And ready to receive another command. */
                                        UartReset();
+                                       //UartInit(receivedCmd, receivedCmdPar);
                                        /* And also reset the demod code, which might have been */
                                        /* false-triggered by the commands from the reader. */
                                        DemodReset();
@@ -1034,7 +1035,7 @@ void SimulateIso14443aTag(int tagType, int flags, int uid_2nd, byte_t* data)
        response3a[0] = sak & 0xFB;
        ComputeCrc14443(CRC_14443_A, response3a, 1, &response3a[1], &response3a[2]);
 
-       uint8_t response5[] = { 0x01, 0x02, 0x03, 0x04 }; // Very random tag nonce
+       uint8_t response5[] = { 0x01, 0x01, 0x01, 0x01 }; // Very random tag nonce
        uint8_t response6[] = { 0x04, 0x58, 0x80, 0x02, 0x00, 0x00 }; // dummy ATS (pseudo-ATR), answer to RATS: 
        // Format byte = 0x58: FSCI=0x08 (FSC=256), TA(1) and TC(1) present, 
        // TA(1) = 0x80: different divisors not supported, DR = 1, DS = 1
@@ -2332,7 +2333,7 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *
        uint8_t rSAK[] = {0x09, 0x3f, 0xcc };  // Mifare Mini 
        uint8_t rSAK1[] = {0x04, 0xda, 0x17};
 
-       uint8_t rAUTH_NT[] = {0x01, 0x02, 0x03, 0x04};
+       uint8_t rAUTH_NT[] = {0x01, 0x01, 0x01, 0x01};
        uint8_t rAUTH_AT[] = {0x00, 0x00, 0x00, 0x00};
                
        //Here, we collect UID,NT,AR,NR,UID2,NT2,AR2,NR2
@@ -2341,8 +2342,6 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *
        uint32_t ar_nr_responses[] = {0,0,0,0,0,0,0,0,0,0};
        uint8_t ar_nr_collected = 0;
 
-       Dbprintf("FIRE");
-       
        // free eventually allocated BigBuf memory but keep Emulator Memory
        BigBuf_free_keep_EM();
 
@@ -2350,7 +2349,6 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *
        clear_trace();
        set_tracing(TRUE);
 
-       Dbprintf("ICE");
        // Authenticate response - nonce
        uint32_t nonce = bytes_to_num(rAUTH_NT, 4);
        
@@ -2380,7 +2378,6 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *
                }
        }
 
-       Dbprintf("ICE2");
        // save uid.
        ar_nr_responses[0*5]   = bytes_to_num(rUIDBCC1+1, 3);
        if ( _7BUID )
@@ -2413,7 +2410,6 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *
                }
        }
 
-       Dbprintf("ICE3");
        bool finished = FALSE;
        while (!BUTTON_PRESS() && !finished) {
                WDT_HIT();
@@ -2933,7 +2929,8 @@ void RAMFUNC SniffMifare(uint8_t param) {
                                        if (MfSniffLogic(receivedCmd, Uart.len, Uart.parity, Uart.bitCount, TRUE)) break;
 
                                        /* And ready to receive another command. */
-                                       UartInit(receivedCmd, receivedCmdPar);
+                                       //UartInit(receivedCmd, receivedCmdPar);
+                                       UartReset();
                                        
                                        /* And also reset the demod code */
                                        DemodReset();
index 17100131be25959e390fbd84c43e8fd4b6aaa858..5d10ad8161c2a97227ff9fbd91b728d87bfb68a9 100644 (file)
@@ -742,7 +742,7 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
 \r
                        // nested authentication\r
                        auth2_time = auth1_time + delta_time;\r
-                       len = mifare_sendcmd_shortex(pcs, AUTH_NESTED, 0x60 + (targetKeyType & 0x01), targetBlockNo, receivedAnswer, par, &auth2_time);\r
+                       len = mifare_sendcmd_short(pcs, AUTH_NESTED, 0x60 + (targetKeyType & 0x01), targetBlockNo, receivedAnswer, par, &auth2_time);\r
                        if (len != 4) {\r
                                if (MF_DBGLEVEL >= 1)   Dbprintf("Nested: Auth2 error len=%d", len);\r
                                continue;\r
index 1b71f05de55cc911c79ab3f1fe52d34a3d5d02de..c9ff8c6487c2da866efe84e0d87658c304c431d0 100644 (file)
@@ -65,12 +65,6 @@ uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data) {
        return bt;\r
 }\r
 \r
-// send 2 byte commands\r
-int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing)\r
-{\r
-       return mifare_sendcmd_shortex(pcs, crypted, cmd, data, answer, answer_parity, timing);\r
-}\r
-\r
 // send X byte basic commands\r
 int mifare_sendcmd(uint8_t cmd, uint8_t* data, uint8_t data_size, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing)\r
 {\r
@@ -88,52 +82,8 @@ int mifare_sendcmd(uint8_t cmd, uint8_t* data, uint8_t data_size, uint8_t* answe
        return len;\r
 }\r
 \r
-/*\r
-int mifare_sendcmd_short_mfucauth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
-{\r
-    uint8_t dcmd[19];\r
-       int len; \r
-    dcmd[0] = cmd;\r
-    memcpy(dcmd+1,data,16);\r
-       AppendCrc14443a(dcmd, 17);\r
-       \r
-       ReaderTransmit(dcmd, sizeof(dcmd), timing);\r
-       len = ReaderReceive(answer, answer_parity);\r
-       if(!len) {\r
-        if (MF_DBGLEVEL >= MF_DBG_ERROR)   Dbprintf("Authentication failed. Card timeout.");\r
-        len = ReaderReceive(answer,answer_parity);\r
-    }\r
-    if(len==1) {\r
-               if (MF_DBGLEVEL >= MF_DBG_ERROR)   Dbprintf("NAK - Authentication failed.");\r
-               return 1;\r
-        }\r
-       return len;\r
-}\r
-\r
-int mifare_sendcmd_short_mfuev1auth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
-{\r
-    uint8_t dcmd[7];\r
-       int len; \r
-    dcmd[0] = cmd;\r
-    memcpy(dcmd+1,data,4);\r
-       AppendCrc14443a(dcmd, 5);\r
-       \r
-       ReaderTransmit(dcmd, sizeof(dcmd), timing);\r
-       len = ReaderReceive(answer, answer_parity);\r
-       if(!len) {\r
-        if (MF_DBGLEVEL >= MF_DBG_ERROR)   Dbprintf("Authentication failed. Card timeout.");\r
-        len = ReaderReceive(answer,answer_parity);\r
-    }\r
-    if(len==1) {\r
-               if (MF_DBGLEVEL >= MF_DBG_ERROR)   Dbprintf("NAK - Authentication failed.");\r
-               return 1;\r
-        }\r
-       return len;\r
-}\r
-*/\r
-\r
 // send 2 byte commands\r
-int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
+int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
 {\r
        uint8_t dcmd[4], ecmd[4];\r
        uint16_t pos, res;\r
@@ -321,7 +271,6 @@ int mifare_ul_ev1_auth(uint8_t *keybytes, uint8_t *pack){
 \r
        if (MF_DBGLEVEL >= MF_DBG_EXTENDED)\r
                Dbprintf("EV1 Auth : %02x%02x%02x%02x", key[0], key[1], key[2], key[3]);\r
-       \r
        len = mifare_sendcmd(0x1B, key, sizeof(key), resp, respPar, NULL);\r
        //len = mifare_sendcmd_short_mfuev1auth(NULL, 0, 0x1B, key, resp, respPar, NULL);\r
        if (len != 4) {\r
index f9ffc7dd529602bde05e33be4e9491028a5eb204..679b68d694334aeb01edd7be039b24ea718f3740 100644 (file)
@@ -53,11 +53,8 @@ extern int MF_DBGLEVEL;
 #define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();\r
 \r
 //functions
+int mifare_sendcmd(uint8_t cmd, uint8_t *data, uint8_t data_size, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);\r
 int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
-int mifare_sendcmd(uint8_t cmd, uint8_t *data, uint8_t data_size, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
-\r//int mifare_sendcmd_short_mfucauth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing);\r
-//int mifare_sendcmd_short_mfuev1auth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing);\r
-int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
 
 // mifare classic\r
 int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested);\r
index b9069bc19cb82b150b05de62345a188a56e5f6aa..76552351846713d433309c0ba9ce2c0de31617dc 100644 (file)
@@ -55,6 +55,15 @@ int CmdSetDebugMode(const char *Cmd)
        return 1;
 }
 
+int usage_data_printdemodbuf(){
+               PrintAndLog("Usage: data printdemodbuffer x o <offset>");
+               PrintAndLog("Options:        ");
+               PrintAndLog("       h          This help");
+               PrintAndLog("       x          output in hex (omit for binary output)");
+               PrintAndLog("       o <offset> enter offset in # of bits");
+               return 0;       
+}
+
 //by marshmellow
 void printDemodBuff(void)
 {
@@ -73,23 +82,50 @@ void printDemodBuff(void)
 
 int CmdPrintDemodBuff(const char *Cmd)
 {
-       char hex;
-       char printBuff[512]={0x00};
-       uint8_t numBits = DemodBufferLen & 0xFFFC;
-       sscanf(Cmd, "%c", &hex);
-       if (hex == 'h'){
-               PrintAndLog("Usage: data printdemodbuffer [x]");
-               PrintAndLog("Options:        ");
-               PrintAndLog("       h       This help");
-               PrintAndLog("       x       output in hex (omit for binary output)");
-               return 0;
+       char hex[512]={0x00};
+       bool hexMode = false;
+       bool errors = false;
+       uint8_t offset = 0;
+       char cmdp = 0;
+       while(param_getchar(Cmd, cmdp) != 0x00)
+       {
+               switch(param_getchar(Cmd, cmdp))
+               {
+               case 'h':
+               case 'H':
+                       return usage_data_printdemodbuf();
+               case 'x':
+               case 'X':
+                       hexMode = true;
+                       cmdp++;
+                       break;
+               case 'o':
+               case 'O':
+                       offset = param_get8(Cmd, cmdp+1);
+                       if (!offset) errors = true;
+                       cmdp += 2;
+                       break;
+               default:
+                       PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
+                       errors = true;
+                       break;
+               }
+               if(errors) break;
        }
-       if (hex == 'x'){
-               numBits = binarraytohex(printBuff, (char *)DemodBuffer, numBits);
+       //Validations
+       if(errors) return usage_data_printdemodbuf();
+
+       int numBits = (DemodBufferLen-offset) & 0x7FC; //make sure we don't exceed our string
+
+       if (hexMode){
+               char *buf = (char *) (DemodBuffer + offset);
+               numBits = binarraytohex(hex, buf, numBits);
                if (numBits==0) return 0;
-               PrintAndLog("DemodBuffer: %s",printBuff);
+               PrintAndLog("DemodBuffer: %s",hex);             
        } else {
-               printDemodBuff();
+               //setDemodBuf(DemodBuffer, DemodBufferLen-offset, offset);
+               char *bin = sprint_bin_break(DemodBuffer+offset,numBits,16);
+               PrintAndLog("DemodBuffer:\n%s",bin);
        }
        return 1;
 }
@@ -2182,7 +2218,7 @@ static command_t CommandTable[] =
        {"manrawdecode",    Cmdmandecoderaw,    1, "[invert] [maxErr] -- Manchester decode binary stream in DemodBuffer"},
        {"norm",            CmdNorm,            1, "Normalize max/min to +/-128"},
        {"plot",            CmdPlot,            1, "Show graph window (hit 'h' in window for keystroke help)"},
-       {"printdemodbuffer",CmdPrintDemodBuff,  1, "[x] -- print the data in the DemodBuffer - 'x' for hex output"},
+       {"printdemodbuffer",CmdPrintDemodBuff,  1, "[x] [o] <offset> -- print the data in the DemodBuffer - 'x' for hex output"},
        {"pskindalademod",  CmdIndalaDecode,    1, "[clock] [invert<0|1>] -- Demodulate an indala tag (PSK1) from GraphBuffer (args optional)"},
        {"psknexwatchdemod",CmdPSKNexWatch,     1, "Demodulate a NexWatch tag (nexkey, quadrakey) (PSK1) from GraphBuffer"},
        {"rawdemod",        CmdRawDemod,        1, "[modulation] ... <options> -see help (h option) -- Demodulate the data in the GraphBuffer and output binary"},  
index d4b72b3279bbbaf0844f0703334c1d016d6c4176..cf19c0ecf0390c4fb96c13adaffff4cd81cda860 100644 (file)
@@ -61,13 +61,13 @@ int usage_t55xx_read(){
 }\r
 int usage_t55xx_write(){\r
        PrintAndLog("Usage:  lf t55xx wr <block> <data> [password]");\r
-    PrintAndLog("     <block>, block number to read. Between 0-7");\r
+       PrintAndLog("     <block>, block number to write. Between 0-7");\r
        PrintAndLog("     <data>,  4 bytes of data to write (8 hex characters)");\r
     PrintAndLog("     [password], OPTIONAL password 4bytes (8 hex characters)");\r
     PrintAndLog("");\r
        PrintAndLog("Examples:");\r
-    PrintAndLog("      lf t55xx wd 3 11223344           - write 11223344 to block 3");\r
-       PrintAndLog("      lf t55xx wd 3 11223344 feedbeef  - write 11223344 to block 3 password feedbeef");\r
+       PrintAndLog("      lf t55xx wr 3 11223344           - write 11223344 to block 3");\r
+       PrintAndLog("      lf t55xx wr 3 11223344 feedbeef  - write 11223344 to block 3 password feedbeef");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
index b979b652f4b5603b34b1f924e13d239eab8230c7..7ac78394b3d5f98ae29f202fc9cfbaf7a37113dd 100644 (file)
@@ -16,7 +16,6 @@
 #include "cmdmain.h"
 #include "scripting.h"
 #include "util.h"
-#include "ui.h"
 #include "nonce2key/nonce2key.h"
 #include "../common/iso15693tools.h"
 #include "../common/crc16.h"
@@ -347,7 +346,6 @@ static int l_aes128encrypt_ecb(lua_State *L)
        return 1;// return 1 to signal one return value
 }
 
-
 static int l_crc16(lua_State *L)
 {
        size_t size;
@@ -380,8 +378,8 @@ static int l_crc64(lua_State *L)
        return 1;
 }
 
-static int l_sha1(lua_State *L){
-
+static int l_sha1(lua_State *L)
+{
        size_t size;
        const char *p_str = luaL_checklstring(L, 1, &size);     
        unsigned char outdata[20] = {0x00};                                                                                                                                                                     
Impressum, Datenschutz