# Simcard making
## **<font color="#f00">Make sure you have a simcard reader and a programmable simcard</font>**
### Install needed packages
```
sudo apt-get install python3-pyscard python3-serial python3-pip python3-yaml
sudo apt-get install pcscd pcsc-tools libccid python3-dev swig python3-setuptools python3-pip libpcsclite-dev
sudo pip3 install pycrypto pytlv
```
### Build the pyscard package from source
#### If the pip3 install failed, please refer this
```
git clone https://github.com/LudovicRousseau/pyscard
cd <pyscard-path>
sudo /usr/bin/python setup.py build_ext install
```
#### Prepare for SIM card information

### For sysmoISIM-sjs2(black card)
#### Clone the sysmo-usim-tool
```
git clone https://gitea.sysmocom.de/sysmocom/sysmo-usim-tool/
```
#### Verify your reader is ready
```
sudo pcsc_scan # It should show the information of simcard
```
#### Change your opcode and ki
> The IMSI sysmoISIM-sjs2 cannot be written, so please check your configuration when using free5GC or other open source 5G core
The adm code will be sent by the sysmoISIM company, make sure you had this information
If you enter wrong adm code 3 times, this card will be locked
{.is-info}
```
python3 sysmo-isim-tool.sja2.py -a <adm code of simcard> -C 8e27b6af0e692e750f32667a3b14605d -K 8baf473f2f8fd09487cccbd7097c6862
```
> You can also use the -h option to see all the functions to this python tool
{.is-success}
### For sysmoUSIM-sjs1(orange card)
#### Clone PySIM and install required packages
```
git clone git://git.osmocom.org/pysim.git
pip3 install -r requirements.txt #the pyscard may fail, please refer the informaion above
```
#### Verify your reader is ready
```
sudo pcsc_scan
```
#### Check whether your reader can read the SIM card
```
cd <pysim-path>
./pySim-read.py –p 0
```
#### Program your SIM card information
example:

```
./pySim-prog.py -p 0 -x 208 -y 93 -t sysmoUSIM-SJS1 -i 208930000000003 --op=8e27b6af0e692e750f32667a3b14605d -k 8baf473f2f8fd09487cccbd7097c6862 -s 8988211000000088313 -a 23605945
```
> reference
https://hackmd.io/@AN4J0hQ9SaGjRxVsuG1fwg/rkPxfLTdm?type=view&fbclid=IwAR22cuEy41hSZDMHhW5yETt-nOCZhxL3_tXJZwbbElYeM8zKAqOBsKwRcKk
https://osmocom.org/projects/cellular-infrastructure/wiki/SysmoISIM-SJA2
{.is-success}