From: iceman1001 Date: Fri, 13 Feb 2015 09:16:21 +0000 (+0100) Subject: chg: step two for t55xx commnads X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/4e7af352b41bf13d283e25eeb049b59022f8bc46?ds=sidebyside chg: step two for t55xx commnads --- diff --git a/armsrc/epa.c b/armsrc/epa.c index 86f7c864..9012bf11 100644 --- a/armsrc/epa.c +++ b/armsrc/epa.c @@ -430,8 +430,6 @@ int EPA_Setup() // power up the field iso14443a_setup(FPGA_HF_ISO14443A_READER_MOD); - iso14a_set_timeout(10500); - // select the card return_code = iso14443a_select_card(uid, &card_select_info, NULL); if (return_code != 1) { diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index b060bdee..a48945ab 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -76,29 +76,11 @@ int usage_t55xx_dump(){ static int CmdHelp(const char *Cmd); -/* -FSK1 / FSK1a -size = fskdemod(dest, size, 32, 0, 8, 10); // fsk1 RF/32 -size = fskdemod(dest, size, 32, 1, 8, 10); // fsk1a RF/32 - -FSK2 / FSK2a -size = fskdemod(dest, size, 32, 0, 10, 8); // fsk2 RF/32 -size = fskdemod(dest, size, 32, 1, 10, 8); // fsk2a RF/32 -size = fskdemod(dest, size, 50, 1, 10, 8); // fsk2a RF/50 -size = fskdemod(dest, size, 64, 1, 10, 8); // FSK2a RF/64 - -*/ - int CmdReadBlk(const char *Cmd) { - int invert = 0; - int clk = 0; int block = -1; int password = 0xFFFFFFFF; //default to blank Block 7 - int errCnt; size_t bitlen; - int maxErr = 100; - //uint8_t askAmp = 0; uint32_t blockData; uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00}; @@ -139,32 +121,22 @@ int CmdReadBlk(const char *Cmd) CmdSamples("12000"); bitlen = getFromGraphBuf(bits); - - //errCnt = askrawdemod(bits, &bitlen, &clk, &invert, maxErr, askAmp); - errCnt = askmandemod(bits, &bitlen, &clk, &invert, maxErr); - - //throw away static - allow 1 and -1 (in case of threshold command first) - if ( errCnt == -1 || bitlen < 16 ){ - PrintAndLog("no data found"); - if (g_debugMode) - PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert); - return 3; - } - if (g_debugMode) - PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d", clk, invert, bitlen); + if ( !tryDemod(bits, bitlen) ) + return 3; + //move bits back to DemodBuffer setDemodBuf(bits, bitlen, 0); - printBitStream(bits,bitlen); + printBitStream(bits, bitlen); - // bits has the manchester encoded data. - errCnt = manrawdecode(bits, &bitlen); - if ( errCnt == -1 || bitlen < 16 ){ - PrintAndLog("no data found"); - if (g_debugMode) - PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert); - return 4; - } + // // bits has the manchester encoded data. + // errCnt = manrawdecode(bits, &bitlen); + // if ( errCnt == -1 || bitlen < 32 ){ + // PrintAndLog("no data found"); + // if (g_debugMode) + // PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert); + // return 4; + // } blockData = PackBits(1, 32, bits); @@ -176,6 +148,69 @@ int CmdReadBlk(const char *Cmd) return 0; } + +/* +FSK1 / FSK1a +size = fskdemod(dest, size, 32, 0, 8, 10); // fsk1 RF/32 +size = fskdemod(dest, size, 32, 1, 8, 10); // fsk1a RF/32 + +FSK2 / FSK2a +size = fskdemod(dest, size, 32, 0, 10, 8); // fsk2 RF/32 +size = fskdemod(dest, size, 32, 1, 10, 8); // fsk2a RF/32 +size = fskdemod(dest, size, 50, 1, 10, 8); // fsk2a RF/50 +size = fskdemod(dest, size, 64, 1, 10, 8); // FSK2a RF/64 + +PSK1 +errCnt = pskRawDemod(bits, &bitlen, 32, 0); +*/ +bool tryDemod(uint8_t bits[], size_t bitlen) { + + int invert = 0; + int clk = 0; + int errCnt, size; + int maxErr = 100; + uint8_t rflen, fchigh, fclow, dummy = 0; + uint16_t fcs=0; + + // ASK - manchester demod + errCnt = askmandemod(bits, &bitlen, &clk, &invert, maxErr); + if ( analyseDemod(errCnt, bitlen, clk, invert) ) + return true; + + // FSK demod + fcs = countFC(bits, bitlen, &dummy); + if (fcs == 0){ + fchigh = 10; + fclow = 8; + }else{ + fchigh = (fcs >> 8) & 0xFF; + fclow = fcs & 0xFF; + } + //get bit clock length + rflen = detectFSKClk(bits, bitlen, fchigh, fclow); + rflen = (rflen == 0) ? 50 : rflen; + + size = fskdemod(bits, bitlen, rflen, invert, fchigh, fclow); + if ( analyseDemod(size, bitlen, clk, invert) ) + return true; + + // PSK demod + return false; +} + +bool analyseDemod( int errCnt, size_t bitlen, uint8_t clock, uint8_t invert){ + if (g_debugMode) + PrintAndLog("ErrorCount: %d, Bits Found: %d, Clock: %d, invert: %d", errCnt, bitlen, clock, invert); + //PrintAndLog("Args invert: %d - Clock:%d - fchigh:%d - fclow: %d",invert,rfLen,fchigh, fclow); + + //throw away static - allow 1 and -1 (in case of threshold command first) + if ( errCnt == -1 || bitlen < 32 ){ + PrintAndLog("no success demod"); + return false; + } + return true; +} + int CmdWriteBlk(const char *Cmd) { int block = 8; //default to invalid block diff --git a/client/cmdlft55xx.h b/client/cmdlft55xx.h index 8c0cdf58..cbd6312a 100644 --- a/client/cmdlft55xx.h +++ b/client/cmdlft55xx.h @@ -13,9 +13,7 @@ int CmdLFT55XX(const char *Cmd); int CmdReadBlk(const char *Cmd); -int CmdReadBlkPWD(const char *Cmd); int CmdWriteBlk(const char *Cmd); -int CmdWriteBLkPWD(const char *Cmd); int CmdReadTrace(const char *Cmd); int CmdInfo(const char *Cmd); int CmdIceFsk(const char *Cmd); @@ -25,4 +23,6 @@ char * GetBitRateStr(uint32_t id); char * GetSaferStr(uint32_t id); char * GetModulationStr( uint32_t id); uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bitstream); +bool tryDemod(uint8_t bits[], uint32_t bitlen); +bool analyseDemod( int errCnt, size_t bitlen, uint8_t clock, uint8_t invert); #endif