Search code examples
gsmsim-card

How to access a SIM card programmatically?


Just any old GSM compatible SIM card (bonus for 3G USIM).

I presume I need some hardware? Can anyone recommend something cheap for hobbyist, and something more professional?

I presume that there will be full docs of an API with the h/w, so maybe this should be tagged "no-programming-related"? Sorry, if so.

Any good URLs or books (I am conversant with the 3GPP standards).

I'm not (black hat) hacking, don't worry, just not pleased with the likes of SIM Card Secretary, Data Doctor Recovery, etc, so would like to code my own, but might turn it commercial, or offer SIM card programming services (data recover from damaged card, etc) as a sideline.


Update: while I am primarily interested just reading my SMS for backup, it might be a bonus if someone knows of a cheap SIM card writer (so that I can back up all or part of the SIM and restore it later)


Solution

  • You can do that with any PC/SC smart card reader (and writer, as others pointed out) and a program that can read and parse the data for you.

    • Talking to a card is done via APDU commands (defined in ISO-7816)
    • The command set used by SIM (2G) and USIM (3G) cards is different, so you have to keep that in mind
    • The structure and format of the file system of a SIM card is defined in GSM 11.11 (for 2G) and ETSI TS 131.102 (for 3G) - all this documentation is public and available free of charge
    • The SMS are kept in a file called EF SMS, its name is 0x6F3C, its structure is defined in section 10.5.3 of GSM 11.11

    Direct answers to your questions:

    • Here's where to buy a SIM reader, click on 'photos' to see pics of the device and screenshots of the software
    • SIM Manager is the program that does everything you want (including reading SMS, restoring SMS, it can even attempt to recover deleted SMS - if they're still physically on the card)
    • A SIM card SDK is available too. It is a DLL you can load and apply in your program. This thing does all the hard work for you, all you need is to create a GUI on top of it

    I am one of the people from the team that created SIM Manager and the aforementioned SDK.