7 function add(commaSeparated)
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];
17 //In the data below, wrong endian is used. Mifare is
18 // written as "0004" instead of "0400", so we need to
20 ATQA = ATQA.substr(2,4)+ATQA.substr(0,2)
23 modelCode : modelCode,
24 modelSubCode : modelSubCode,
25 modelName : modelName,
29 console.log("Adding "+modelName+" , "+SAK)
31 dictionary[ATQA] = dictionary[ATQA] || [];
32 dictionary[ATQA].push(info)
34 function lookup(atqa, sak)
36 if (!dictionary[atqa]) return "UNKNOWN";
38 var possibleMatches = [];
39 for(var i = 0 ; i < dictionary[atqa].length ; i++)
42 var info = dictionary[atqa][i];
43 console.log("Comparing "+sak+ " with "+ info.SAK);
44 if(sak && info.SAK == sak)//exact match
46 return info.modelName;
47 // possibleMatches.push(info.modelName);
50 possibleMatches.push(info.modelName);
53 if(possibleMatches.length > 0)
54 return possibleMatches.join(" or ");
58 add("04,,,Mifare Mini,0004,09");
59 add("04,,,Mifare Classic 1k/Mifare Plus(4 byte UID) 2K SL1,0004,08");
60 add("04,,,Mifare Plus (4 byte UID) 2K SL2,0004,10");
61 add("04,,,Mifare Plus (4 byte UID) 4K SL2,0004,11");
62 add("04,,,Mifare Plus (4 byte UID) 4K SL1,0004,18");
63 add("04,,,Mifare Plus (4 byte UID) 2K/4K SL3,0004,20");
64 add("04,,,Mifare Classic 4K,0002,18");
65 add("xx,,,NDEF Tags,0044,00 ");
66 add("04,,,Mifare Ultralight/UltralightC,0044,04");
67 add("04,,,Mifare Plus (7 byte UID) 2K SL1,0042,08");
68 add("04,,,Mifare Plus (7 byte UID) 2K SL1,0044,08");
69 add("04,,,Mifare Plus (7 byte UID) 4K SL1,0042,18");
70 add("04,,,Mifare Plus (7 byte UID) 4K SL1,0044,18");
71 add("04,,,Mifare Plus (7 byte UID),0042,10");
72 add("04,,,Mifare Plus (7 byte UID),0044,10");
73 add("04,,,Mifare Plus (7 byte UID),0042,11");
74 add("04,,,Mifare Plus (7 byte UID),0044,11");
75 add("04,,,Mifare Plus (7 byte UID),0042,20");
76 add("04,,,Mifare Plus (7 byte UID),0044,20");
77 add("04,,,Mifare DesFire / DesFire EV1,0344,20067577810280");
78 add("04,,,JCOP31,0304,283877B14A434F503331");
79 add("04,,,JCOP31 v2.4.1,0048,207877B1024A434F5076323431");
80 add("04,,,JCOP41 v2.2,0048,203833B14A434F503431563232");
81 add("04,,,JCOP41 v2.3.1,0004,283833B14A434F50343156323331");
82 add("05,,,Mifare Classic 1K,0004,88");
83 add("40,,,MPCOS,0002,98");
84 add("25,,,Topaz/Topaz512/Jewel,0C00,");
85 add("1D,,,FM1208SH01,0004,53");
86 add("1D,,,FM1208,0008,20");
87 add("Nokia,,,Mifare Classic 4K emulated by Nokia 6212,0002,38");
88 add("Nokia,,,Mifare Classic 4K emulated by Nokia 6131,0008,38");
89 add("04,,,Smart MX with Mifare 4K emulation,0002");
90 add("04,,,Smart MX with Mifare 4K emulation,0102");
91 add("04,,,Smart MX with Mifare 4K emulation,0202");
92 add("04,,,Smart MX with Mifare 4K emulation,0302");
93 add("04,,,Smart MX with Mifare 4K emulation,0402");
94 add("04,,,Smart MX with Mifare 4K emulation,0502");
95 add("04,,,Smart MX with Mifare 4K emulation,0602");
96 add("04,,,Smart MX with Mifare 4K emulation,0702");
97 add("04,,,Smart MX with Mifare 4K emulation,0802");
98 add("04,,,Smart MX with Mifare 4K emulation,0902");
99 add("04,,,Smart MX with Mifare 4K emulation,0A02");
100 add("04,,,Smart MX with Mifare 4K emulation,0B02");
101 add("04,,,Smart MX with Mifare 4K emulation,0C02");
102 add("04,,,Smart MX with Mifare 4K emulation,0D02");
103 add("04,,,Smart MX with Mifare 4K emulation,0E02");
104 add("04,,,Smart MX with Mifare 4K emulation,0F02");
105 add("04,,,Smart MX with Mifare 1K emulation,0004");
106 add("04,,,Smart MX with Mifare 1K emulation,0104");
107 add("04,,,Smart MX with Mifare 1K emulation,0204");
108 add("04,,,Smart MX with Mifare 1K emulation,0304");
109 add("04,,,Smart MX with Mifare 1K emulation,0404");
110 add("04,,,Smart MX with Mifare 1K emulation,0504");
111 add("04,,,Smart MX with Mifare 1K emulation,0604");
112 add("04,,,Smart MX with Mifare 1K emulation,0704");
113 add("04,,,Smart MX with Mifare 1K emulation,0804");
114 add("04,,,Smart MX with Mifare 1K emulation,0904");
115 add("04,,,Smart MX with Mifare 1K emulation,0A04");
116 add("04,,,Smart MX with Mifare 1K emulation,0B04");
117 add("04,,,Smart MX with Mifare 1K emulation,0C04");
118 add("04,,,Smart MX with Mifare 1K emulation,0D04");
119 add("04,,,Smart MX with Mifare 1K emulation,0E04");
120 add("04,,,Smart MX with Mifare 1K emulation,0F04");
121 add("04,,,Smart MX with 7 byte UID,0048");
122 add("04,,,Smart MX with 7 byte UID,0148");
123 add("04,,,Smart MX with 7 byte UID,0248");
124 add("04,,,Smart MX with 7 byte UID,0348");
125 add("04,,,Smart MX with 7 byte UID,0448");
126 add("04,,,Smart MX with 7 byte UID,0548");
127 add("04,,,Smart MX with 7 byte UID,0648");
128 add("04,,,Smart MX with 7 byte UID,0748");
129 add("04,,,Smart MX with 7 byte UID,0848");
130 add("04,,,Smart MX with 7 byte UID,0948");
131 add("04,,,Smart MX with 7 byte UID,0A48");
132 add("04,,,Smart MX with 7 byte UID,0B48");
133 add("04,,,Smart MX with 7 byte UID,0C48");
134 add("04,,,Smart MX with 7 byte UID,0D48");
135 add("04,,,Smart MX with 7 byte UID,0E48");
136 add("04,,,Smart MX with 7 byte UID,0F48");
141 background-color: #2F3440;
142 background-color:#232323;
144 xtext-transform: uppercase;
146 font-family: monospace,Arial;
150 border: 1px solid white;
155 td.blockzero, .turqoise{
156 color: rgb(140, 245, 193);
164 td.accessconditions, .red{
169 border-top: 1px solid white;
173 /** Jquery for the poor **/
174 function dc(x){return document.createElement(x)}
178 table.appendChild(row);
181 function td(row, text){
182 var tdata = dc('td');
183 row.appendChild(tdata);
184 tdata.appendChild(document.createTextNode(text))
189 * The identifiers that determine how to highlight data and present information
194 // Should be 32 characters long ( 16 bytes per block)
195 if(data[0].length != 32) { return false; }
196 // ... add more checks if necessary ...
198 var info = {Type : "Mifare"}
199 info['Size'] = (data[0].length / 2 * data.length) + " Bytes";
200 info['UID'] = data[0].substring(0,8);
201 info['SAK'] = data[0].substring(10,12);
202 info['ATQA'] = data[0].substring(12,16);
204 info['Name'] = lookup(info.ATQA, info.SAK);
205 return {info: info, highlighter : mifareHighlighter }
209 // Should be 8 characters long ( 4 bytes per block)
210 if(data[0].length != 8) { return false; }
211 // ... add more checks if necessary ...
212 var info = {Type : "NDEF"}
213 info['Size'] = (data[0].length / 2 * data.length) + " Bytes";
215 return {info: info, highlighter : ndefHighligheter }
218 {//This is the catch-all
219 return {info: {type : "Unknown"}, highlighter : noHighlighter}
225 * Helper function to convert bin-data into printable chars
228 function to_ascii(hexval)
230 var intval = parseInt(hexval,16);
231 if(intval > 31 && intval < 127)
233 return String.fromCharCode(intval);
239 function loadIntoTable(data, info, ascii)
242 for(var i = 0 ; i < data.length ; i++)
246 var bytes = line.match(/(.{1,2})/g);
247 for(var b = 0 ; b < bytes.length ; b++)
249 var elem = td(row, ascii ? to_ascii(bytes[b]) : bytes[b]);
250 info.highlighter.addClass(elem,i,b, bytes[b]);
253 document.body.appendChild(t);
255 function loadGeneralInfo(data, info)
258 for (var key in info)
264 document.body.appendChild(t);
267 function handle(dump)
269 var data = dump.data;
271 for(var i = 0; i < identifiers.length && !info; i++)
272 info = identifiers[i](data);
276 loadIntoTable(data, info, false);
277 loadIntoTable(data, info, true);
278 loadGeneralInfo(data, info.info);
281 var noHighlighter = {
282 addClass : function(el ,line, byte)
287 var ndefHighligheter = {
288 addClass : function(el ,line, byte, value)
292 el.className += " red";
297 if( byte == 0 && "e1" == value.toLowerCase()) el.className += " turqoise";
298 if( byte == 1 ) el.className += " yellow";
299 if( byte == 2 ) el.className += " blue";
304 var mifareHighlighter = {
305 addClass : function(el ,line, byte)
309 el.className += " blockzero";
316 //Quadruple size sectors
322 if(line % linesPerSector == 0)
324 el.className += " sectorhdr";
326 if(line % linesPerSector == (linesPerSector -1))
328 el.className += " sectortrailer";
329 if(byte == undefined)
334 if(byte < 6) el.className += " key_a";
335 else if(byte < 10) el.className += " accessconditions";
336 else el.className += " key_b";
359 local function getHTML(data)
360 return skel_1 .. data .. skel_2
363 return {getHTML = getHTML}