Project

General

Profile

SIMtrace » History » Version 37

tsaitgaist, 02/19/2016 10:48 PM
udp sink

1 1 laforge
[[PageOutline]]
2 1 laforge
= Osmocom SIMtrace =
3 1 laforge
4 1 laforge
Osmocom SIMtrace is a software and hardware system for passively tracing SIM-ME communication between the SIM card and the mobile phone.
5 1 laforge
6 18 laforge
It looks a bit like this:
7 18 laforge
{{{
8 18 laforge
#!graphviz
9 18 laforge
digraph G{
10 18 laforge
  //rankdir = LR;
11 18 laforge
  Phone -> SIMtrace [label = "Flexi-PCB cable"];
12 18 laforge
  SIMtrace -> SIM;
13 18 laforge
  SIMtrace -> PC [label = "USB cable"];
14 1 laforge
15 18 laforge
  SIMtrace [ label = "SIMtrace hardware" ];
16 18 laforge
}
17 18 laforge
}}}
18 18 laforge
19 29 laforge
When connected to a phone, it looks like this:
20 29 laforge
21 29 laforge
22 30 tsaitgaist
[[Image(simtrace_and_phone.jpg, align=center,50%)]]
23 33 zecke2
[[Image(simtrace_functions.png, align=right,33%)]]
24 29 laforge
25 18 laforge
It works by utilizing the T=0 capable USART of the USB-attached AT91SAM7 microcontroller.
26 18 laforge
27 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.
28 1 laforge
The received bytes are sent via USB to the PC, where a program called {{{simtrace}}} on the PC gathers data from the USB device,
29 1 laforge
parses the APDUs and forwards them via [wiki:GSMTAP] to the [wiki:wireshark] protocol analyzer.
30 1 laforge
31 1 laforge
== Features ==
32 1 laforge
 * Completely passive scanner
33 17 dw
 * RST and ATR detection
34 1 laforge
 * Auto-bauding with PPS / PTS support
35 1 laforge
 * Segmentation of APDUs
36 32 tsaitgaist
37 1 laforge
38 1 laforge
== TODO ==
39 1 laforge
 * Check for parity errors
40 1 laforge
 * Verify TCK / PCK check-bytes
41 31 laforge
 * Implement MITM
