Project

General

Profile

SIMtrace » History » Version 32

tsaitgaist, 02/19/2016 10:48 PM
modi added

1 1 laforge
[[PageOutline]]
2
= Osmocom SIMtrace =
3
4
Osmocom SIMtrace is a software and hardware system for passively tracing SIM-ME communication between the SIM card and the mobile phone.
5
6 18 laforge
It looks a bit like this:
7
{{{
8
#!graphviz
9
digraph G{
10
  //rankdir = LR;
11
  Phone -> SIMtrace [label = "Flexi-PCB cable"];
12
  SIMtrace -> SIM;
13
  SIMtrace -> PC [label = "USB cable"];
14 1 laforge
15 18 laforge
  SIMtrace [ label = "SIMtrace hardware" ];
16
}
17
}}}
18
19 29 laforge
When connected to a phone, it looks like this:
20
21
22 30 tsaitgaist
[[Image(simtrace_and_phone.jpg, align=center,50%)]]
23 29 laforge
24 18 laforge
It works by utilizing the T=0 capable USART of the USB-attached AT91SAM7 microcontroller.
25
26 1 laforge
The USART passively receives the bytes as they are exchanged on the ISO 7816-3 / TS 11.11 interface between SIM and phone.
27
The received bytes are sent via USB to the PC, where a program called {{{simtrace}}} on the PC gathers data from the USB device,
28
parses the APDUs and forwards them via [wiki:GSMTAP] to the [wiki:wireshark] protocol analyzer.
29
30
== Features ==
31
 * Completely passive scanner
32 17 laforge
 * RST and ATR detection
33 1 laforge
 * Auto-bauding with PPS / PTS support
34
 * Segmentation of APDUs
35 32 tsaitgaist
36
== Modi ==
37
38
[[Image(simtrace_functions.png, align=right,33%)]]
39
40
SIMtrace has the possibility to work as:
41
 * sniffer
42
 * card reader
43
 * card emulator
44
 * man-in-the-middle
