mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
monster merge...
all those changes marshmellow did.. and more...
This commit is contained in:
parent
208550823d
commit
f28da2da6e
107 changed files with 5087 additions and 3777 deletions
|
@ -7,22 +7,11 @@
|
|||
// Low frequency Viking tag commands (AKA FDI Matalec Transit)
|
||||
// ASK/Manchester, RF/32, 64 bits (complete)
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "graph.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdmain.h"
|
||||
#include "cmdlf.h"
|
||||
#include "cmdlfviking.h"
|
||||
#include "lfdemod.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int usage_lf_viking_clone(void){
|
||||
int usage_lf_viking_clone(void) {
|
||||
PrintAndLog("clone a Viking AM tag to a T55x7 tag.");
|
||||
PrintAndLog("Usage: lf viking clone <Card ID - 8 hex digits> <Q5>");
|
||||
PrintAndLog("Options :");
|
||||
|
@ -54,15 +43,60 @@ uint64_t getVikingBits(uint32_t id) {
|
|||
ret |= checksum;
|
||||
return ret;
|
||||
}
|
||||
// by marshmellow
|
||||
// find viking preamble 0xF200 in already demoded data
|
||||
int detectViking(uint8_t *dest, size_t *size) {
|
||||
//make sure buffer has data
|
||||
if (*size < 64*2) return -2;
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -4; //preamble not found
|
||||
|
||||
uint32_t checkCalc = bytebits_to_byte(dest+startIdx,8) ^
|
||||
bytebits_to_byte(dest+startIdx+8,8) ^
|
||||
bytebits_to_byte(dest+startIdx+16,8) ^
|
||||
bytebits_to_byte(dest+startIdx+24,8) ^
|
||||
bytebits_to_byte(dest+startIdx+32,8) ^
|
||||
bytebits_to_byte(dest+startIdx+40,8) ^
|
||||
bytebits_to_byte(dest+startIdx+48,8) ^
|
||||
bytebits_to_byte(dest+startIdx+56,8);
|
||||
if ( checkCalc != 0xA8 ) return -5;
|
||||
if (*size != 64) return -6;
|
||||
//return start position
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
//by marshmellow
|
||||
//see ASKDemod for what args are accepted
|
||||
int CmdVikingDemod(const char *Cmd) {
|
||||
if (!ASKDemod(Cmd, false, false, 1)) {
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - Viking ASKDemod failed");
|
||||
return 0;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
|
||||
int ans = detectViking(DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (g_debugMode) PrintAndLog("DEBUG: Error - Viking Demod %d %s", ans, (ans == -5)?"[chksum error]":"");
|
||||
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, checksum);
|
||||
PrintAndLog("Raw: %08X%08X", raw1,raw2);
|
||||
setDemodBuf(DemodBuffer, 64, ans);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
|
||||
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("12000", true);
|
||||
// demod and output viking ID
|
||||
lf_read(true, 10000);
|
||||
return CmdVikingDemod(Cmd);
|
||||
}
|
||||
|
||||
|
@ -120,7 +154,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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue