1 /**
  2  *  ---------
  3  * |.##> <##.|  Open Smart Card Development Platform (www.openscdp.org)
  4  * |#       #|  
  5  * |#       #|  Copyright (c) 1999-2009 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 Simple script to read all data elements from a card card application
 25  */
 26 
 27 try	{
 28 	var card = new Card(_scsh3.reader);
 29 	card.reset(Card.RESET_COLD);
 30 	
 31 	var aid = new ByteString("A0000000041010", HEX); // MC
 32 //	var aid = new ByteString("A0000000031010", HEX); // VISA
 33 	
 34 //	var aid = new ByteString("1PAY.SYS.DDF01", ASCII);
 35 
 36 
 37 	
 38 	var fcp = card.sendApdu(0x00, 0xA4, 0x04, 0x00, aid, 0x00, [0x9000]);
 39 	
 40 	print("FCP returned in SELECT: ", new ASN1(fcp));
 41 	
 42 	for (var sfi = 1; sfi <= 31; sfi++) {
 43 		for (var rec = 1; rec <= 16; rec++) {
 44 			//print(((sfi << 3) | 4).toString(16));
 45 			
 46 			var tlv = card.sendApdu(0x00, 0xB2, rec, (sfi << 3) | 4, 0x00);
 47 			if (card.SW == 0x9000) {
 48 				print("SFI " + sfi.toString(16) + " record #" + rec);
 49 				try	{
 50 					var asn = new ASN1(tlv);
 51 					print(asn);
 52 				}
 53 				catch(e) {
 54 					print(tlv.toString(HEX));
 55 				}
 56 			}
 57 		}
 58 	}
 59 }
 60 
 61 catch(e) {
 62 	print("Exception reading from Credit Card Application: " + e.toString());
 63 }
 64