Home - kamwar/simLAB GitHub Wiki

logosimLAB

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 backup SIM 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.

simLAB blocks Environment setup

simLAB installation with docker

  1. Install docker https://docs.docker.com/v1.8/installation

  2. Kill pcscd process if it's started on your host

$killall pcscd
  1. Download and run image with command
$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/

  1. To start simLAB with virtual SIM use the following command inside container
#python mim/mim_soft.py

No hardware is needed for virtual SIM editing. More info can be found here

simLAB installation under Linux

$ 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

Linux issues

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

simLAB installation under Microsoft Windows 7

  1. Install python 2.7.11 64bit Add C:\Python27 to system enviroment variable PATH

  2. Install swig https://sourceforge.net/projects/swig/files/swigwin/swigwin-3.0.8/swigwin-3.0.8.zip/download Download and extract, add directory containing swig.exe to system enviroment variable PATH

  3. Install Microsoft Visual C++ 9.0 for python. Download from http://aka.ms/vcpython27

  4. Install python packages: pyusb, plac, gevent, zerorpc, lxml:

$ 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
  1. Install pyscard, use e.g. git-scm for windows
$ 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

  1. Install AT91 drivers (only if simTrace hardware is connected) Download libusb from https://sourceforge.net/projects/libusb/files/libusb-1.0/ Copy .\MS64\dll\libusb-1.0.dll to C:\Python27 Install libusbK driver with zadig Run 'Driver Install Creator Wizard' and install libusbK driver for AT91USBSserial

Note: You might need to disable driver signature enforcement (enter Test mode) to install the driver

  1. Download and run simLAB, use e.g. git-scm for windows
  $ 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

  • Visual Studio 2010 (VS10):
SET VS90COMNTOOLS=%VS100COMNTOOLS%
  • Visual Studio 2012 (VS11):
SET VS90COMNTOOLS=%VS110COMNTOOLS%
  • Visual Studio 2013 (VS12):
SET VS90COMNTOOLS=%VS120COMNTOOLS%

simlabTrace Installation

Flash the SIMtrace board with the SIM forwarder firmware.
Detailed information can be found in the simlabTrace wiki.

Verifying environment setup

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

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

Documentation

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)

No warranty

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.

License

GNU GPL v2

Credits

The project is a fork of Tom Schouten's (zwizwa) project https://github.com/zwizwa/at91work/tree/apdu_phone/src

Main contributors:

  • Kamil Wartanowicz
  • Szymon Mielczarek

Thanks to:

  • Janusz Kuszczynski
  • Aleksander Kulon