Project

General

Profile

OsmoNITB Crypto » History » Version 6

laforge, 03/23/2018 01:00 PM

1 6 laforge
{{include(cellular-infrastructure:MacroLegacy)}}
2 1 dexter
3 5 dexter
h1. A5/x Crypto support
4 1 dexter
5
6 5 dexter
7
8
h2. Prepare Simcard
9
10
11
The first thing we do is to prepare a [[MagicSim]]-Simcard with our own provider data. We use the utitity pysim to write the provider data to the card. Enter ./pySim.py --help to get an overview about the parameters. For now it is only importand that you keep in mind that the imsi must begin with the MCC, followed by the MNC and that the pattern in the imsi must match the parameter -x (which is the MCC) and the parameter -y (which is the MNC). You also should note the KI (opetion -k) somewhere. We need it later.
12
<pre>
13 1 dexter
dexter@da-laptop-w3:~/pysim$ ./pySim.py -d /dev/ttyUSB2 -n openBSC -c 49 -x 001 -y 01 -i 001010000000000 -s 12345678901234567890 -k DEADBEEF0C0FFEE0F00D013370D00F23
14
Generated card parameters :
15
 > Name    : openBSC
16
 > SMSP    : 00495555
17
 > ICCID   : 12345678901234567890
18
 > MCC/MNC : 1/1
19
 > IMSI    : 010010000000000
20
 > Ki      : DEADBEEF0C0FFEE0F00D013370D00F23
21
22
Autodetected card type magicsim
23
Programming ...
24
Done !
25
dexter@da-laptop-w3:~/pysim$ 
26 5 dexter
</pre>
27 1 dexter
28
Pysim can be downloaded at: git clone git://git.osmocom.org/pysim.git
29
30
Now it is time to test if the card basicly work. Just grap a mobile phone, insert the card. Switch the pone on the mobile pone. Than you start your network with the option -e 1 to see whats going on. Without further intervention the moile phone should login to your network. That is a sign that the simcard works and makes the pone successfully think that your testnetwork is its home network.
31
32
Note: The network was configured to accept any pone. (accept-all) We can do this safely because we operate the natwork with a dummload under controlled conditions.
33
34
The output should contain some lines like that:
35
36 5 dexter
<pre>
37 1 dexter
<0012> db.c:613 Failed to find the Subscriber. '0' '001010000000000'
38
<0012> db.c:294 New Subscriber: ID 1, IMSI 001010000000000
39
<0012> db.c:802 Allocated extension 26056 for IMSI 001010000000000.
40
<0000> abis_rsl.c:1348 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION
41
<0003> gsm_04_08.c:1025 CLASSMARK CHANGE CM2(len=3) CM3(len=2)
42
<0012> db.c:699 Sync Equipment IMEI=, classmark1=33, classmark2=33 59 80 , classmark3=60 14 
43
<0000> abis_rsl.c:1348 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION
44
<0002> gsm_04_08.c:387 IDENTITY RESPONSE: mi_type=0x02 MI(357140011801950)
45
<0012> db.c:883 New Equipment: ID 1, IMEI 357140011801950
46 5 dexter
<0012> db.c:921 New [[EquipmentWatch]]: ID 1, IMSI 001010000000000, IMEI 357140011801950
47 1 dexter
<0012> db.c:699 Sync Equipment IMEI=357140011801950, classmark1=33, classmark2=33 59 80 , classmark3=60 14 
48
<0012> db.c:766 Allocated TMSI 1473277565 for IMSI 001010000000000.
49 5 dexter
</pre>
50 1 dexter
51 2 dexter
We see that our pone was accepted by our network. We can see our custom imsi 001010000000000. That means that the simcard parameters are correct so far.
52 1 dexter
53
54 5 dexter
h2. Configure the network
55
56
57 1 dexter
Now we take a closer look to the configuration:
58
59 5 dexter
<pre>
60 1 dexter
!
61
network
62
 network country code 1
63
 mobile network code 1
64
 short name openBSC
65
 long name openBSC
66
 timer t3101 10
67
 timer t3113 60
68
 auth policy accept-all
69
70
! Encryption settings
71
 encryption a5 1
72 5 dexter
</pre>
73 1 dexter
74 3 dexter
In the network section we activate the encryption by adding a line "encryption a5 1" at network level. Tha 'a' of a5 must be written in lowercase. Otherwise you will get an error message.
75 1 dexter
76
Note: In this example "auth policy accept-all" is enabled here for debug. You should disable this when all tests are finished. Do not forget to set the authorisation flag for the subscriber.
77
78
So we try again to make sure that our changes are accepted:
79
80 5 dexter
<pre>
81 1 dexter
<0002> gsm_04_08.c:937 LOCATION UPDATING REQUEST: mi_type=0x04 MI(1473277565) type=IMSI ATTACH 
82 5 dexter
<0012> db.c:641 Found Subscriber: ID 1, IMSI 1010000000000, NAME _, TMSI 1473277565, EXTEN '26056', LAC 1, AUTH 0
83 1 dexter
<0001> gsm_04_08.c:99 (bts 0 trx 0 ts 0 pd 05) Sending 0x18 to MS.
84
<0000> abis_rsl.c:1348 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION
85
<0003> gsm_04_08.c:1025 CLASSMARK CHANGE CM2(len=3) CM3(len=2)
86
<0012> db.c:699 Sync Equipment IMEI=357140011801950, classmark1=33, classmark2=33 59 80 , classmark3=60 14 
87
<0000> abis_rsl.c:1348 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION
88
<0002> gsm_04_08.c:387 IDENTITY RESPONSE: mi_type=0x02 MI(357140011801950)
89 5 dexter
<0012> db.c:934 Updated [[EquipmentWatch]]: ID 1, IMSI 1010000000000, IMEI 357140011801950
90 1 dexter
<0012> db.c:699 Sync Equipment IMEI=357140011801950, classmark1=33, classmark2=33 59 80 , classmark3=60 14 
91
<0002> auth.c:83 No retrievable Ki for subscriber, skipping auth<0012> db.c:766 Allocated TMSI 1347086625 for IMSI 1010000000000.
92
<0002> gsm_04_08.c:351 -> LOCATION UPDATE ACCEPT
93 5 dexter
</pre>
94 1 dexter
95
We see that authentication was activated successfully. But we gen an error: No retrievable Ki for subscriber, skipping auth. That is normal and the reason is that we did not configure the auth-keys so far. But it shows us that the encryption is ready to go. We also can see that phones for which is no key configured are accepted anyway. This means that having encryption activated does not lock yout your phones that run with old reused simcards.
96
97
98 5 dexter
h2. Setup the keys
99
100
101
The final step is to configure the keys. You have to do this for every user seperately because every user has its individual key. The keys will be stored in the table [[AuthKeys]] of the hlr databse. All you need to do is to enter the key manually through the vty:
102 1 dexter
103
subscriber imsi 001010000000000 a3a8 comp128v1 DEADBEEF0C0FFEE0F00D013370D00F23
Add picture from clipboard (Maximum size: 48.8 MB)