]> git.zerfleddert.de Git - proxmark3-svn/blame - client/lualibs/htmlskel.lua
textual change @4m4rOk
[proxmark3-svn] / client / lualibs / htmlskel.lua
CommitLineData
61caacda 1local skel_1 = [[
2<html>
3<head>
62a95012 4
5 <script>
6 var dictionary = {}
7 function add(commaSeparated)
8 {
9 var fields = commaSeparated.split(",");
10 var manufacturerCode = fields[0];
11 var modelCode = fields[1];
12 var modelSubCode= fields[2];
13 var modelName = fields[3];
14 var ATQA = fields[4];
15 var SAK = fields[5];
16
17 //In the data below, wrong endian is used. Mifare is
18 // written as "0004" instead of "0400", so we need to
19 // flip it
20 ATQA = ATQA.substr(2,4)+ATQA.substr(0,2)
21
22 var info = {
23 modelCode : modelCode,
24 modelSubCode : modelSubCode,
25 modelName : modelName,
26 ATQA : ATQA,
27 SAK : SAK
28 }
29 console.log("Adding "+modelName+" , "+SAK)
30
31 dictionary[ATQA] = dictionary[ATQA] || [];
32 dictionary[ATQA].push(info)
33 }
34 function lookup(atqa, sak)
35 {
36 if (!dictionary[atqa]) return "UNKNOWN";
37
38 var possibleMatches = [];
39 for(var i = 0 ; i < dictionary[atqa].length ; i++)
40 {
41
42 var info = dictionary[atqa][i];
43 console.log("Comparing "+sak+ " with "+ info.SAK);
44 if(sak && info.SAK == sak)//exact match
45 {
46 return info.modelName;
47// possibleMatches.push(info.modelName);
48 }else //SAK unknown
49 {
50 possibleMatches.push(info.modelName);
51 }
52 }
53 if(possibleMatches.length > 0)
54 return possibleMatches.join(" or ");
55 return "UNKNOWN"
56 }
57
c15d2bdc 58 add("04,,,Mifare TNP3xxx Activision 1K,0f01,01");
62a95012 59 add("04,,,Mifare Mini,0004,09");
60 add("04,,,Mifare Classic 1k/Mifare Plus(4 byte UID) 2K SL1,0004,08");
61 add("04,,,Mifare Plus (4 byte UID) 2K SL2,0004,10");
62 add("04,,,Mifare Plus (4 byte UID) 4K SL2,0004,11");
63 add("04,,,Mifare Plus (4 byte UID) 4K SL1,0004,18");
64 add("04,,,Mifare Plus (4 byte UID) 2K/4K SL3,0004,20");
65 add("04,,,Mifare Classic 4K,0002,18");
66 add("xx,,,NDEF Tags,0044,00 ");
67 add("04,,,Mifare Ultralight/UltralightC,0044,04");
68 add("04,,,Mifare Plus (7 byte UID) 2K SL1,0042,08");
69 add("04,,,Mifare Plus (7 byte UID) 2K SL1,0044,08");
70 add("04,,,Mifare Plus (7 byte UID) 4K SL1,0042,18");
71 add("04,,,Mifare Plus (7 byte UID) 4K SL1,0044,18");
72 add("04,,,Mifare Plus (7 byte UID),0042,10");
73 add("04,,,Mifare Plus (7 byte UID),0044,10");
74 add("04,,,Mifare Plus (7 byte UID),0042,11");
75 add("04,,,Mifare Plus (7 byte UID),0044,11");
76 add("04,,,Mifare Plus (7 byte UID),0042,20");
77 add("04,,,Mifare Plus (7 byte UID),0044,20");
78 add("04,,,Mifare DesFire / DesFire EV1,0344,20067577810280");
79 add("04,,,JCOP31,0304,283877B14A434F503331");
80 add("04,,,JCOP31 v2.4.1,0048,207877B1024A434F5076323431");
81 add("04,,,JCOP41 v2.2,0048,203833B14A434F503431563232");
82 add("04,,,JCOP41 v2.3.1,0004,283833B14A434F50343156323331");
83 add("05,,,Mifare Classic 1K,0004,88");
84 add("40,,,MPCOS,0002,98");
85 add("25,,,Topaz/Topaz512/Jewel,0C00,");
86 add("1D,,,FM1208SH01,0004,53");
87 add("1D,,,FM1208,0008,20");
88 add("Nokia,,,Mifare Classic 4K emulated by Nokia 6212,0002,38");
89 add("Nokia,,,Mifare Classic 4K emulated by Nokia 6131,0008,38");
90 add("04,,,Smart MX with Mifare 4K emulation,0002");
91 add("04,,,Smart MX with Mifare 4K emulation,0102");
92 add("04,,,Smart MX with Mifare 4K emulation,0202");
93 add("04,,,Smart MX with Mifare 4K emulation,0302");
94 add("04,,,Smart MX with Mifare 4K emulation,0402");
95 add("04,,,Smart MX with Mifare 4K emulation,0502");
96 add("04,,,Smart MX with Mifare 4K emulation,0602");
97 add("04,,,Smart MX with Mifare 4K emulation,0702");
98 add("04,,,Smart MX with Mifare 4K emulation,0802");
99 add("04,,,Smart MX with Mifare 4K emulation,0902");
100 add("04,,,Smart MX with Mifare 4K emulation,0A02");
101 add("04,,,Smart MX with Mifare 4K emulation,0B02");
102 add("04,,,Smart MX with Mifare 4K emulation,0C02");
103 add("04,,,Smart MX with Mifare 4K emulation,0D02");
104 add("04,,,Smart MX with Mifare 4K emulation,0E02");
105 add("04,,,Smart MX with Mifare 4K emulation,0F02");
106 add("04,,,Smart MX with Mifare 1K emulation,0004");
107 add("04,,,Smart MX with Mifare 1K emulation,0104");
108 add("04,,,Smart MX with Mifare 1K emulation,0204");
109 add("04,,,Smart MX with Mifare 1K emulation,0304");
110 add("04,,,Smart MX with Mifare 1K emulation,0404");
111 add("04,,,Smart MX with Mifare 1K emulation,0504");
112 add("04,,,Smart MX with Mifare 1K emulation,0604");
113 add("04,,,Smart MX with Mifare 1K emulation,0704");
114 add("04,,,Smart MX with Mifare 1K emulation,0804");
115 add("04,,,Smart MX with Mifare 1K emulation,0904");
116 add("04,,,Smart MX with Mifare 1K emulation,0A04");
117 add("04,,,Smart MX with Mifare 1K emulation,0B04");
118 add("04,,,Smart MX with Mifare 1K emulation,0C04");
119 add("04,,,Smart MX with Mifare 1K emulation,0D04");
120 add("04,,,Smart MX with Mifare 1K emulation,0E04");
121 add("04,,,Smart MX with Mifare 1K emulation,0F04");
122 add("04,,,Smart MX with 7 byte UID,0048");
123 add("04,,,Smart MX with 7 byte UID,0148");
124 add("04,,,Smart MX with 7 byte UID,0248");
125 add("04,,,Smart MX with 7 byte UID,0348");
126 add("04,,,Smart MX with 7 byte UID,0448");
127 add("04,,,Smart MX with 7 byte UID,0548");
128 add("04,,,Smart MX with 7 byte UID,0648");
129 add("04,,,Smart MX with 7 byte UID,0748");
130 add("04,,,Smart MX with 7 byte UID,0848");
131 add("04,,,Smart MX with 7 byte UID,0948");
132 add("04,,,Smart MX with 7 byte UID,0A48");
133 add("04,,,Smart MX with 7 byte UID,0B48");
134 add("04,,,Smart MX with 7 byte UID,0C48");
135 add("04,,,Smart MX with 7 byte UID,0D48");
136 add("04,,,Smart MX with 7 byte UID,0E48");
137 add("04,,,Smart MX with 7 byte UID,0F48");
ac42d5be 138 </script>
62a95012 139
61caacda 140 <style>
141 * {
142 background-color: #2F3440;
143 background-color:#232323;
144 color : #F5E5C0;
62a95012 145 xtext-transform: uppercase;
61caacda 146 font-size: 1.05em;
147 font-family: monospace,Arial;
148 }
149 table{
150 float:left;
151 border: 1px solid white;
152 }
62a95012 153 td {
154 empty-cells: show;
57d38400 155 }
62a95012 156 td.blockzero, .turqoise{
61caacda 157 color: rgb(140, 245, 193);
158 }
62a95012 159 td.key_a, .yellow{
61caacda 160 color : #F8CA4D;
161 }
62a95012 162 td.key_b, .blue{
61caacda 163 color : #3F5666;
164 }
62a95012 165 td.accessconditions, .red{
61caacda 166 color : #EA6045;
167 }
168
169 td.sectorhdr{
170 border-top: 1px solid white;
171 }
172 </style>
173 <script>
62a95012 174 /** Jquery for the poor **/
61caacda 175 function dc(x){return document.createElement(x)}
176
62a95012 177 function tr(table){
178 var row = dc('tr');
179 table.appendChild(row);
180 return row;
181 }
182 function td(row, text){
183 var tdata = dc('td');
184 row.appendChild(tdata);
185 tdata.appendChild(document.createTextNode(text))
186 return tdata;
187 }
188
189 /**
190 * The identifiers that determine how to highlight data and present information
191 **/
192 var identifiers = [
193 function(data)
61caacda 194 {
62a95012 195 // Should be 32 characters long ( 16 bytes per block)
196 if(data[0].length != 32) { return false; }
197 // ... add more checks if necessary ...
61caacda 198
62a95012 199 var info = {Type : "Mifare"}
200 info['Size'] = (data[0].length / 2 * data.length) + " Bytes";
201 info['UID'] = data[0].substring(0,8);
202 info['SAK'] = data[0].substring(10,12);
203 info['ATQA'] = data[0].substring(12,16);
61caacda 204
62a95012 205 info['Name'] = lookup(info.ATQA, info.SAK);
206 return {info: info, highlighter : mifareHighlighter }
207 },
208 function(data)
61caacda 209 {
62a95012 210 // Should be 8 characters long ( 4 bytes per block)
211 if(data[0].length != 8) { return false; }
212 // ... add more checks if necessary ...
213 var info = {Type : "NDEF"}
214 info['Size'] = (data[0].length / 2 * data.length) + " Bytes";
61caacda 215
62a95012 216 return {info: info, highlighter : ndefHighligheter }
217 },
ac42d5be 218
62a95012 219 function(data)
220 {//This is the catch-all
221 return {info: {type : "Unknown"}, highlighter : noHighlighter}
61caacda 222 }
62a95012 223 ]
224
61caacda 225
62a95012 226 /**
227 * Helper function to convert bin-data into printable chars
228 **/
61caacda 229
61caacda 230 function to_ascii(hexval)
231 {
232 var intval = parseInt(hexval,16);
233 if(intval > 31 && intval < 127)
234 {
235 return String.fromCharCode(intval);
236 }
237 return ".";
238 }
239
62a95012 240
241 function loadIntoTable(data, info, ascii)
61caacda 242 {
61caacda 243 var t = dc("table")
244 for(var i = 0 ; i < data.length ; i++)
245 {
246 line = data[i];
62a95012 247 var row = tr(t);
61caacda 248 var bytes = line.match(/(.{1,2})/g);
249 for(var b = 0 ; b < bytes.length ; b++)
250 {
62a95012 251 var elem = td(row, ascii ? to_ascii(bytes[b]) : bytes[b]);
252 info.highlighter.addClass(elem,i,b, bytes[b]);
61caacda 253 }
254 }
255 document.body.appendChild(t);
256 }
62a95012 257 function loadGeneralInfo(data, info)
258 {
259 var t = dc("table");
260 for (var key in info)
261 {
262 var row = tr(t);
263 td(row,key);
264 td(row,info[key]);
265 }
266 document.body.appendChild(t);
267 }
61caacda 268
62a95012 269 function handle(dump)
61caacda 270 {
62a95012 271 var data = dump.data;
272 var info = null;
273 for(var i = 0; i < identifiers.length && !info; i++)
274 info = identifiers[i](data);
275
276 console.log(info);
277
278 loadIntoTable(data, info, false);
279 loadIntoTable(data, info, true);
280 loadGeneralInfo(data, info.info);
281
61caacda 282 }
62a95012 283 var noHighlighter = {
284 addClass : function(el ,line, byte)
285 {
286 return;
287 }
288 };
289 var ndefHighligheter = {
290 addClass : function(el ,line, byte, value)
291 {
292 if(line < 3)
293 {
294 el.className += " red";
295 }
296 if ( line == 3)
297 {
298 console.log(value);
299 if( byte == 0 && "e1" == value.toLowerCase()) el.className += " turqoise";
300 if( byte == 1 ) el.className += " yellow";
301 if( byte == 2 ) el.className += " blue";
302 return;
303 }
304 }
305 };
306 var mifareHighlighter = {
307 addClass : function(el ,line, byte)
308 {
309 if (line == 0)
310 {
311 el.className += " blockzero";
312 }
313
314 if(line < 128){
315 linesPerSector = 4;
ac42d5be 316 } else {
62a95012 317 //Quadruple size sectors
318 linesPerSector = 16;
319 line = line - 128;
62a95012 320 }
321
322 if(line % linesPerSector == 0)
323 {
324 el.className += " sectorhdr";
325 }
326 if(line % linesPerSector == (linesPerSector -1))
327 {
328 el.className += " sectortrailer";
329 if(byte == undefined)
330 {
331 return;
332 }
333
334 if(byte < 6) el.className += " key_a";
335 else if(byte < 10) el.className += " accessconditions";
336 else el.className += " key_b";
337 }
338
339 }
340 };
341
61caacda 342 </script>
343
344</head>
b11542a7 345<body></body>
61caacda 346<script>
62a95012 347 var x = { data :
61caacda 348]]
349local skel_2 = [[
350
62a95012 351 };
352 handle(x);
61caacda 353 </script>
354</html>
62a95012 355
61caacda 356]]
357local function getHTML(data)
358 return skel_1 .. data .. skel_2
359end
360
361return {getHTML = getHTML}
Impressum, Datenschutz