X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/35147d51e3961db75a852368fffa31006da90199..f6c18637ca504d2eea0bc3accaabddd132d749fb:/client/cmdlfem4x.c diff --git a/client/cmdlfem4x.c b/client/cmdlfem4x.c index be31e1ea..8380bcba 100644 --- a/client/cmdlfem4x.c +++ b/client/cmdlfem4x.c @@ -21,6 +21,7 @@ #include "cmdlfem4x.h" #include "util.h" #include "data.h" +#define LF_TRACE_BUFF_SIZE 12000 char *global_em410xId; @@ -506,84 +507,80 @@ int CmdEM410xWrite(const char *Cmd) int CmdReadWord(const char *Cmd) { int Word = -1; //default to invalid word - UsbCommand c; + UsbCommand c; - sscanf(Cmd, "%d", &Word); + sscanf(Cmd, "%d", &Word); if ( (Word > 15) | (Word < 0) ) { - PrintAndLog("Word must be between 0 and 15"); - return 1; - } + PrintAndLog("Word must be between 0 and 15"); + return 1; + } - PrintAndLog("Reading word %d", Word); + PrintAndLog("Reading word %d", Word); - c.cmd = CMD_EM4X_READ_WORD; - c.d.asBytes[0] = 0x0; //Normal mode - c.arg[0] = 0; - c.arg[1] = Word; - c.arg[2] = 0; - SendCommand(&c); + c.cmd = CMD_EM4X_READ_WORD; + c.d.asBytes[0] = 0x0; //Normal mode + c.arg[0] = 0; + c.arg[1] = Word; + c.arg[2] = 0; + SendCommand(&c); WaitForResponse(CMD_ACK, NULL); - size_t bytelength = 4096; - uint8_t data[bytelength]; - memset(data, 0x00, bytelength); + uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00}; - GetFromBigBuf(data,bytelength,3560); //3560 -- should be offset.. + GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset.. WaitForResponseTimeout(CMD_ACK,NULL, 1500); - for (int j = 0; j < bytelength; j++) { - GraphBuffer[j] = ((int)data[j]) - 128; + for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { + GraphBuffer[j] = ((int)data[j]); } - GraphTraceLen = bytelength; - RepaintGraphWindow(); - - manchester_decode(data, bytelength); - - free(data); + GraphTraceLen = LF_TRACE_BUFF_SIZE; + uint8_t bits[1000] = {0x00}; + uint8_t * bitstream = bits; + manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); + RepaintGraphWindow(); return 0; } int CmdReadWordPWD(const char *Cmd) { int Word = -1; //default to invalid word - int Password = 0xFFFFFFFF; //default to blank password - UsbCommand c; - - sscanf(Cmd, "%d %x", &Word, &Password); - + int Password = 0xFFFFFFFF; //default to blank password + UsbCommand c; + + sscanf(Cmd, "%d %x", &Word, &Password); + if ( (Word > 15) | (Word < 0) ) { - PrintAndLog("Word must be between 0 and 15"); - return 1; - } - - PrintAndLog("Reading word %d with password %08X", Word, Password); + PrintAndLog("Word must be between 0 and 15"); + return 1; + } - c.cmd = CMD_EM4X_READ_WORD; - c.d.asBytes[0] = 0x1; //Password mode - c.arg[0] = 0; - c.arg[1] = Word; - c.arg[2] = Password; - SendCommand(&c); + PrintAndLog("Reading word %d with password %08X", Word, Password); + + c.cmd = CMD_EM4X_READ_WORD; + c.d.asBytes[0] = 0x1; //Password mode + c.arg[0] = 0; + c.arg[1] = Word; + c.arg[2] = Password; + SendCommand(&c); WaitForResponse(CMD_ACK, NULL); + + uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00}; - size_t bytelength = 4096; - uint8_t data[bytelength]; - memset(data, 0x00, bytelength); - - GetFromBigBuf(data,bytelength,3560); //3560 -- should be offset.. + GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset.. WaitForResponseTimeout(CMD_ACK,NULL, 1500); - for (int j = 0; j < bytelength; j++) { - GraphBuffer[j] = ((int)data[j]) - 128; + for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { + GraphBuffer[j] = ((int)data[j]); } - GraphTraceLen = bytelength; + GraphTraceLen = LF_TRACE_BUFF_SIZE; + + uint8_t bits[1000] = {0x00}; + uint8_t * bitstream = bits; + + manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); RepaintGraphWindow(); - - manchester_decode(data, bytelength); - - free(data); return 0; } @@ -636,8 +633,6 @@ int CmdWriteWordPWD(const char *Cmd) return 0; } - - static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"},