42 1 laforge
43 1 laforge
== Hardware ==
44 17 dw
45 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.
46 1 laforge
47 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.
48 31 laforge
49 31 laforge
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
50 31 laforge
51 27 zecke2
More details are available at [wiki:SIMtrace/Hardware]
52 4 laforge
53 1 laforge
== Firmware ==
54 1 laforge
55 28 zecke2
The firmware for the AT91SAM7S device was written by reusing a lot of the code for the [http://www.openpcd.org/ OpenPCD]
56 28 zecke2
RFID reader.  Details are available at [wiki:SIMtrace/Firmware].
57 24 tsaitgaist
58 1 laforge
59 5 laforge
== Host PC Software ==
60 5 laforge
61 6 tsaitgaist
The {{{simtrace}}} program is part of the git://git.osmocom.org/simtrace.git repository. It will bind to the USB device
62 5 laforge
and send GSMTAP frames using UDP/IPv4 to localhost:4729.
63 6 tsaitgaist
64 14 tsaitgaist
=== Preconditions ===
65 1 laforge
66 14 tsaitgaist
[wiki:libosmocore] and headers (simtrace_usb.h) from the firmware.
67 14 tsaitgaist
68 14 tsaitgaist
additional packages :
69 6 tsaitgaist
{{{
70 26 tsaitgaist
sudo apt-get install libusb-1.0-0-dev
71 7 tsaitgaist
}}}
72 1 laforge
73 6 tsaitgaist
=== Compiling it ===
74 6 tsaitgaist
75 1 laforge
{{{
76 14 tsaitgaist
git clone git://git.osmocom.org/simtrace.git
77 21 tsaitgaist
cd simtrace/host/
78 6 tsaitgaist
make
79 6 tsaitgaist
}}}
80 6 tsaitgaist
81 35 tsaitgaist
=== Accessing it ===
82 35 tsaitgaist
83 35 tsaitgaist
Add udev rules so to be able to use simtrace and access the device as non-root user (only need to be in the osmocom group)
84 35 tsaitgaist
85 35 tsaitgaist
{{{
86 35 tsaitgaist
sudo groupadd osmocom
87 35 tsaitgaist
sudo adduser $USERNAME osmocom
88 35 tsaitgaist
sudo tee /etc/udev/rules.d/10-osmocom.rules << EOF
89 35 tsaitgaist
# to use, install this file in /etc/udev/rules.d as 10-osmocom.rules
90 35 tsaitgaist
# rule to grant read/write access on SIMtrace to group named osmocom.
91 35 tsaitgaist
ACTION=="add", BUS=="usb", SYSFS{idVendor}=="16c0", SYSFS{idProduct}=="0762", GROUP:="osmocom", MODE:="0660"
92 35 tsaitgaist
EOF
93 35 tsaitgaist
sudo service udev reload
94 35 tsaitgaist
}}}
95 35 tsaitgaist
96 35 tsaitgaist
you must log out and back in so to take effect.
97 35 tsaitgaist
98 6 tsaitgaist
=== Using it ===
99 6 tsaitgaist
100 6 tsaitgaist
Simply start '''simtrace'''.
101 13 tsaitgaist
It will send the GSMTAP frames to UDP/IPv4 localhost:4729.
102 1 laforge
103 1 laforge
It will also print hexdumps of the frames to the console, looking like this:
104 6 tsaitgaist
{{{
105 1 laforge
sudo ./simtrace
106 1 laforge
APDU: (9):  a0 a4 00 00 02 6f 07 9f 0f
107 1 laforge
APDU: (22):  a0 c0 00 00 0f 00 00 00 09 6f 07 04 00 15 00 15 01 02 00 00 91 78
108 1 laforge
APDU: (9):  a0 a4 00 00 02 6f 38 9f 0f
109 1 laforge
APDU: (22):  a0 c0 00 00 0f 00 00 00 09 6f 38 04 00 15 00 55 01 02 00 00 91 78
110 1 laforge
APDU: (16):  a0 b0 00 00 09 ff 3f ff ff 00 00 3f 03 00 91 78
111 1 laforge
APDU: (9):  a0 a4 00 00 02 6f ad 9f 0f
112 1 laforge
APDU: (8):  a0 b0 00 00 01 00 91 78
113 1 laforge
APDU: (9):  a0 a4 00 00 02 6f 07 9f 0f
114 1 laforge
APDU: (16):  a0 b0 00 00 09 08 49 06 20 11 49 00 11 06 91 78
115 1 laforge
APDU: (9):  a0 a4 00 00 02 6f 7e 9f 0f
116 1 laforge
APDU: (18):  a0 b0 00 00 0b ff ff ff ff 64 f0 00 ff fe 00 03 91 78
117 1 laforge
APDU: (9):  a0 a4 00 00 02 6f 78 9f 0f
118 1 laforge
APDU: (9):  a0 b0 00 00 02 00 01 91 78
119 1 laforge
APDU: (9):  a0 a4 00 00 02 6f 74 9f 0f
120 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
121 2 laforge
APDU: (9):  a0 a4 00 00 02 6f 20 9f 0f
122 2 laforge
APDU: (16):  a0 b0 00 00 09 ff ff ff ff ff ff ff ff 07 91 78
123 2 laforge
APDU: (9):  a0 a4 00 00 02 6f 30 9f 0f
124 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
125 1 laforge
}}}
126 1 laforge
127 1 laforge
== Wireshark integration ==
128 1 laforge
129 34 tsaitgaist
There is an experimental patch, also part of the simtrace.git package.  It is also included in the [wiki:wireshark] developer version (since wireshark 1.7.1).
130 34 tsaitgaist
131 34 tsaitgaist
To see the APDUs in wireshark:
132 37 tsaitgaist
 * on localhost SIMtrace automatically opens a UDP sink locally, no need to do any anything
133 37 tsaitgaist
 * to get the data on another machine
134 37 tsaitgaist
  * start an UDP sink for GSMTAP on the other machine (do not use netcat as it "connects" back)
135 34 tsaitgaist
{{{
136 37 tsaitgaist
socat -u udp-recv:4729 /dev/null
137 34 tsaitgaist
}}}
138 37 tsaitgaist
  * tell SIMtrace on which machine to forward
139 34 tsaitgaist
{{{
140 37 tsaitgaist
./simtrace -i 192.168.0.1
141 34 tsaitgaist
}}}
142 1 laforge
143 1 laforge
[[Image(wireshark-sim.png)]]
144 1 laforge
145 1 laforge
Protocol parsing is far from being complete, patches are always welcome!
146 31 laforge
147 31 laforge
== Contact / Mailing List ==
148 31 laforge
149 31 laforge
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/
150 31 laforge
151 31 laforge
Please kindly observe our [http://openbsc.osmocom.org/trac/wiki/MailingListRules Mailing List Rules]
Add picture from clipboard (Maximum size: 48.8 MB)