]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfawid26.c
added the changes from PM3 master.
[proxmark3-svn] / client / cmdlfawid26.c
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 AWID26 commands
8 //-----------------------------------------------------------------------------
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <inttypes.h>
13 #include "proxmark3.h"
14 #include "ui.h"
15 //#include "graph.h"
16 #include "cmdmain.h"
17 #include "cmdparser.h"
18 //#include "cmddata.h"
19 #include "cmdlf.h"
20 #include "cmdlfawid26.h"
21 #include "util.h"
22 //#include "data.h"
23
24
25 static int CmdHelp(const char *Cmd);
26
27 int CmdClone(const char *Cmd)
28 {
29 char cmdp = param_getchar(Cmd, 0);
30
31 if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') {
32 PrintAndLog("Usage: lf awid26 clone <facility> <id>");
33 PrintAndLog(" [], ");
34 PrintAndLog("");
35 PrintAndLog(" sample: lf awid26 clone 15 2233");
36 return 0;
37 }
38
39 //sscanf(Cmd, "%d %d", &facilitycode, &cardno);
40
41 // char block0 = "00107060";
42 // char block1 = "00107060";
43 // char block2 = "00107060";
44 // char block3 = "00107060";
45
46
47
48 // PrintAndLog("Writing block %d with data %08X", Block, Data);
49 return 0;
50 }
51
52
53 // convert 96 bit AWID FSK data to 8 digit BCD UID
54 bool awid26_hex_to_uid(unsigned char *response, unsigned char *awid26)
55 {
56 // uint8_t i, tmp[96], tmp1[7];
57 // int site;
58 // int id;
59
60 // if(!hextobinarray(tmp, awid26))
61 // return false;
62
63 // // data is in blocks of 4 bits - every 4th bit is parity, except the first
64 // // block which is all zeros
65 // for(i= 0 ; i < 4 ; ++i)
66 // if(tmp[i] != 0x00)
67 // return false;
68
69 // // discard 1st block
70 // memcpy(tmp, tmp + 4, 92);
71
72 // // check and strip parity on the rest
73 // for(i= 1 ; i < 23 ; ++i)
74 // if(tmp[(i * 4) - 1] != parity(tmp + (i - 1) * 4, ODD, 3))
75 // return false;
76 // else
77 // memcpy((tmp + (i - 1) * 3), tmp + (i - 1) * 4, 3);
78
79 // // discard the rest of the header - 1 more 3 bit block
80 // memcpy(tmp, tmp + 3, 66);
81
82 // // next 8 bits is data length - should be 26: 0x1A
83 // binarraytohex(tmp1, tmp, 8);
84 // if(strcmp(tmp1, "1A") != 0)
85 // return false;
86 // memcpy(tmp, tmp +8, 58);
87
88 // // standard wiegand parity check - even for 1st 12 bits, odd for 2nd 12
89 // if(tmp[0] != parity(tmp + 1, EVEN, 12))
90 // return false;
91 // if(tmp[25] != parity(tmp + 13, ODD, 12))
92 // return false;
93
94 // // convert to hex, ignoring parity bits
95 // if(!binarraytohex(tmp1, tmp + 1, 24))
96 // return false;
97
98 // // convert hex to site/id
99 // sscanf(tmp1,"%2X%4X", &site, &id);
100
101 // // final output 8 byte BCD
102 // sprintf(response,"%03d%05d", site, id);
103
104 return true;
105 }
106
107 // convert null-terminated BCD UID (8 digits) to 96 bit awid26 encoded binary array
108 bool bcd_to_awid26_bin(unsigned char *awid26, unsigned char *bcd)
109 {
110 // char i, p, tmp1[8], tmp2[26];
111 // int tmpint;
112
113 // if(strlen(bcd) != 8)
114 // return false;
115
116 // // convert BCD site code to HEX
117 // sscanf(bcd, "%03d", &tmpint);
118 // sprintf(tmp2, "%02x", tmpint);
119 // memcpy(tmp1, tmp2, 2);
120
121 // // convert BCD ID to HEX
122 // sscanf(bcd + 3, "%05d", &tmpint);;
123 // sprintf(tmp2, "%04x", tmpint);
124
125 // // copy with trailing NULL
126 // memcpy(tmp1 + 2, tmp2, 5);
127
128 // // convert full HEX to binary, leaving room for parity prefix
129 // hextobinarray(tmp2 + 1, tmp1);
130
131 // wiegand_add_parity(tmp2, tmp2 + 1, 24);
132
133 // memset(awid26, '\x0', 96);
134
135 // // magic 18 bit awid26 header (we will overwrite the last two bits)
136 // hextobinarray(awid26, "011D8");
137
138 // // copy to target leaving space for parity bits
139 // for(i= 0, p= 18 ; i < 26 ; ++i, ++p)
140 // {
141 // // skip target bit if this is a parity location
142 // if(!((p + 1) % 4))
143 // p += 1;
144 // awid26[p]= tmp2[i];
145 // }
146
147 // // add parity bits
148 // for(i= 1 ; i < 24 ; ++i)
149 // awid26[((i + 1) * 4) - 1]= parity(&awid26[i * 4], ODD, 3);
150
151 return false;
152 }
153
154 // int CmdReadTrace(const char *Cmd)
155 // {
156
157 // uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};
158 // uint8_t * bitstream = bits;
159
160 // uint8_t si = 5;
161 // uint32_t bl0 = PackBits(si, 32, bitstream);
162 // uint32_t bl1 = PackBits(si+32, 32, bitstream);
163
164 // uint32_t acl = PackBits(si, 8, bitstream); si += 8;
165 // uint32_t mfc = PackBits(si, 8, bitstream); si += 8;
166 // uint32_t cid = PackBits(si, 5, bitstream); si += 5;
167 // uint32_t icr = PackBits(si, 3, bitstream); si += 3;
168 // uint32_t year = PackBits(si, 4, bitstream); si += 4;
169 // uint32_t quarter = PackBits(si, 2, bitstream); si += 2;
170 // uint32_t lotid = PackBits(si, 12, bitstream); si += 12;
171 // uint32_t wafer = PackBits(si, 5, bitstream); si += 5;
172 // uint32_t dw = PackBits(si, 15, bitstream);
173
174 // PrintAndLog("");
175 // PrintAndLog("-- T55xx Trace Information ----------------------------------");
176 // PrintAndLog("-------------------------------------------------------------");
177 // PrintAndLog(" ACL Allocation class (ISO/IEC 15963-1) : 0x%02X (%d)", acl, acl);
178 // PrintAndLog(" MFC Manufacturer ID (ISO/IEC 7816-6) : 0x%02X (%d)", mfc, mfc);
179 // PrintAndLog(" CID : 0x%02X (%d)", cid, cid);
180 // PrintAndLog(" ICR IC Revision : %d",icr );
181
182
183 // return 0;
184 // }
185
186 static command_t CommandTable[] =
187 {
188 {"help", CmdHelp, 1, "This help"},
189 {"clone", CmdClone, 1, "<facility> <id> -- clone AWID26 to t55xx tag"},
190 {NULL, NULL, 0, NULL}
191 };
192
193 int CmdLFAWID26(const char *Cmd)
194 {
195 CmdsParse(CommandTable, Cmd);
196 return 0;
197 }
198
199 int CmdHelp(const char *Cmd)
200 {
201 CmdsHelp(CommandTable);
202 return 0;
203 }
Impressum, Datenschutz