<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Opensource GSM adventures (among other things)</title>
	<atom:link href="http://tetalab.org/pg/feed/" rel="self" type="application/rss+xml" />
	<link>http://tetalab.org/pg</link>
	<description>Un blog utilisant Tetalab</description>
	<lastBuildDate>Mon, 09 Nov 2009 02:36:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting pcap files from openbts</title>
		<link>http://tetalab.org/pg/2009/11/09/getting-pcap-files-from-openbts/</link>
		<comments>http://tetalab.org/pg/2009/11/09/getting-pcap-files-from-openbts/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 02:29:21 +0000</pubDate>
		<dc:creator>pong</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false">http://tetalab.org/pg/?p=49</guid>
		<description><![CDATA[Just few lines to get pcap files from openbts, at now it&#8217;s just a little python script but if i feel not lazy i would directly add method into Openbts  sending  layer2 packets in a tap interface to grab it in realtime. It currently uses Airprobe&#8217;s pcap dissectors so it&#8217;s downlink only.  Just for fun, [...]]]></description>
			<content:encoded><![CDATA[<p>Just few lines to get pcap files from openbts, at now it&#8217;s just a little python script but if i feel not lazy i would directly add method into Openbts  sending  layer2 packets in a tap interface to grab it in realtime. It currently uses Airprobe&#8217;s pcap dissectors so it&#8217;s downlink only.  Just for fun, here is a screenshot.</p>
<p><a href="http://tetalab.org/pg/files/2009/11/wireshark21.png"><img class="aligncenter size-full wp-image-64" src="http://tetalab.org/pg/files/2009/11/wireshark21.png" alt="wireshark2" width="800" height="437" /></a></p>
<p style="text-align: center">
]]></content:encoded>
			<wfw:commentRss>http://tetalab.org/pg/2009/11/09/getting-pcap-files-from-openbts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An overview of the Subscriber Identity Module file system ( Part 1. )</title>
		<link>http://tetalab.org/pg/2009/11/08/an-overview-of-the-subscriber-identity-module-file-system-part-1/</link>
		<comments>http://tetalab.org/pg/2009/11/08/an-overview-of-the-subscriber-identity-module-file-system-part-1/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 04:56:21 +0000</pubDate>
		<dc:creator>pong</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false">http://tetalab.org/pg/?p=6</guid>
		<description><![CDATA[The  Suscriber Identity Module (aka SIM for shorter) is nothing more but a smartcard with specific files and directories on it. It is defined in GSM 11.11 or ETS 300 977 in the ETSI denomination. As a smartcard, the way to communicate with it goes thru ADPU. You can either use a card reader or [...]]]></description>
			<content:encoded><![CDATA[<p>The  Suscriber Identity Module (aka SIM for shorter) is nothing more but a smartcard with specific files and directories on it. It is defined in GSM 11.11 or ETS 300 977 in the <a href="http://www.etsi.org">ETSI</a> denomination. As a smartcard, the way to communicate with it goes thru <a href="http://en.wikipedia.org/wiki/APDU">ADPU</a>. You can either use a card reader or ( less in fact ) directly use a gsm modem to issue commands.</p>
<p>The standard command set for GSM modem is defined in   &#8220;AT Command set for GSM Mobile Equipment (ME) &#8221; (TS 07.07) or just ETS 100 916. It defines a lot of command to interecact with the network or the simcard. As I just want explore the filesystem of my SIM, we&#8217;ll just use a command to issue raw adpu directly.</p>
<p><span id="more-6"></span></p>
<pre>8.17 Generic SIM access +CSIM

     Command               Possible response(s)
+CSIM=&lt;length&gt;,&lt;command&gt; +CSIM: &lt;length&gt;,&lt;response&gt;
                         +CME ERROR: &lt;err&gt;
+CSIM=?

Description
Set command transmits to the ME the &lt;command&gt; it then shall send as it is to the SIM. In the same manner the SIM
&lt;response&gt; shall be sent back by the ME to the TA as it is. Refer subclause 9.2 for &lt;err&gt; values.
This command allows a direct control of the SIM by an distant application on the TE. The TE shall then take care of
processing SIM information within the frame specified by GSM.</pre>
<p>Using +CSIM command, you can directly issue the ADPU defined in GSM 11.11. It basically contains the following subset.</p>
<pre>SELECT             'A4'      '00'         '00'   '02' S/R
STATUS             'F2'      '00'         '00'   lgth  R
READ BINARY        'B0'  offset high  offset low lgth  R
UPDATE BINARY     'D6'   offset high  offset low lgth  S
READ RECORD        'B2'   rec No.       mode     lgth  R
UPDATE RECORD     'DC'    rec No.       mode     lgth  S
SEEK               'A2'      '00'    type/mode   lgth S/R
INCREASE           '32'      '00'         '00'   '03' S/R
VERIFY CHV         '20'      '00'     CHV No.    '08'  S
CHANGE CHV         '24'      '00'     CHV No.    '10'  S
DISABLE CHV        '26'      '00'         '01'   '08'  S
ENABLE CHV         '28'      '00'         '01'   '08'  S
UNBLOCK CHV       '2C'       '00'     see note   '10'  S
INVALIDATE         '04'      '00'         '00'   '00'  -
REHABILITATE       '44'      '00'         '00'   '00'  -
RUN GSM ALGORITHM  '88'      '00'         '00'   '10' S/R
SLEEP             'FA'       '00'         '00'   '00'  -
GET RESPONSE      'C0'       '00'         '00'   lgth  R
TERMINAL PROFILE    '10'     '00'         '00'   lgth  S
ENVELOPE          '#C2'       '00'         '00'   lgth S/R
FETCH              '12'      '00'         '00'   lgth  R
TERMINAL RESPONSE  '14'      '00'         '00'   lgth  S</pre>
<p>As we&#8217;ll just  have a look in the filesystem of the SIM, we&#8217;ll just focus on the SELECT, READ BINARY, READ RECORD and GET RESPONSE command. Just to summarize the other are either dedicated to write to the sim (UPDATE family),related to  the card holder (CHV family), we&#8217;ll discuss on the RUN GSM ALGORITHM and the Sim Application Toolkit command (ENVELOPE, FETCH, TERMINAL PROFILE&#8230;) later.</p>
<p>Here is an overview of the filesystem that is implemented in all SIM card</p>
<pre><img class="size-medium wp-image-18 aligncenter" src="http://tetalab.org/pg/files/2009/11/simfs-270x300.gif" alt="simfs" width="532" height="300" /></pre>
<p>Basically, all file belong to the Master File (you can think about / on unix) there are mainly 2 subsets : DF (dedicated file ) a kind of directory which contains EF (elementary file) where datas are stored.</p>
<p>There are 3 kinds of EF :</p>
<ul>
<li>Transparent EF : binary file, you mainly access its contain by specify its relative address (offset) the total length is specified in the header. The first byte of a transparent EF has the relative address &#8216;00 00&#8242;.</li>
<li>Linear fixed EF :  consists of a sequence of records all having the same (fixed) length. It is not possible to have more than 255 records in a file of this type, and each record cannot be greater than 255 bytes. The first record is record number 1.</li>
<li>Cyclic EF  : Cyclic files are used for storing records in chronological order. When all records have been used for storage, then the next storage of data shall overwrite the oldest information. An EF with a cyclic structure consists of a fixed number of records with the same (fixed) length.</li>
</ul>
<p>Just a word on Access Right, as i play with deactivated simcard issued by an operator, i can only grant myself to CHV1 or CHV2 level not ADM (no root dance this night :p). This mean that some file may not be updated. For example EFIMSI (which hold the <a href="http://en.wikipedia.org/wiki/International_Mobile_Subscriber_Identity">IMSI</a> number) has the following access condition :</p>
<pre>10.3.2      EFIMSI (IMSI)
This EF contains the International Mobile Subscriber Identity (IMSI).
                   Identifier: '6F07'            Structure: transparent             Mandatory
                        File size: 9 bytes                        Update activity: low
                   Access Conditions:
                    READ                        CHV1
                    UPDATE                      ADM
                    INVALIDATE                  ADM
                    REHABILITATE                CHV1
                   Bytes                        Description                 M/O          Length
                   1          length of IMSI                                M           1 byte
                   2-9           IMSI                                       M           8 bytes</pre>
<p>so when you&#8217;re granted to CHV1 (ie you entered your PIN code) you can read its value but neither change it nor deactivate it.</p>
<p>Despite the fact you can simply get its value by issueing the AT+CIMI command, here is the process to access it with adpu .</p>
<p>1 Select the Master File (3F00)</p>
<p>2 Select DF_GSM (7F20)</p>
<p>3 Select EF_IMSI (6F07)</p>
<p>4 Read  9 bytes with READ BINARY</p>
<pre> root@ret:~# socat - file:/dev/ttyUSB0,crtscts,crnl
 AT+CSIM=14,A0A40000023F00
 +CSIM: 4,"9F22"
 OK
 AT+CSIM=14,A0A40000027F20
 +CSIM: 4,"9F22"
 OK
 AT+CSIM=14,A0A40000026F07
 +CSIM: 4,"9F0F"
 OK
 AT+CSIM=10,A0B0000009
 +CSIM: 22,"08298002xxxxx49039000"
 OK</pre>
<p>the last 4 bytes are the return value of the command &#8216;9000&#8242; signifing success . you may notice that on SELECT opereation, the return value is 9FXX which mean sucess whth XX bytes of response data. you can pull the response with GET RESPONSE command &#8216;C0&#8242;</p>
<p>here there are :</p>
<pre> AT+CSIM=14,A0A40000026F07
 +CSIM: 4,"9F0F"
 OK
 AT+CSIM=10,A0C000000F
 +CSIM: 34,"000000096F07040015F515010200009000"
 OK</pre>
<p>which is decoded as :</p>
<pre>0000 0009 6F07 04 00 15F515 01 02 0000 9000
|    |    |    |  |  |      |   | |    |_status
|    |    |    |  |  |      |   | |
|    |    |    |  |  |      |   | structure
|    |    |    |  |  |      |  len of data following
|    |    |    |  |  |    status
|    |    |    |  | access
|    |    |    |
|    |    | file type
|    |  file id  
|   size
RFU

file type 04 = EF
structure 00 = transparent
the file access is coded as follow READ|UPDATE INCREASE|RFU REHABILITATE|INVALIDATE
knowning that '0' means always , '1'  CHV1 'F' never and '4'...'E' ADM.

In case of DF or MF the response is slightly different. 

AT+CSIM=14,A0A40000027F10
+CSIM: 4,"9F22"
OK
AT+CSIM=10,A0C0000022
+CSIM: 72,"000002407F1002001F55FF01151100050500838A838A008A000000000000000000009000"
OK
0000 0240 7F20 02 000F55FF01 15 11 00 19 05 00 83 8A 83 8A 00 8A00 000000000000000000 9000
|    |    |    |  |          |  |  |  |  |  |  |  |  |  |  |  |                       |       
|    |    |    |  |          |  |  |  |  |  |  |  |  |  |  |  |                       return value      
|    |    |    |  |          |  |  |  |  |  |  |  |  |  |  |  |                              
|    |    |    |  |          |  |  |  |  |  |  |  |  |  |  |  reserved for admin                                
|    |    |    |  |          |  |  |  |  |  |  |  |  |  |  rfu                                  
|    |    |    |  |          |  |  |  |  |  |  |  |  |   unblock CHV2 status                                   
|    |    |    |  |          |  |  |  |  |  |  |  |  CHV2 status                                      
|    |    |    |  |          |  |  |  |  |  |  |  unblock CHv1 status                                        
|    |    |    |  |          |  |  |  |  |  |  CHV status                                          
|    |    |    |  |          |  |  |  |  |  RFU                                            
|    |    |    |  |          |  |  |  |  number of CHV and admin code                                              
|    |    |    |  |          |  |  |  number of EF direct child of current dir                                               
|    |    |    |  |          |  |  number of DF direct child of current dir                                                
|    |    |    |  |          |  file caracteristic                                                    
|    |    |    |  |        len of data                                                       
|    |    |    |  RFU                                                                
|    |    |   file type                                                                  
|    |    file ID                                                                      
|    total amount NOT allocated                                                                          
RFU</pre>
<p>Well that&#8217;s all for this night in an UNIX world we would have learn 3 fondamentals command : cd, ls and cat <img src='http://tetalab.org/pg/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I would write a crappy python script to gather such infos, it&#8217;s stacked on my todolist, so it may be popped (or not).</p>
<p>On a next post i&#8217;ll have a deeper look on data contained on the sim.</p>
]]></content:encoded>
			<wfw:commentRss>http://tetalab.org/pg/2009/11/08/an-overview-of-the-subscriber-identity-module-file-system-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro</title>
		<link>http://tetalab.org/pg/2009/11/07/bonjour-tout-le-monde/</link>
		<comments>http://tetalab.org/pg/2009/11/07/bonjour-tout-le-monde/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 10:52:42 +0000</pubDate>
		<dc:creator>pong</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[As every walk has his first step, here is the first post on this blog. The title is self explanatory, I&#8217;ll focus mainly on the recents development of opensourcing GSM.
The recent releases of Openbts, OpenBSC and the Airprobe projects are openning new area of technological study. More than the political considerations of free the more [...]]]></description>
			<content:encoded><![CDATA[<p>As every walk has his first step, here is the first post on this blog. The title is self explanatory, I&#8217;ll focus mainly on the recents development of opensourcing GSM.</p>
<p>The recent releases of<a title="OpenBTS" href="http://gnuradio.org/trac/wiki/OpenBTS"> Openbts</a>, <a title="OPenBSC" href="http://openbsc.gnumonks.org/trac/">OpenBSC</a> and the <a title="Airprobe" href="https://svn.berlin.ccc.de/projects/airprobe/">Airprobe</a> projects are openning new area of technological study. More than the political considerations of free the more than widely spreaded GSM technology, it&#8217;s just an amazing playground of protocols and devices.</p>
<p>Among the networking parts, there&#8217;s also an effort on opening the handset, as demonstrated by <a title="Openmoko" href="http://wiki.openmoko.org/wiki/Main_Page">Openmoko</a> and Android platform. I&#8217;ll sometimes play with these &#8220;toys&#8221; that are most visible part of the &#8220;opensource mobile movment&#8221;.</p>
<p>PS: I&#8217;m not an engineer of these topics, just another geek hobbyist, so I may omit things or do some mistakes. Sorry in advance.</p>
]]></content:encoded>
			<wfw:commentRss>http://tetalab.org/pg/2009/11/07/bonjour-tout-le-monde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>