simLAB is a pure python tool for editing and simulating SIM card. Together with simlabTrace, it allows modification of APDU exchanged between Terminal (Mobile Equipment) and SIM.
Manage the SIM card with read, write, create, delete commands. You don’t have to take into account what code (i.e. PIN, PUK, ADM) is needed to access SIM files. If access condition is not satisfied then you will get prompt to enter the valid code. With interactive shall, you might directly issue the command and get the result information on the fly. simLAB allows to backupSIM file system which might be used in virtual (simulated) SIM. All shell commands are supported on live and soft SIM. To connect remotely with interactive shell use DBUS or Telnet protocol.
simLAB is commonly used for testing Mobile Equipment with customized SIM content. You might easily modify HPLMN (part of EF_IMSI, EF_AD) with single command
set_plmn. The command
writei allows to update common files like EF_IMSI, EF_SPN, EF_OPL, EF_PNN, EF_LOCI with interpreted value without knowledge of the file structure.
$docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb kamwar/simlab
Raspberry Pi installation guide: https://hub.docker.com/r/kamwar/rpi-simlab/
No hardware is needed for virtual SIM editing. More info can be found here
$ sudo apt-get install python-pip $ sudo apt-get install python-dev $ sudo apt-get install python-tk $ sudo apt-get install swig $ sudo apt-get install libpcsclite1 pcscd pcsc-tools $ sudo apt-get install python-pyscard $ sudo easy_install pyusb lxml $ sudo pip install plac gevent zerorpc $ git clone https://github.com/kamwar/simLAB.git $ cd ./simLAB $ sudo python simlab.py
File "/usr/local/lib/python2.7/dist-packages/msgpack/fallback.py", line 347, in _read_header b = ord(c) TypeError: ord() expected string of length 1, but memoryview found
Double check the installation of the msgpack package:
$ pip install --reinstall msgpack
$ cd C:\Python27\Scripts $ pip install pyusb plac gevent zerorpc
There are problems with installing lxml by pip, use easy_install instead
$ cd C:\Python27\Scripts $ easy_install lxml
$ git clone https://github.com/LudovicRousseau/pyscard.git $ cd ./pyscard/ $ python setup.py build_ext install
Note: don’t use “pip install pyscard”, ../smartcard/scard/scard.py will be missing
Note: You might need to disable driver signature enforcement (enter Test mode) to install the driver
$ git clone https://github.com/kamwar/simLAB.git $ cd ./simLAB $ python simlab.py
Microsoft Windows Installation issues
Gevent installation error: Setup script exited with error: Unable to find vcvarsall.bat. Depending on the Visual studio installer, set in terminal
Flash the SIMtrace board with the SIM forwarder firmware.
Detailed information can be found in the simlabTrace wiki.
Before you begin, you can verify that your environment has been correctly setup. Insert live SIM (e.g. Mobile Operator SIM or test UICC SIM) into PC/SC compliant reader.
Start test runner to execute internal tests for both live and soft SIM.
$ cd /path/to/simLAB $ python ./tests/runner.py
Test results example
This is just a quick example of simLAB capabilities as a SIM editor.
readi – read EF_IMSI value (interpreted)
/>readi EF_IMSI status OK data 001010123456789
writei – update EF_IMSI value (interpreted)
/>writei EF_IMSI 001020123456789 status OK
get_plmn – get HPLMN (based on IMSI)
/ADF0/6F07>get_plmn status OK data 00102
set_plmn – update HPLMN with MCC=310, MNC=410
/ADF0/6FAD>set_plmn 310410 status OK
read – read EF_AD raw data to verify length of MNC in the IMSI
/ADF0/6F07>read EF_AD status OK data 80000103
SIM shell commands – shell command to be executed via interactive mode or dbus or telnet
SIM router – connect many SIM cards and define routing attributes for every SIM
SIM/SAT simulation – USIM/ISIM card simulator and SIM application toolkit (SAT)
The program is provided “as is” without warranty of any kind. It is possible that your SIM card will be permanently blocked, e.g. when verification of security code fails. Be careful when changing EF_ARR rules with NEVER condition.
Usage of this software might require patent licenses and those are users responsibility. Use for testing purposes only.
GNU GPL v2
The project is a fork of Tom Schouten’s (zwizwa) project https://github.com/zwizwa/at91work/tree/apdu_phone/src