From: marshmellow42 Date: Thu, 23 Mar 2017 02:59:55 +0000 (-0400) Subject: move viking demod to respective file X-Git-Tag: v3.0.0~40^2 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/f2fc0a9c4df18f9650c30320308a95b6a948e16d move viking demod to respective file see changelog.md for cli changes! --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 59e87277..abd2dd37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - `lf viking read` - read viking tag and output ID - `lf t55xx wipe` - sets t55xx back to factory defaults - Added viking demod to `lf search` (marshmellow) -- `data askvikingdemod` demod viking id tag from graphbuffer (marshmellow) +- `lf viking demod` demod viking id tag from graphbuffer (marshmellow) - `lf t55xx resetread` added reset then read command - should allow determining start of stream transmissions (marshmellow) - `lf t55xx wakeup` added wake with password (AOR) to allow lf search or standard lf read after (iceman, marshmellow) - `hf iclass managekeys` to save, load and manage iclass keys. (adjusted most commands to accept a loaded key in memory) (marshmellow) @@ -45,6 +45,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Added option c to 'hf list' (mark CRC bytes) (piwi) ### Changed +- `data askvikingdemod` has been moved to `lf viking demod` (reads from graphbuffer) - `data fskpyramiddemod` has been moved to `lf pyramid demod` (reads from graphbuffer) - `data fskiodemod` has been moved to `lf io demod` (reads from graphbuffer) - `lf io fskdemod` has been renamed to `lf io read` (reads from antenna) diff --git a/client/cmddata.c b/client/cmddata.c index 1924e5f7..49c94674 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -510,33 +510,6 @@ int CmdG_Prox_II_Demod(const char *Cmd) return 1; } -//could be moved to a viking file -//by marshmellow -//see ASKDemod for what args are accepted -int CmdVikingDemod(const char *Cmd) -{ - if (!ASKDemod(Cmd, false, false, 1)) { - if (g_debugMode) PrintAndLog("ASKDemod failed"); - return 0; - } - size_t size = DemodBufferLen; - //call lfdemod.c demod for Viking - int ans = VikingDemod_AM(DemodBuffer, &size); - if (ans < 0) { - if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans); - return 0; - } - //got a good demod - uint32_t raw1 = bytebits_to_byte(DemodBuffer+ans, 32); - uint32_t raw2 = bytebits_to_byte(DemodBuffer+ans+32, 32); - uint32_t cardid = bytebits_to_byte(DemodBuffer+ans+24, 32); - uint8_t checksum = bytebits_to_byte(DemodBuffer+ans+32+24, 8); - PrintAndLog("Viking Tag Found: Card ID %08X, Checksum: %02X", cardid, (unsigned int) checksum); - PrintAndLog("Raw: %08X%08X", raw1,raw2); - setDemodBuf(DemodBuffer+ans, 64, 0); - return 1; -} - //by marshmellow - see ASKDemod int Cmdaskrawdemod(const char *Cmd) { @@ -1857,7 +1830,6 @@ static command_t CommandTable[] = {"help", CmdHelp, 1, "This help"}, {"askedgedetect", CmdAskEdgeDetect, 1, "[threshold] Adjust Graph for manual ask demod using the length of sample differences to detect the edge of a wave (use 20-45, def:25)"}, {"askgproxiidemod", CmdG_Prox_II_Demod, 1, "Demodulate a G Prox II tag from GraphBuffer"}, - {"askvikingdemod", CmdVikingDemod, 1, "Demodulate a Viking tag from GraphBuffer"}, {"autocorr", CmdAutoCorr, 1, "[window length] [g] -- Autocorrelation over window - g to save back to GraphBuffer (overwrite)"}, {"biphaserawdecode",CmdBiphaseDecodeRaw,1, "[offset] [invert<0|1>] [maxErr] -- Biphase decode bin stream in DemodBuffer (offset = 0|1 bits to shift the decode start)"}, {"bin2hex", Cmdbin2hex, 1, "bin2hex -- Converts binary to hexadecimal"}, diff --git a/client/cmddata.h b/client/cmddata.h index 789ebb1b..552a37a1 100644 --- a/client/cmddata.h +++ b/client/cmddata.h @@ -23,7 +23,6 @@ int CmdData(const char *Cmd); void printDemodBuff(void); void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx); int CmdPrintDemodBuff(const char *Cmd); -int CmdVikingDemod(const char *Cmd); int CmdG_Prox_II_Demod(const char *Cmd); int Cmdaskrawdemod(const char *Cmd); int Cmdaskmandemod(const char *Cmd); diff --git a/client/cmdlfviking.c b/client/cmdlfviking.c index fa073df1..edbc3500 100644 --- a/client/cmdlfviking.c +++ b/client/cmdlfviking.c @@ -17,7 +17,6 @@ #include "cmddata.h" #include "cmdmain.h" #include "cmdlf.h" -#include "cmdlfviking.h" #include "lfdemod.h" static int CmdHelp(const char *Cmd); @@ -50,13 +49,40 @@ uint64_t getVikingBits(uint32_t id) { uint8_t checksum = ((id>>24) & 0xFF) ^ ((id>>16) & 0xFF) ^ ((id>>8) & 0xFF) ^ (id & 0xFF) ^ 0xF2 ^ 0xA8; return ((uint64_t)0xF2 << 56) | ((uint64_t)id << 8) | checksum; } + +//could be moved to a viking file +//by marshmellow +//see ASKDemod for what args are accepted +int CmdVikingDemod(const char *Cmd) { + if (!ASKDemod(Cmd, false, false, 1)) { + if (g_debugMode) PrintAndLog("ASKDemod failed"); + return 0; + } + size_t size = DemodBufferLen; + //call lfdemod.c demod for Viking + int ans = VikingDemod_AM(DemodBuffer, &size); + if (ans < 0) { + if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans); + return 0; + } + //got a good demod + uint32_t raw1 = bytebits_to_byte(DemodBuffer+ans, 32); + uint32_t raw2 = bytebits_to_byte(DemodBuffer+ans+32, 32); + uint32_t cardid = bytebits_to_byte(DemodBuffer+ans+24, 32); + uint8_t checksum = bytebits_to_byte(DemodBuffer+ans+32+24, 8); + PrintAndLog("Viking Tag Found: Card ID %08X, Checksum: %02X", cardid, (unsigned int) checksum); + PrintAndLog("Raw: %08X%08X", raw1,raw2); + setDemodBuf(DemodBuffer+ans, 64, 0); + return 1; +} + //by marshmellow //see ASKDemod for what args are accepted int CmdVikingRead(const char *Cmd) { // read lf silently CmdLFRead("s"); // get samples silently - getSamples("30000",false); + getSamples("10000",false); // demod and output viking ID return CmdVikingDemod(Cmd); } @@ -110,7 +136,8 @@ int CmdVikingSim(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"}, - {"read", CmdVikingRead, 0, "Attempt to read and Extract tag data"}, + {"demod", CmdVikingDemod, 1, "Demodulate a Viking tag from the GraphBuffer"}, + {"read", CmdVikingRead, 0, "Attempt to read and Extract tag data from the antenna"}, {"clone", CmdVikingClone, 0, "<8 digit ID number> clone viking tag"}, {"sim", CmdVikingSim, 0, "<8 digit ID number> simulate viking tag"}, {NULL, NULL, 0, NULL} diff --git a/client/cmdlfviking.h b/client/cmdlfviking.h index 2e8ac479..cdaad26f 100644 --- a/client/cmdlfviking.h +++ b/client/cmdlfviking.h @@ -8,9 +8,10 @@ //----------------------------------------------------------------------------- #ifndef CMDLFVIKING_H__ #define CMDLFVIKING_H__ -int CmdLFViking(const char *Cmd); -int CmdVikingRead(const char *Cmd); -int CmdVikingClone(const char *Cmd); -int CmdVikingSim(const char *Cmd); +extern int CmdLFViking(const char *Cmd); +extern int CmdVikingDemod(const char *Cmd); +extern int CmdVikingRead(const char *Cmd); +extern int CmdVikingClone(const char *Cmd); +extern int CmdVikingSim(const char *Cmd); #endif