blob: fe4669376a3f0a2f6b8e343230bdf7d70ba830eb [file] [log] [blame]
Harald Weltec1cd0272011-12-07 01:51:46 +01001= osmo-sim-auth =
2
3This is a small script that can be used with a PC-based smart card
4reader to obtain GSM/UMTS authentication parameters from a SIM/USIM
5card.
6
7== prerequisites ==
8
9We assume that you have
10
11* A smart card reader compatible with pcsc-lite
12* Installed python program and pyscard library
13
14
15=== smart card reader ===
16
17Any reader supported by pcsc-lite will work. However, a reader
18compatible with the USB CCID device class is much recommended.
19
20Please verify that the hardware and driver setup is working, e.g. by
21using the 'pcsc_scan' tool included with pcsc-lite. You should get an
22output like:
23{{{
24V 1.4.17 (c) 2001-2009, Ludovic Rousseau <ludovic.rousseau@free.fr>
25Compiled with PC/SC lite version: 1.5.5
26Scanning present readers...
270: OmniKey CardMan 5121 00 00
28
29Wed Dec 7 01:32:37 2011
30 Reader 0: OmniKey CardMan 5121 00 00
31 Card state: Card inserted, Shared Mode,
32 ATR: 3B 9F 95 80 1F C7 80 31 E0 73 FE 21 13 57 12 29 11 02 01 00 00 C2
33
34ATR: 3B 9F 95 80 1F C7 80 31 E0 73 FE 21 13 57 12 29 11 02 01 00 00 C2
35}}}
36
37plus many more lines of output decoding the ATR.
38
39If you only get
40{{{
41PC/SC device scanner
42V 1.4.17 (c) 2001-2009, Ludovic Rousseau <ludovic.rousseau@free.fr>
43Compiled with PC/SC lite version: 1.5.5
44Scanning present readers...
450: OmniKey CardMan 5121 00 00
46
47Wed Dec 7 01:35:08 2011
48 Reader 0: OmniKey CardMan 5121 00 00
49 Card state: Card removed,
50}}}
51
52then your card was not detected in the reader.
53
54If you don't even get any displayed readers, your hardware and/or driver
55setup are likely wrong.
56
57
58=== pyscard ===
59
60pyscard can be installed from packages of major Linux distributions.
61
62If you want to build it from source, it is available from
63http://pyscard.sourceforge.net/
64
65
66== running osmo-sim-auth ==
67
68{{{
69$ ./osmo-sim-auth.py --help
70Usage: osmo-sim-auth.py [options]
71
72Options:
73 -h, --help show this help message and exit
74 -a AUTN, --autn=AUTN AUTN parameter from AuC
75 -r RAND, --rand=RAND RAND parameter from AuC
76 -d, --debug Enable debug output
77 -s, --sim SIM mode (default: USIM)
78}}}
79
80you can run the program in two modes:
81 * running GSM authentication (classic SIM card protocol)
82 * running UMTS authentication (USIM card protocol)
83
84=== classic GSM authentication ===
85
86This mode will use the "RUN GSM ALGORITHM" command as specified in GMS
87TS 11.11
88
89You have to specify
90 * the 16 byte RAND value from the AuC (-r) as 32 hex digits
91 * the '-s' flag to enable SIM mode
92
93{{{
94$ ./osmo-sim-auth.py -r 00000000000000000000000000000000 -s
95Testing SIM card with IMSI 901700000000403
96
97GSM Authentication
98SRES: 215fdb4d
99Kc: 6de816a759a42912
100}}}
101
102=== UMTS authentication ===
103
104This mode will use the "AUTHENTICATE" command as specified in 3GPP TS
10531.102
106
107You have to specify
108 * the 16 byte RAND value from the AuC (-r) as 32 hex digits
109 * the 16 byte AUTN value from the AuC (-a) as 32 hex digits
110
111==== successful operation ====
112
113In this case, the tool will output the following values obtained from
114the card:
115 * RES authentication result value
116 * CK ciphering key
117 * IK integrity key
118 * Kc for inter-RAN handover from UMTS -> 2G
119
120Secondly, the tool will re-run the authentication in "2G authentication
121context" in order to obtain the SRES result. This value would be used
122if a 3G/2G dual-mode phone registers on a 2G network.
123
124{{{
125python ./osmo-sim-auth.py -r 00000000000000000000000000000000 -a ec9320c2c2000000e1dd22c1ad3e2d3d
126[+] UICC AID found:
127found [AID 1] 3GPP || USIM || (255, 134) || (255, 255) || (137, 255,
128255, 255, 255)
129[+] USIM AID selection succeeded
130
131Testing USIM card with IMSI 901700000000403
132
133UMTS Authentication
134RES: e9fc88ccc8a35381
135CK: 7200a184d8f2c758fbdf87900ddbf275
136IK: 12cb2dd3e0ec8378f6fc1d606c619f47
137Kc: 6de816a759a42912
138
139GSM Authentication
140SRES: 215fdb4d
141Kc: 6de816a759a42912
142}}}
143
144==== synchronization required ====
145
146In this case, the AUTHENTICATE command will return the AUTS parameter,
147which has to be sent to the AuC in order to re-synchronzie the SQN
148counter which is kept in both the USIM as well as the AuC.
149
150{{{
151./osmo-sim-auth.py -r 00000000000000000000000000000000 -a ec9320c2c2120000c8b7de2a3449f1bd
152[+] UICC AID found:
153found [AID 1] 3GPP || USIM || (255, 134) || (255, 255) || (137, 255,
154255, 255, 255)
155[+] USIM AID selection succeeded
156
157Testing USIM card with IMSI 901700000000403
158
159UMTS Authentication
160AUTS: 8711a0ec9e2be2f766881a64605b
161
162GSM Authentication
163SRES: 215fdb4d
164Kc: 6de816a759a42912
165}}}