X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/8ae9b358f85bdfc60e269c0e93c8fa911869706a..29ce214c65d0d36679b8496dd8dddf4ea2b0ec23:/client/cmdlfjablotron.c diff --git a/client/cmdlfjablotron.c b/client/cmdlfjablotron.c index 1401f11e..da4b0040 100644 --- a/client/cmdlfjablotron.c +++ b/client/cmdlfjablotron.c @@ -35,6 +35,15 @@ int usage_lf_jablotron_sim(void) { return 0; } +static uint8_t jablontron_chksum(uint8_t *bits){ + uint8_t chksum = 0; + for (int i=16; i < 56; i += 8) { + chksum += bytebits_to_byte(bits+i,8); + } + chksum ^= 0x3A; + return chksum; +} + int getJablotronBits(uint64_t fullcode, uint8_t *bits) { //preamp num_to_bytebits(0xFFFF, 16, bits); @@ -43,13 +52,8 @@ int getJablotronBits(uint64_t fullcode, uint8_t *bits) { num_to_bytebits(fullcode, 40, bits+16); //chksum byte - uint8_t crc = 0; - for (int i=16; i < 56; i += 8) { - crc += bytebits_to_byte(bits+i,8); - } - crc ^= 0x3A; - num_to_bytebits(crc, 8, bits+56); - + uint8_t chksum = jablontron_chksum(bits); + num_to_bytebits(chksum, 8, bits+56); return 1; } @@ -68,32 +72,46 @@ int CmdJablotronDemod(const char *Cmd) { if (g_debugMode){ // if (ans == -5) // PrintAndLog("DEBUG: Error - not enough samples"); - // else if (ans == -1) - // PrintAndLog("DEBUG: Error - only noise found"); + if (ans == -1) + PrintAndLog("DEBUG: Error - Jablotron too few bits found"); // else if (ans == -2) // PrintAndLog("DEBUG: Error - problem during ASK/Biphase demod"); - if (ans == -3) - PrintAndLog("DEBUG: Error - Size not correct: %d", size); + else if (ans == -3) + PrintAndLog("DEBUG: Error - Jablotron Size not correct: %d", size); else if (ans == -4) PrintAndLog("DEBUG: Error - Jablotron preamble not found"); + else if (ans == -5) + PrintAndLog("DEBUG: Error - Jablotron checksum failed"); else PrintAndLog("DEBUG: Error - ans: %d", ans); } return 0; } + + setDemodBuf(DemodBuffer+ans, 64, 0); + //got a good demod - uint32_t raw1 = bytebits_to_byte(DemodBuffer+ans, 32); - uint32_t raw2 = bytebits_to_byte(DemodBuffer+ans+32, 32); - uint64_t cardid = (raw1 & 0x0000FFFF); - cardid <<= 32; + uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32); + uint32_t raw2 = bytebits_to_byte(DemodBuffer+32, 32); + uint64_t cardid = (raw1 & 0xFFFF); + cardid <<= 24; cardid |= (raw2 >> 8); - PrintAndLog("Jablotron Tag Found: Card ID %012X", cardid); + PrintAndLog("Jablotron Tag Found: Card ID %"PRIx64, cardid); PrintAndLog("Raw: %08X%08X", raw1 ,raw2); - setDemodBuf(DemodBuffer+ans, 64, 0); - - //PrintAndLog("1410-%u-%u-%08X-%02X", fullcode); + uint8_t chksum = raw2 & 0xFF; + PrintAndLog("Checksum: %02X [%s]", + chksum, + (chksum == jablontron_chksum(DemodBuffer)) ? "OK":"FAIL" + ); + + // Printed format: 1410-nn-nnnn-nnnn + PrintAndLog("Printed: 1410-%02X-%04X-%04X", + (raw1 & 0x0000FF00) >> 8, + (raw1 & 0xFF) << 8 | ((raw2 >> 24) & 0xFF), + (raw2 & 0x00FFFF00) >> 8 + ); return 1; } @@ -123,11 +141,12 @@ int CmdJablotronClone(const char *Cmd) { blocks[0] = T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | 64<