How to access a SIM card programmatically?

前端 未结 5 1779
逝去的感伤
逝去的感伤 2021-01-30 04:57

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 professio

5条回答
  •  再見小時候
    2021-01-30 05:26

    1. pySim

      In the below example, we are changing the card’s IMSI to 901700000003080 (option -i) and we are specifying a new set of -n NAME (Operator name), -t TYPE (Card type), -c CC (Country code), -x MCC (Mobile Country Code), -y MNC (Mobile Network Code) and -s ID (Integrated Circuit Card ID) values.

      $ ./pySim-prog.py -p 0 -n OpenBSC -t sysmosim-gr1 -i 901700000003080 -c 001 -x 001 -y 02 -s 1791198229180000075
      

    Is it enough just filling the new SIM card with new meta and will it working the same way as original? pyusb

    Here is the full list of options:

    $ ./pySim-prog.py -help
      Usage: pySim-prog.py [options]  Options:   
      -h, --help            show this help message and exit
      -d DEV, --device=DEV  Serial Device for SIM access [default: /dev/ttyUSB0]
      -b BAUD, --baud=BAUD  Baudrate used for SIM access [default: 9600]
      -p PCSC, --pcsc-device=PCSC
                            Which PC/SC reader number for SIM access
      -t TYPE, --type=TYPE  Card type (user -t list to view) [default: auto]
      -a PIN_ADM, --pin-adm=PIN_ADM
                            ADM PIN used for provisioning (overwrites default)
      -e, --erase           Erase beforehand [default: False]   
      -S SOURCE, --source=SOURCE
                            Data Source[default: cmdline]
      -n NAME, --name=NAME  Operator name [default: Magic]
      -c CC, --country=CC   Country code [default: 1]
      -x MCC, --mcc=MCC     Mobile Country Code [default: 901]
      -y MNC, --mnc=MNC     Mobile Network Code [default: 55]
      -m SMSC, --smsc=SMSC  SMSP [default: '00 + country code + 5555']
      -M SMSP, --smsp=SMSP  Raw SMSP content in hex [default: auto from SMSC]
      -s ID, --iccid=ID     Integrated Circuit Card ID
      -i IMSI, --imsi=IMSI  International Mobile Subscriber Identity
      -k KI, --ki=KI        Ki (default is to randomize)
      -o OPC, --opc=OPC     OPC (default is to randomize)
      --op=OP               Set OP to derive OPC from OP and KI
      --acc=ACC             Set ACC bits (Access Control Code). not all card types are supported
      -z STR, --secret=STR  Secret used for ICCID/IMSI autogen
      -j NUM, --num=NUM     Card # used for ICCID/IMSI autogen
      --batch               Enable batch mode [default: False]
      --batch-state=FILE    Optional batch state file
      --read-csv=FILE       Read parameters from CSV file rather than command line
      --write-csv=FILE      Append generated parameters in CSV file
      --write-hlr=FILE      Append generated parameters to OpenBSC HLR sqlite3
      --dry-run             Perform a 'dry run', don't actually program the card
    

    The source code is available.

    1. Also the SIM card is just a smart card. You can use pyscard or pyusb to operate on it. I found this Q&A helpful.

提交回复
热议问题