]> git.zerfleddert.de Git - proxmark3-svn/blame - client/cmdlfparadox.c
Merge branch 'master' of github.com:merlokk/proxmark3 into 14a_rework3
[proxmark3-svn] / client / cmdlfparadox.c
CommitLineData
5bce72d5 1//-----------------------------------------------------------------------------
2//
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
5// the license.
6//-----------------------------------------------------------------------------
7// Low frequency Paradox tag commands
b9957414 8// FSK2a, rf/50, 96 bits (completely known)
5bce72d5 9//-----------------------------------------------------------------------------
10#include <stdio.h>
11#include <string.h>
12#include <inttypes.h>
13#include "cmdlfparadox.h"
14#include "proxmark3.h"
15#include "ui.h"
16#include "util.h"
17#include "graph.h"
18#include "cmdparser.h"
19#include "cmddata.h"
20#include "cmdlf.h"
21#include "lfdemod.h"
22static int CmdHelp(const char *Cmd);
23
24//by marshmellow
25//Paradox Prox demod - FSK RF/50 with preamble of 00001111 (then manchester encoded)
26//print full Paradox Prox ID and some bit format details if found
27int CmdFSKdemodParadox(const char *Cmd)
28{
29 //raw fsk demod no manchester decoding no start bit finding just get binary from wave
30 uint32_t hi2=0, hi=0, lo=0;
31
32 uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
33 size_t BitLen = getFromGraphBuf(BitStream);
34 if (BitLen==0) return 0;
1c70664a 35 int waveIdx=0;
5bce72d5 36 //get binary from fsk wave
1c70664a 37 int idx = ParadoxdemodFSK(BitStream,&BitLen,&hi2,&hi,&lo,&waveIdx);
5bce72d5 38 if (idx<0){
39 if (g_debugMode){
40 if (idx==-1){
41 PrintAndLog("DEBUG: Just Noise Detected");
42 } else if (idx == -2) {
43 PrintAndLog("DEBUG: Error demoding fsk");
44 } else if (idx == -3) {
45 PrintAndLog("DEBUG: Preamble not found");
46 } else if (idx == -4) {
47 PrintAndLog("DEBUG: Error in Manchester data");
48 } else {
49 PrintAndLog("DEBUG: Error demoding fsk %d", idx);
50 }
51 }
52 return 0;
53 }
54 if (hi2==0 && hi==0 && lo==0){
55 if (g_debugMode) PrintAndLog("DEBUG: Error - no value found");
56 return 0;
57 }
58 uint32_t fc = ((hi & 0x3)<<6) | (lo>>26);
59 uint32_t cardnum = (lo>>10)&0xFFFF;
60 uint32_t rawLo = bytebits_to_byte(BitStream+idx+64,32);
61 uint32_t rawHi = bytebits_to_byte(BitStream+idx+32,32);
62 uint32_t rawHi2 = bytebits_to_byte(BitStream+idx,32);
63
64 PrintAndLog("Paradox TAG ID: %x%08x - FC: %d - Card: %d - Checksum: %02x - RAW: %08x%08x%08x",
65 hi>>10, (hi & 0x3)<<26 | (lo>>10), fc, cardnum, (lo>>2) & 0xFF, rawHi2, rawHi, rawLo);
66 setDemodBuf(BitStream,BitLen,idx);
1c70664a 67 setClockGrid(50, waveIdx + (idx*50));
5bce72d5 68 if (g_debugMode){
69 PrintAndLog("DEBUG: idx: %d, len: %d, Printing Demod Buffer:", idx, BitLen);
70 printDemodBuff();
71 }
72 return 1;
73}
74//by marshmellow
75//see ASKDemod for what args are accepted
76int CmdParadoxRead(const char *Cmd) {
77 // read lf silently
b9957414 78 lf_read(true, 10000);
5bce72d5 79 // demod and output viking ID
80 return CmdFSKdemodParadox(Cmd);
81}
82
83static command_t CommandTable[] = {
84 {"help", CmdHelp, 1, "This help"},
85 {"demod", CmdFSKdemodParadox, 1, "Demodulate a Paradox FSK tag from the GraphBuffer"},
86 {"read", CmdParadoxRead, 0, "Attempt to read and Extract tag data from the antenna"},
87 {NULL, NULL, 0, NULL}
88};
89
90int CmdLFParadox(const char *Cmd) {
91 CmdsParse(CommandTable, Cmd);
92 return 0;
93}
94
95int CmdHelp(const char *Cmd) {
96 CmdsHelp(CommandTable);
97 return 0;
98}
Impressum, Datenschutz