]> git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdhf.c
Merge pull request #909 from pwpiwi/fix_button_break
[proxmark3-svn] / client / cmdhf.c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
3 // Merlok - 2017
4 //
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
7 // the license.
8 //-----------------------------------------------------------------------------
9 // High frequency commands
10 //-----------------------------------------------------------------------------
11
12 #include "cmdhf.h"
13
14 #include <math.h>
15 #include "usb_cmd.h"
16 #include "comms.h"
17 #include "ui.h"
18 #include "cmdparser.h"
19 #include "cliparser/cliparser.h"
20 #include "cmdhf14a.h"
21 #include "cmdhf14b.h"
22 #include "cmdhf15.h"
23 #include "cmdhfepa.h"
24 #include "cmdhflegic.h"
25 #include "cmdhficlass.h"
26 #include "cmdhfmf.h"
27 #include "cmdhfmfp.h"
28 #include "cmdhfmfu.h"
29 #include "cmdhftopaz.h"
30 #include "cmdhflist.h"
31 #include "cmdhffido.h"
32 #include "cmddata.h"
33 #include "graph.h"
34 #include "fpga.h"
35
36 static int CmdHelp(const char *Cmd);
37
38 int CmdHFTune(const char *Cmd)
39 {
40 UsbCommand c={CMD_MEASURE_ANTENNA_TUNING_HF};
41 SendCommand(&c);
42 return 0;
43 }
44
45 int CmdHFSearch(const char *Cmd){
46 int ans = 0;
47 PrintAndLog("");
48 ans = CmdHF14AInfo("s");
49 if (ans > 0) {
50 PrintAndLog("\nValid ISO14443A Tag Found - Quiting Search\n");
51 return ans;
52 }
53 ans = HFiClassReader(false, false);
54 if (ans) {
55 PrintAndLog("\nValid iClass Tag (or PicoPass Tag) Found - Quiting Search\n");
56 return ans;
57 }
58 ans = HF15Reader("", false);
59 if (ans) {
60 PrintAndLog("\nValid ISO15693 Tag Found - Quiting Search\n");
61 return ans;
62 }
63 //14b is longest test currently (and rarest chip type) ... put last
64 ans = infoHF14B(false);
65 if (ans) {
66 PrintAndLog("\nValid ISO14443B Tag Found - Quiting Search\n");
67 return ans;
68 }
69 ans = CmdLegicRFRead("");
70 if (ans == 0) {
71 PrintAndLog("\nValid Legic Tag Found - Quiting Search\n");
72 return ans;
73 }
74 PrintAndLog("\nno known/supported 13.56 MHz tags found\n");
75 return 0;
76 }
77
78 int CmdHFSnoop(const char *Cmd)
79 {
80 char * pEnd;
81 UsbCommand c = {CMD_HF_SNIFFER, {strtol(Cmd, &pEnd,0),strtol(pEnd, &pEnd,0),0}};
82 SendCommand(&c);
83 return 0;
84 }
85
86
87 // static void InterpolateShannon(int *source, size_t source_len, int *dest, size_t dest_len)
88 // {
89 // int *buf = (int*)malloc(source_len * sizeof(int));
90 // memcpy(buf, source, source_len * sizeof(int));
91 // for (int i = 0; i < source_len; i++) {
92 // buf[i] += 128;
93 // }
94 // for (int i = 0; i < dest_len; i++) {
95 // float value = 0.0;
96 // for (int j = 0; j < source_len; j++) {
97 // if (i * source_len == j * dest_len) { // sin(0) / 0 = 1
98 // value += (float)buf[j];
99 // } else {
100 // value += (float)buf[j] * sin(((float)i*source_len/dest_len-j)*3.1415) / (((float)i*source_len/dest_len-j)*3.1415);
101 // }
102 // }
103 // dest[i] = value - 128;
104 // }
105 // free(buf);
106 // }
107
108
109 static int CmdHFPlot(const char *Cmd)
110 {
111 CLIParserInit("hf plot",
112 "Plots HF signal after RF signal path and A/D conversion.",
113 "This can be used after any hf command and will show the last few milliseconds of the HF signal.\n"
114 "Note: If the last hf command terminated because of a timeout you will most probably see nothing.\n");
115 void* argtable[] = {
116 arg_param_begin,
117 arg_param_end
118 };
119 CLIExecWithReturn(Cmd, argtable, true);
120
121 uint8_t buf[FPGA_TRACE_SIZE];
122
123 if (GetFromFpgaRAM(buf, FPGA_TRACE_SIZE)) {
124 for (size_t i = 0; i < FPGA_TRACE_SIZE; i++) {
125 GraphBuffer[i] = (int)buf[i] - 128;
126 }
127 GraphTraceLen = FPGA_TRACE_SIZE;
128 // InterpolateShannon(GraphBuffer, FPGA_TRACE_SIZE, GraphBuffer, FPGA_TRACE_SIZE*8/7);
129 // GraphTraceLen = FPGA_TRACE_SIZE*8/7;
130 ShowGraphWindow();
131 RepaintGraphWindow();
132 }
133 return 0;
134 }
135
136
137 static command_t CommandTable[] =
138 {
139 {"help", CmdHelp, 1, "This help"},
140 {"14a", CmdHF14A, 0, "{ ISO14443A RFIDs... }"},
141 {"14b", CmdHF14B, 0, "{ ISO14443B RFIDs... }"},
142 {"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"},
143 {"epa", CmdHFEPA, 0, "{ German Identification Card... }"},
144 {"legic", CmdHFLegic, 0, "{ LEGIC RFIDs... }"},
145 {"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"},
146 {"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
147 {"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
148 {"mfp", CmdHFMFP, 0, "{ MIFARE Plus RFIDs... }"},
149 {"topaz", CmdHFTopaz, 0, "{ TOPAZ (NFC Type 1) RFIDs... }"},
150 {"fido", CmdHFFido, 0, "{ FIDO and FIDO2 authenticators... }"},
151 {"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"},
152 {"list", CmdHFList, 1, "List protocol data in trace buffer"},
153 {"plot", CmdHFPlot, 0, "Plot signal"},
154 {"search", CmdHFSearch, 0, "Search for known HF tags [preliminary]"},
155 {"snoop", CmdHFSnoop, 0, "<samples to skip (10000)> <triggers to skip (1)> Generic HF Snoop"},
156 {NULL, NULL, 0, NULL}
157 };
158
159 int CmdHF(const char *Cmd)
160 {
161 CmdsParse(CommandTable, Cmd);
162 return 0;
163 }
164
165 int CmdHelp(const char *Cmd)
166 {
167 CmdsHelp(CommandTable);
168 return 0;
169 }
Impressum, Datenschutz