1 /** 2 * --------- 3 * |.##> <##.| Open Smart Card Development Platform (www.openscdp.org) 4 * |# #| 5 * |# #| Copyright (c) 1999-2006 CardContact Software & System Consulting 6 * |'##> <##'| Andreas Schwier, 32429 Minden, Germany (www.cardcontact.de) 7 * --------- 8 * 9 * This file is part of OpenSCDP. 10 * 11 * OpenSCDP is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License version 2 as 13 * published by the Free Software Foundation. 14 * 15 * OpenSCDP is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with OpenSCDP; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 * @fileoverview Example to read from a Mifare classic card using a shell script 25 */ 26 27 load("mifare.js"); 28 29 30 var card = new Card(_scsh3.reader); 31 32 card.reset(Card.RESET_COLD); 33 34 var mif = new Mifare(card); 35 36 print("UID: " + mif.getUID()); 37 38 if (_scsh3.reader.substr(0, 3) != "SCM") { 39 var keyaid = 0x00; // Use for ACR and Omnikey readers 40 } else { 41 print("SCM Reader detected."); 42 var keyaid = 0x60; // Use for SCS SDI 010 and 011 43 } 44 45 for (var i = 0; i < 16; i++) { 46 var s = mif.newSector(i); 47 s.setKeyId(keyaid); 48 49 var ki = s.authenticatePublic(0, Mifare.KEY_A); 50 if (ki >= 0) { 51 print("Authentication with " + Mifare.PUBLICKEYS[ki].toString(HEX) + " successfull"); 52 s.read(0); 53 s.read(1); 54 s.read(2); 55 s.read(3); 56 print(s.toString()); 57 } else { 58 print("Unknown key A - skipping sector " + i); 59 } 60 } 61