45
46
The SAM7S offers 2 T=0 capable USART ports.
47
One is connected to the phone (PA21-PA27), the other to the SIM (PA1-PA7).
48
The lines goes from the phone to the SIM through a bus switch (IC4=[http://www.ti.com/lit/ds/symlink/sn74cb3q3244.pdf CB3Q3244]).
49
The bus switch offer 2 buses of 4 lines:
50
 * The first is used to forward RST, CLK, and VPP (between the SIM and the phone). It is controlled by SC_SW (PA20)
51
 * The second is used to forward I/O (between the SIM and the phone). It is controlled by SC_I/O (PA19)
52
53
The various modi require to interrupt different lines:
54
55
|| SW_SC (PA20) || SC_I/O (PA19) || description || modus ||
56
|| L || L || phone and SIM directly connected || sniffer (use any USART port) ||
57
|| L || H || only I/O interrupted || MitM (use both USART port) ||
58
|| H || H || phone and SIM not connected || card read, emulator (use each USART port) ||
59
60
As of 2012-01-12, only the sniffer is implemented
61
62
SIM cards support various classes (voltage levels): class A = 5.0V, class B = 3.0V, class C = 1.8V.
63
SIMtrace v1.x only supports class B (3.0V), which all actual SIM cards and phone also support.
64
To ensure class B is used, SIMtrace forces 3.3V (within the 3.0V±10% spec) by holding the VCC line at this voltage.
65
SIMtrace v2 will support all 3 classes.
66 1 laforge
67
== TODO ==
68
 * Check for parity errors
69
 * Verify TCK / PCK check-bytes
70 31 laforge
 * Implement MITM
71 1 laforge
72
== Hardware ==
73 17 laforge
74 1 laforge
The first implementations used an Olimex SAM7-P64 development board with some of the I/O lines hooked up to the mechanical SIM card adapters from [wiki:RebelSIM_Scanner]. If the RebelSIM scanner is used, connect the USB even if just the lines are used. It needs to be powered, else the real reader will often fail to initialize the card.
75
76 31 laforge
Now we have a dedicated PCB design.  The schematics and Gerber files are released as open source hardware and can be produced by everyone.
77
78
However, those of you who are not interested in building it from scratch can buy a complete factory-produced, tested and flashed PCB assembly from http://shop.sysmocom.de/products/simtrace
79
80 27 laforge
More details are available at [wiki:SIMtrace/Hardware]
81 4 laforge
82 1 laforge
== Firmware ==
83
84 28 laforge
The firmware for the AT91SAM7S device was written by reusing a lot of the code for the [http://www.openpcd.org/ OpenPCD]
85
RFID reader.  Details are available at [wiki:SIMtrace/Firmware].
86 24 tsaitgaist
87 1 laforge
88 5 laforge
== Host PC Software ==
89
90 6 tsaitgaist
The {{{simtrace}}} program is part of the git://git.osmocom.org/simtrace.git repository. It will bind to the USB device
91 5 laforge
and send GSMTAP frames using UDP/IPv4 to localhost:4729.
92 6 tsaitgaist
93 14 tsaitgaist
=== Preconditions ===
94 1 laforge
95 14 tsaitgaist
[wiki:libosmocore] and headers (simtrace_usb.h) from the firmware.
96
97
additional packages :
98 6 tsaitgaist
{{{
99 26 tsaitgaist
sudo apt-get install libusb-1.0-0-dev
100 7 tsaitgaist
}}}
101 1 laforge
102 6 tsaitgaist
=== Compiling it ===
103
104 1 laforge
{{{
105 14 tsaitgaist
git clone git://git.osmocom.org/simtrace.git
106 21 tsaitgaist
cd simtrace/host/
107 6 tsaitgaist
make
108
}}}
109
110
=== Using it ===
111
112
Simply start '''simtrace'''.
113 13 tsaitgaist
It will send the GSMTAP frames to UDP/IPv4 localhost:4729.
114 1 laforge
115
It will also print hexdumps of the frames to the console, looking like this:
116 6 tsaitgaist
{{{
117 1 laforge
sudo ./simtrace
118
APDU: (9):  a0 a4 00 00 02 6f 07 9f 0f
119
APDU: (22):  a0 c0 00 00 0f 00 00 00 09 6f 07 04 00 15 00 15 01 02 00 00 91 78
120
APDU: (9):  a0 a4 00 00 02 6f 38 9f 0f
121
APDU: (22):  a0 c0 00 00 0f 00 00 00 09 6f 38 04 00 15 00 55 01 02 00 00 91 78
122
APDU: (16):  a0 b0 00 00 09 ff 3f ff ff 00 00 3f 03 00 91 78
123
APDU: (9):  a0 a4 00 00 02 6f ad 9f 0f
124
APDU: (8):  a0 b0 00 00 01 00 91 78
125
APDU: (9):  a0 a4 00 00 02 6f 07 9f 0f
126
APDU: (16):  a0 b0 00 00 09 08 49 06 20 11 49 00 11 06 91 78
127
APDU: (9):  a0 a4 00 00 02 6f 7e 9f 0f
128
APDU: (18):  a0 b0 00 00 0b ff ff ff ff 64 f0 00 ff fe 00 03 91 78
129
APDU: (9):  a0 a4 00 00 02 6f 78 9f 0f
130
APDU: (9):  a0 b0 00 00 02 00 01 91 78
131
APDU: (9):  a0 a4 00 00 02 6f 74 9f 0f
132 2 laforge
APDU: (23):  a0 b0 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 91 78
133
APDU: (9):  a0 a4 00 00 02 6f 20 9f 0f
134
APDU: (16):  a0 b0 00 00 09 ff ff ff ff ff ff ff ff 07 91 78
135
APDU: (9):  a0 a4 00 00 02 6f 30 9f 0f
136 1 laforge
APDU: (22):  a0 c0 00 00 0f 00 00 00 f0 6f 30 04 00 11 00 55 01 02 00 00 91 78
137
}}}
138
139
== Wireshark integration ==
140
141 6 tsaitgaist
There is an experimental patch, also part of the simtrace.git package.  You will have to apply this against the latest
142 1 laforge
[wiki:wireshark] developer version.
143
144
[[Image(wireshark-sim.png)]]
145
146
Protocol parsing is far from being complete, patches are always welcome!
147 31 laforge
148
== Contact / Mailing List ==
149
150
For any development or usage related questions, there is a mailinglist [mailto:simtrace@lists.osmocom.org], you can subscribe/unsubscribe to it at http://lists.osmocom.org/mailman/listinfo/simtrace and read the archives at http://lists.osmocom.org/pipermail/simtrace/
151
152
Please kindly observe our [http://openbsc.osmocom.org/trac/wiki/MailingListRules Mailing List Rules]
Add picture from clipboard (Maximum size: 48.8 MB)