]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfviking.c
12 #include "cmdlfviking.h"
14 static int CmdHelp(const char *Cmd
);
16 int usage_lf_viking_clone(void){
17 PrintAndLog("clone a Viking AM tag to a T55x7 tag.");
18 PrintAndLog("Usage: lf viking clone <Card ID 16 bytes of hex number>");
23 //see ASKDemod for what args are accepted
24 int CmdVikingDemod(const char *Cmd
)
27 getSamples("30000",false);
29 if (!ASKDemod(Cmd
, false, false, 1)) {
30 if (g_debugMode
) PrintAndLog("ASKDemod failed");
33 size_t size
= DemodBufferLen
;
35 int ans
= VikingDemod_AM(DemodBuffer
, &size
);
37 if (g_debugMode
) PrintAndLog("Error Viking_Demod");
41 uint32_t raw1
= bytebits_to_byte(DemodBuffer
+ans
, 32);
42 uint32_t raw2
= bytebits_to_byte(DemodBuffer
+ans
+32, 32);
43 uint32_t cardid
= bytebits_to_byte(DemodBuffer
+ans
+24, 32);
44 uint8_t checksum
= bytebits_to_byte(DemodBuffer
+ans
+32+24, 8);
45 PrintAndLog("Viking Tag Found: Card ID %08X, Checksum: %02X", cardid
, checksum
);
46 PrintAndLog("Raw: %08X%08X", raw1
,raw2
);
47 setDemodBuf(DemodBuffer
+ans
, 64, 0);
51 int CmdVikingClone(const char *Cmd
)
54 // get the tag number 64 bits (8 bytes) in hex
57 char cmdp
= param_getchar(Cmd
, 0);
58 if (strlen(Cmd
) < 0 || cmdp
== 'h' || cmdp
== 'H') return usage_lf_viking_clone();
60 if (param_gethex(Cmd
, 0, id
, 16) == 1)
61 return usage_lf_viking_clone();
63 b1
= bytes_to_num(id
, sizeof(uint32_t));
64 b2
= bytes_to_num(id
+ sizeof(uint32_t), sizeof(uint32_t));
65 UsbCommand c
= {CMD_VIKING_CLONE_TAG
,{b1
,b2
}};
72 static command_t CommandTable
[] =
74 {"help", CmdHelp
, 1, "This help"},
75 {"demod", CmdVikingDemod
, 1, "Extract tag data"},
76 {"clone", CmdVikingClone
, 1, "<16 digits card data> clone viking tag"},
80 int CmdLFViking(const char *Cmd
)
82 CmdsParse(CommandTable
, Cmd
);
86 int CmdHelp(const char *Cmd
)
88 CmdsHelp(CommandTable
);