]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfnexwatch.c
caabe83559d47fdaf118815ab76ddea666287516
1 //-----------------------------------------------------------------------------
3 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
4 // at your option, any later version. See the LICENSE.txt file for the text of
6 //-----------------------------------------------------------------------------
7 // Low frequency Honeywell NexWatch tag commands
8 // PSK1 RF/16, RF/2, 128 bits long (known)
9 //-----------------------------------------------------------------------------
14 #include "cmdlfnexwatch.h"
15 #include "proxmark3.h"
19 #include "cmdparser.h"
24 static int CmdHelp(const char *Cmd
);
26 int CmdPSKNexWatch(const char *Cmd
)
28 if (!PSKDemod("", false)) return 0;
29 uint8_t preamble
[28] = {0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
30 size_t startIdx
= 0, size
= DemodBufferLen
;
32 if (!preambleSearch(DemodBuffer
, preamble
, sizeof(preamble
), &size
, &startIdx
)){
33 // if didn't find preamble try again inverting
34 if (!PSKDemod("1", false)) return 0;
35 size
= DemodBufferLen
;
36 if (!preambleSearch(DemodBuffer
, preamble
, sizeof(preamble
), &size
, &startIdx
)) return 0;
39 if (size
!= 128) return 0;
40 setDemodBuf(DemodBuffer
, size
, startIdx
+4);
41 setClockGrid(g_DemodClock
, g_DemodStartIdx
+ ((startIdx
+4)*g_DemodClock
));
42 startIdx
= 8+32; // 8 = preamble, 32 = reserved bits (always 0)
45 for (uint8_t wordIdx
=0; wordIdx
<4; wordIdx
++){
46 for (uint8_t idx
=0; idx
<8; idx
++){
47 ID
= (ID
<< 1) | DemodBuffer
[startIdx
+wordIdx
+(idx
*4)];
52 //checksum check (TBD)
55 PrintAndLog("NexWatch ID: %d", ID
);
57 PrintAndLog("Had to Invert - probably NexKey");
58 for (uint8_t idx
=0; idx
<size
; idx
++)
59 DemodBuffer
[idx
] ^= 1;
62 CmdPrintDemodBuff("x");
67 //see ASKDemod for what args are accepted
68 int CmdNexWatchRead(const char *Cmd
) {
71 // demod and output viking ID
72 return CmdPSKNexWatch(Cmd
);
75 static command_t CommandTable
[] = {
76 {"help", CmdHelp
, 1, "This help"},
77 {"demod", CmdPSKNexWatch
, 1, "Demodulate a NexWatch tag (nexkey, quadrakey) from the GraphBuffer"},
78 {"read", CmdNexWatchRead
, 0, "Attempt to Read and Extract tag data from the antenna"},
82 int CmdLFNexWatch(const char *Cmd
) {
83 CmdsParse(CommandTable
, Cmd
);
87 int CmdHelp(const char *Cmd
) {
88 CmdsHelp(CommandTable
);