X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/c48211f7ed175c91d92044e7e08b921e06f8ff3f..e1778858ddc53a6a82e8ee24f02e6b673687f69a:/client/cmdlffdx.c diff --git a/client/cmdlffdx.c b/client/cmdlffdx.c index 58c2cb7c..ae8531a6 100644 --- a/client/cmdlffdx.c +++ b/client/cmdlffdx.c @@ -31,8 +31,8 @@ static int CmdHelp(const char *Cmd); int usage_lf_fdx_clone(void){ - PrintAndLog("clone a FDX-B Animal tag to a T55x7 tag."); - PrintAndLog("Usage: lf fdx clone [h] "); + PrintAndLog("Clone a FDX-B animal tag to a T55x7 tag."); + PrintAndLog("Usage: lf animal clone [h] "); PrintAndLog("Options:"); PrintAndLog(" h : This help"); PrintAndLog(" : Country id"); @@ -41,23 +41,23 @@ int usage_lf_fdx_clone(void){ //reserved/rfu //is animal tag // extended data - PrintAndLog(" : specify write to Q5 (t5555 instead of t55x7)"); + PrintAndLog(" : Specify write to Q5 (t5555 instead of t55x7)"); PrintAndLog(""); - PrintAndLog("Sample: lf fdx clone 999 112233"); + PrintAndLog("Sample: lf animal clone 999 112233"); return 0; } int usage_lf_fdx_sim(void) { - PrintAndLog("Enables simulation of FDX-B Animal tag"); + PrintAndLog("Enables simulation of FDX-B animal tag"); PrintAndLog("Simulation runs until the button is pressed or another USB command is issued."); PrintAndLog(""); - PrintAndLog("Usage: lf fdx sim [h] "); + PrintAndLog("Usage: lf animal sim [h] "); PrintAndLog("Options:"); PrintAndLog(" h : This help"); - PrintAndLog(" : Country id"); - PrintAndLog(" : Animal id"); + PrintAndLog(" : Country ID"); + PrintAndLog(" : Animal ID"); PrintAndLog(""); - PrintAndLog("Sample: lf fdx sim 999 112233"); + PrintAndLog("Sample: lf animal sim 999 112233"); return 0; } // clearing the topbit needed for the preambl detection. @@ -72,54 +72,12 @@ static void verify_values(uint32_t countryid, uint64_t animalid){ } } -static uint16_t getFDXchksum (uint64_t raw){ - uint8_t arr[8]; - num_to_bytes(raw, 64, arr); - return crc16_ccitt_kermit(arr, 8); -} - int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) { - - uint64_t raw = 0; - uint8_t data[117] = {0}; - - raw |= isanimal; - raw |= (0x000 & 0x3ff) << 1; - raw |= isextended << 14; - raw |= (country & 0x3ff) << 15; - raw |= (national_id & 0x3FFFFFFFFF) << 25; - - uint16_t crc = getFDXchksum(raw); - - // add raw to bitarray - num_to_bytebits(raw, 64, data); - // add crc to bitarray - num_to_bytebits(crc, 16, data+64); - - // add extended data to bitarray - num_to_bytebits(extended, 24, data+64+16); - - //reverse array - printf("ICE:\n %s\n", sprint_bin(data, 104) ); - for (uint8_t i = 0; i <104/2; ++i) { - uint8_t tmp = data[i]; - data[i] = data[104-i]; - data[104-i] = tmp; - } - printf("ICE:\n %s\n", sprint_bin(data, 104) ); - - // add parity always EVEN (2), every 8bits - // into output array - uint8_t bitlen = addParity(data, bits+11, 104, 9, 2); - if (bitlen != 117 ) - printf("ICE ERROR PARITY BITLEN 119 != %d\n", bitlen); - // add preamble ten 0x00 and one 0x01 memset(bits, 0x00, 10); bits[10] = 1; - printf("%s\n", sprint_bin_break(bits, 128, 32) ); - /* + // 128bits // every 9th bit is 0x01, but we can just fill the rest with 0x01 and overwrite memset(bits, 0x01, 128); @@ -161,8 +119,6 @@ int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t num_to_bytebitsLSBF( extended >> 0 , 8, bits+101); num_to_bytebitsLSBF( extended >> 8 , 8, bits+110); num_to_bytebitsLSBF( extended >> 16, 8, bits+119); - - */ return 1; } @@ -193,6 +149,7 @@ int CmdFdxDemod(const char *Cmd) { } setDemodBuf(DemodBuffer, 128, ans); + setGrid_Clock(32); // remove marker bits (1's every 9th digit after preamble) (pType = 2) size = removeParity(DemodBuffer, 11, 9, 2, 117); if ( size != 104 ) { @@ -219,8 +176,8 @@ int CmdFdxDemod(const char *Cmd) { uint16_t calcCrc = crc16_ccitt_kermit(raw, 8); PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found: Raw : %s", sprint_hex(raw, 8)); - PrintAndLog("Animal ID %04u-%012llu", countryCode, NationalCode); - PrintAndLog("National Code %012llu (0x%llX)", NationalCode, NationalCode); + PrintAndLog("Animal ID %04u-%012" PRIu64, countryCode, NationalCode); + PrintAndLog("National Code %012" PRIu64 " (0x%" PRIx64 ")", NationalCode, NationalCode); PrintAndLog("Country Code %04u", countryCode); PrintAndLog("Reserved/RFU %u (0x04%X)", reservedCode, reservedCode); PrintAndLog(""); @@ -246,7 +203,7 @@ int CmdFdxClone(const char *Cmd) { uint32_t countryid = 0; uint64_t animalid = 0; - uint32_t blocks[5] = {T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4<>1) << T5555_BITRATE_SHIFT | 4 << T5555_MAXBLOCK_SHIFT; } verify_values(countryid, animalid); @@ -294,7 +251,7 @@ int CmdFdxClone(const char *Cmd) { c.arg[1] = i; clearCommandBuffer(); SendCommand(&c); - if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)){ + if (!WaitForResponseTimeout(CMD_ACK, &resp, T55XX_WRITE_TIMEOUT)){ PrintAndLog("Error occurred, device did not respond during write operation."); return -1; } @@ -333,10 +290,10 @@ int CmdFdxSim(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"}, - {"demod", CmdFdxDemod,1, "Attempt extract tag data from graphbuf"}, + {"demod", CmdFdxDemod,1, "Attempt to extract tag data from graphbuf"}, {"read", CmdFdxRead, 0, "Attempt to read and extract tag data"}, - {"clone", CmdFdxClone,0, "clone animal ID tag"}, - {"sim", CmdFdxSim, 0, "simulate animal ID tag"}, + {"clone", CmdFdxClone,0, "Clone animal ID tag to T55x7"}, + {"sim", CmdFdxSim, 0, "Animal ID tag simulator"}, {NULL, NULL, 0, NULL} };