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 TNP3xxx Activision 1K,0f01,01");
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");
142 background-color: #2F3440;
143 background-color:#232323;
145 xtext-transform: uppercase;
147 font-family: monospace,Arial;
151 border: 1px solid white;
156 td.blockzero, .turqoise{
157 color: rgb(140, 245, 193);
165 td.accessconditions, .red{
170 border-top: 1px solid white;
174 /** Jquery for the poor **/
175 function dc(x){return document.createElement(x)}
179 table.appendChild(row);
182 function td(row, text){
183 var tdata = dc('td');
184 row.appendChild(tdata);
185 tdata.appendChild(document.createTextNode(text))
190 * The identifiers that determine how to highlight data and present information
195 // Should be 32 characters long ( 16 bytes per block)
196 if(data[0].length != 32) { return false; }
197 // ... add more checks if necessary ...
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);
205 info['Name'] = lookup(info.ATQA, info.SAK);
206 return {info: info, highlighter : mifareHighlighter }
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";
216 return {info: info, highlighter : ndefHighligheter }
219 {//This is the catch-all
220 return {info: {type : "Unknown"}, highlighter : noHighlighter}
226 * Helper function to convert bin-data into printable chars
229 function to_ascii(hexval)
231 var intval = parseInt(hexval,16);
232 if(intval > 31 && intval < 127)
234 return String.fromCharCode(intval);
240 function loadIntoTable(data, info, ascii)
243 for(var i = 0 ; i < data.length ; i++)
247 var bytes = line.match(/(.{1,2})/g);
248 for(var b = 0 ; b < bytes.length ; b++)
250 var elem = td(row, ascii ? to_ascii(bytes[b]) : bytes[b]);
251 info.highlighter.addClass(elem,i,b, bytes[b]);
254 document.body.appendChild(t);
256 function loadGeneralInfo(data, info)
259 for (var key in info)
265 document.body.appendChild(t);
268 function handle(dump)
270 var data = dump.data;
272 for(var i = 0; i < identifiers.length && !info; i++)
273 info = identifiers[i](data);
277 loadIntoTable(data, info, false);
278 loadIntoTable(data, info, true);
279 loadGeneralInfo(data, info.info);
282 var noHighlighter = {
283 addClass : function(el ,line, byte)
288 var ndefHighligheter = {
289 addClass : function(el ,line, byte, value)
293 el.className += " red";
298 if( byte == 0 && "e1" == value.toLowerCase()) el.className += " turqoise";
299 if( byte == 1 ) el.className += " yellow";
300 if( byte == 2 ) el.className += " blue";
305 var mifareHighlighter = {
306 addClass : function(el ,line, byte)
310 el.className += " blockzero";
317 //Quadruple size sectors
323 if(line % linesPerSector == 0)
325 el.className += " sectorhdr";
327 if(line % linesPerSector == (linesPerSector -1))
329 el.className += " sectortrailer";
330 if(byte == undefined)
335 if(byte < 6) el.className += " key_a";
336 else if(byte < 10) el.className += " accessconditions";
337 else el.className += " key_b";
360 local function getHTML(data)
361 return skel_1 .. data .. skel_2
364 return {getHTML = getHTML}