using java card instead of SIM in android with SEEK
I’ve patched android with SEEK for Galaxy S3 and after some struggle I’m now able to send APDUs to SIM card and get proper responses. I want to place my own applet inside SIM but since there is no way we can get the access to do so, I start to wonder if there is anyway we can issue a java card to work like a SIM card. All I need is a java card that the phone can’t distinguish from a SIM, no network coverage is needed and I know it is almost impossible to create a SIM that works OK with operator and gives network coverage. The reason for all this is I need to send APDUs and work with my applet, but if I insert a java card instead of a SIM card in GS3, it gives me no access at all. So my question is this: Is it possible to issue a java card so that it looks like a SIM by the phone (and not the operator)? or Is it possible to change android so that it gives needed access when there is a java card in it, i.e. RIL works as usual? EDIT Okay, I think I’ll try to issue a Java Card with following properties: First, it will have an auto selected applet (default applet) that from now on will be call fake-UICC.
Second, in fake-UICC we’ll emulate the file system of UICC (according to http://www.in2eps.com/fo-uicc/tk-fo-uicc-mf.html).
Third, since different class is used for SIM APDUs ( 0xA0 ) so All APDUs sent from RIL will be directed to fake-UICC by JCRE, since class+instruction is not recognized by normal Java Card. e.g. 0xA0A4 is select for SIM but 0x00A4 is select command for Java Card.
In last step, we will try to send exact same responses a real SIM would send to each APDU. Maybe it won’t work but I think it’s worth a try.
May I ask you to say me how did you send APDUs to your SIM card in your galaxy S3? I’ve the same handset mobile, and I want to do it also. (It’s better to help me here ) Thanks in advance.
Dear @vojta, actually there’s been some progress and it’s now possible to send APDU to our fake UICC. With special thanks to you and Abraham. I will now try to do same thing with a dual SIM phone, if you have any suggestions on that, I’d really appreciate it.
getting started with java card on sim cards
I’m looking to write a simple beginner program using Java Card to run on sim cards. Can anyone point me to some very basic information on getting started? I’ve seen some descriptions of the toolkit api, but I’m looking for things like: what capabilities are supported by the sim card, how to upload my code to the card (do i need special hardware?), how do I tell whether a sim card supports java card, that sort of thing. EDIT: I’m specifically looking to run code on sim cards. I’ve seen some very high level tutorials online, but nothing that goes as far as connecting to a sim card or uploading code. I have a USB sim card reader and a variety of cards to test, but I can’t find any detail on how to work with them.
2 Answers 2
To upload your code to a sim card, it seems to require one of these tools:
I’ve not got any of these to recognise my ebay sim card reader, so I think I’ll have buy a different reader (probably from gemalto)
Edit: I bought the ACS ACR38 SDK, which includes 3 card readers and a selection of cards, along with drivers, code samples and tools. These card readers are working nicely with the Gemalto Developer Suite.
The Usability Lab tutorial provided with the Gemalto Developer Suite is a pretty good way of diving into sim card development.
Very interesting thing to note: it’s pretty hard to get your code running on commercial mobile network operator SIM cards. They typically require the correct certificate before you can write to them.
There are hardware workarounds to this. I’m currently investigating TurboSIM and RebelSIM.
I finally gave up on this project due to other pressures. I was not able to get any Java Card running except on the dev cards, which are not compatible with real devices on a mobile network. The cutout cards such as TurboSIM and RebelSIM are a possibility but quite frustrating to work with.
How to work with SIM cards (Installing applet)
I have a smart card with the following ATR: ATR = 3B 9E 94 80 1F 42 80 31 00 73 BE 21 10 66 54 59 53 04 4C 25 CF . Based on the output of atr-parse.appspot.com I found that it is a MCI (Mobile Communication Company of Iran) SIM card. These are the info that I gained from Historical Bytes :
- EF.DIR and EF.ATR access services: by GET RECORD(s) command
- Card with MF
- Record number supported
- Short EF identifier supported
- Implicit DF selection
- DF selection by file identifier
- DF selection by path
- DF selection by full DF name
- Behaviour of write functions: proprietary
- Value ‘FF’ for the first byte of BER-TLV tag fields: valid
- Data unit in quartets: 1
- Logical channel number assignment: by the card
- Maximum number of logical channels: 1
As you see above it is mentioned that the card has a MF .
The problem is I can’t do anything with this card. In the first step I want to list its contents. I took a look at TS 11.11, TS 102.221,TS 131.102 and TS 151.011 specifications.
As far as I understand from above documents the system file of the card consist of an Master File that its AID is 3F00 and Some DF-s and EF-s. For example base on this below table of TS 151.011 specification I tried to select some DF-s :
Connected to RTP CCID USB Reader 0 ATR: 3B 9E 94 80 1F 42 80 31 00 73 BE 21 10 66 54 59 53 04 4C 25 CF > APDU > A0 A4 04 00 02 5F 30 < 6A 82 >APDU > A4 A4 04 00 00 < 6E 00 >APDU > A0 A4 04 00 00 < 67 00 >APDU > 00 A4 04 00 00 < 61 13 >APDU > 00 C0 00 00 13 < 6F 11 84 09 A0 00 00 00 62 03 01 08 01 A5 04 9F 65 01 FF < 90 00 >APDU > 00 A4 04 00 09 A0 00 00 00 62 03 01 08 01 < 61 13 >APDU > A0 A4 04 00 09 A0 00 00 00 62 03 01 08 01 < 6E 00 >APDU > 00 A4 04 00 09 A0 00 00 00 62 03 01 08 01 < 61 13 >APDU > 00 C0 00 00 13 < 6F 11 84 09 A0 00 00 00 62 03 01 08 01 A5 04 9F 65 01 FF < 90 00 >APDU > 00 A4 04 00 02 3F 00 < 6A 82 >APDU > A0 A4 04 00 02 3F 00 < 6E 00
As you see above I failed all of them and I could find the AID of ISD only.
I tried to list contents with GlobalPlatformPro tool also, but it seems that the card not support Initial Update APDU command :
C:\Users\User\Desktop\today>java -jar gp.jar -visa2 -key 47454D5850524553534F53414D504C45 -unlock -list -v -d -i # Detected readers from SunPCSC [*] RTP CCID USB Reader 0 SCardConnect("RTP CCID USB Reader 0", T=*) -> T=0, 3B9E94801F4280310073BE211066545953044C25CF SCardBeginTransaction("RTP CCID USB Reader 0") Reader: RTP CCID USB Reader 0 ATR: 3B9E94801F4280310073BE211066545953044C25CF More information about your card: http://smartcard-atr.appspot.com/parse?ATR=3B9E94801F4280310073BE211066545953044C25CF A>> T=0 (4+0000) 00A40400 00 A> T=0 (4+0000) 80CA9F7F 00 A> T=0 (4+0000) 80CA0066 00 A> T=0 (4+0000) 80CA00E0 00 A> T=0 (4+0000) 00CA00E0 00 A> T=0 (4+0008) 80500000 08 FE44F8E8DF60349B 00 A
I want to know what's wrong? How I can install java card applets on this SIM card?
Note that I already worked with Java Card successfully,but I am totally confused about these kind of SIM cards. I appreciate any one could shed any light on this issue. Regards.