diff --git a/CHANGELOG.md b/CHANGELOG.md index 3caa5134d..bcd40f863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] - - Change `hf legic view/eview/info` - now in verbose mode will print raw hex dump (@iceman1001) + - Changed `lf cotag demo` - a new decoder (@iceman1001) + - Changed `hf legic view/eview/info` - now in verbose mode will print raw hex dump (@iceman1001) - Added new test for cotag demod using data commands in pm3_test.sh (@iceman1001) - Added new sample trace file for cotag w fc/272. Thanks s1acky! (@iceman1001) - Fixed `hf legic eload` - now it doesn't crash client (@doegox) diff --git a/client/src/cmdlfcotag.c b/client/src/cmdlfcotag.c index 8161ceacc..2306b0024 100644 --- a/client/src/cmdlfcotag.c +++ b/client/src/cmdlfcotag.c @@ -25,6 +25,7 @@ #include "ui.h" // PrintAndLog #include "ctype.h" // tolower #include "cliparser.h" +#include "commonutil.h" // reflect32 static int CmdHelp(const char *Cmd); @@ -37,6 +38,9 @@ int demodCOTAG(bool verbose) { size_t bitlen = COTAG_BITS; memcpy(bits, g_DemodBuffer, COTAG_BITS); + uint8_t inv_bits[COTAG_BITS] = {0}; + memcpy(inv_bits, g_DemodBuffer, COTAG_BITS); + uint8_t alignPos = 0; uint16_t err = manrawdecode(bits, &bitlen, 1, &alignPos); if (err > 50) { @@ -55,14 +59,38 @@ int demodCOTAG(bool verbose) { uint32_t raw3 = bytebits_to_byteLSBF(bits + 64, 32); uint32_t raw4 = bytebits_to_byteLSBF(bits + 96, 32); + /* fc 161: 1010 0001 -> LSB 1000 0101 cn 33593 1000 0011 0011 1001 -> LSB 1001 1100 1100 0001 cccc cccc cccc cccc ffffffff 0 1001 1100 1100 0001 1000 0101 0000 0000 100001010000000001111011100000011010000010000000000000000000000000000000000000000000000000000000100111001100000110000101000 1001 1100 1100 0001 10000101 + + COTAG FC/272 + 1 7 7 D E 2 0 0 8 0 0 0 3 9 2 0 D 0 4 0000000000000 + 0001 0111 0111 1101 1110 0010 0000 0000 1000 0000 0000 0000 0011 1001 0010 0000 1101 0000 0100 0000000000000000000000000000000000000000000000000000000 + 0001 0111 0111 1101 1110 001 0010 1001 0011 1000 0110 0100 + */ PrintAndLogEx(SUCCESS, "COTAG Found: FC " _GREEN_("%u")", CN: " _GREEN_("%u")" Raw: %08X%08X%08X%08X", fc, cn, raw1, raw2, raw3, raw4); + + bitlen = COTAG_BITS; + err = manrawdecode(inv_bits, &bitlen, 0, &alignPos); + if (err < 50) { + uint32_t cn_large = bytebits_to_byte(inv_bits + 1, 23); + cn_large = reflect32(cn_large) >> 9; + uint8_t a = bytebits_to_byte(inv_bits + 48, 4); + uint8_t b = bytebits_to_byte(inv_bits + 52, 4); + uint8_t c = bytebits_to_byte(inv_bits + 56, 4); + uint16_t fc_large = NIBBLE_LOW(c) << 8 | NIBBLE_LOW(b) << 4 | NIBBLE_LOW(a); + + raw1 = bytebits_to_byte(inv_bits, 32); + raw2 = bytebits_to_byte(inv_bits + 32, 32); + raw3 = bytebits_to_byte(inv_bits + 64, 32); + raw4 = bytebits_to_byte(inv_bits + 96, 32); + PrintAndLogEx(SUCCESS, " FC " _GREEN_("%u")", CN: " _GREEN_("%u")" Raw: %08X%08X%08X%08X", fc_large, cn_large, raw1, raw2, raw3, raw4); + } return PM3_SUCCESS; } diff --git a/client/src/comms.c b/client/src/comms.c index 3b7509a38..1422c42d3 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -97,7 +97,7 @@ void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, v #endif if (!g_session.pm3_present) { - PrintAndLogEx(WARNING, "Sending bytes to Proxmark3 failed." _YELLOW_("offline")); + PrintAndLogEx(WARNING, "Sending bytes to Proxmark3 failed ( " _RED_("offline") " )"); return; }