<?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>Tyler Oderkirk&#039;s Blog &#187; Table of Contents</title>
	<atom:link href="http://unsyncopated.com/blog/index.php/category/plugins-used/table-of-contents/feed/" rel="self" type="application/rss+xml" />
	<link>http://unsyncopated.com/blog</link>
	<description>&#34;Scared money don&#039;t[sic] make money&#34;</description>
	<lastBuildDate>Thu, 27 Jan 2011 05:02:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>libhasp: Repurposing a copy-protection dongle for general-purpose data storage</title>
		<link>http://unsyncopated.com/blog/index.php/2010/03/12/libhasp-repurposing-a-copy-protection-dongle-for-general-purpose-data-storage/</link>
		<comments>http://unsyncopated.com/blog/index.php/2010/03/12/libhasp-repurposing-a-copy-protection-dongle-for-general-purpose-data-storage/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 15:07:29 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Footnotes]]></category>
		<category><![CDATA[Reverse engineering]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Table of Contents]]></category>

		<guid isPermaLink="false">http://unsyncopated.com/blog/index.php/2010/03/12/libhasp-repurposing-a-copy-protection-dongle-for-general-purpose-data-storage/</guid>
		<description><![CDATA[Way back in 2004, I spied an offer in Circuit Cellar magazine for a free evaluation kit from Aladdin Knowledge Systems (AKS), manufacturer of copy protection tokens. These are the little gadgets that you often need to plug in to your computer to prove that you &#8221;really&#8221; own the particularly expensive application you&#8217;re trying to [...]]]></description>
			<content:encoded><![CDATA[						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/2420667301"><img class="flickr small" title="HASP HL Dongle" alt="HASP HL Dongle" src="http://farm3.static.flickr.com/2378/2420667301_d57374a9a8_m.jpg" /></a></div>
					Way back in 2004, I spied an offer in Circuit Cellar magazine for a free evaluation kit from Aladdin Knowledge Systems (AKS), manufacturer of copy protection tokens. These are the little gadgets that you often need to plug in to your computer to prove that you &#8221;really&#8221; own the <a href="http://usa.autodesk.com/adsk/servlet/pc/index?siteID=123112&amp;id=13577897">particularly expensive application</a> you&#8217;re trying to run.</p>
<p><div class='toc wptoc'>
<h2>Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#The_goods">The goods</a>
	</li>
	<li>
		<a href="#The_hack">The hack</a>
	</li>
	<li>
		<a href="#The_blob">The blob</a>
	</li>
	<li>
		<a href="#What_Bob_and_I_learned">What Bob and I learned</a>
	</li>
	<li>
		<a href="#Further_reading">Further reading</a>
	</li>
</ol>
</ol>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<span id="The_goods"><h3>The goods</h3></span>
<p>Anyways, the offer boasted&#8230;</p>
<ul>
<li>A <a href="http://www.aladdin.com/hasp/protection-keys-benefits-models.aspx">HASP HL &#8220;Time&#8221; dongle</a> with built-in AES, host-accessible 4kB EEPROM, and &#8220;tamperproof&#8221; real-time clock (RTC).</li>
<li>A cross-platform SDK with libraries and example code in C and a handful of other languages.</li>
<li>Printed API documentation.</li>
</ul>
<p>After pestering them with a few emails over the course of a week, AKS sent me the kit and it arrived just in time to distract me from the first round of exams during my Senior year `X|`</p>
<p>The SDK includes a demo application which can&#8230;</p>
<ul>
<li>Read/write the token&#8217;s EEPROM.</li>
<li>Ask the token to encrypt/decrypt data with its key.</li>
<li>Read the RTC.</li>
</ul>
<span id="The_hack"><h3>The hack</h3></span>
<p>To prevent its use in a commercial setting, AKS hard-codes the encryption keys on its evaluation kit tokens.</p>
<p>So, I set out to make use of one of the &#8221;un-crippled&#8221; features: the on-token EEPROM. Claiming 1,000,000+ read/write cycles, it seems like a nice place to store &#8221;my own&#8221; encryption keys or perhaps store two-factor authentication data.</p>
<p>						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/4426568909"><img class="flickr small" title="FUSE architecture" alt="FUSE architecture" src="http://farm3.static.flickr.com/2705/4426568909_5df292d6df_m.jpg" /></a></div>
					At the time, Miklos Szeredi had just <a href="http://marc.info/?l=linux-fsdevel&amp;m=110099238632141&amp;w=2">released his Filesystem-in-userspace (FUSE) framework</a> thus extending the Real Ultimate Power(tm) of the *NIX &#8220;everything-is-a-file&#8221; paradigm to mere mortals<sup>1</sup>.</p>
<p>I hacked up the demo application to implement a bare-bones FUSE filesystem &#8211; one which provides a single file, `hello`, backed by the token&#8217;s EEPROM. I call the result &#8220;<a href="http://unsyncopated.com/hg/haspfuse/file/tip/haspfuse.c#l1">haspfuse</a>&#8220;.</p>
<p>Here are its limitations. See <a href="http://unsyncopated.com/hg/haspfuse/">the haspfuse code</a> for details.</p>
<ul>
<li>The filesystem only supports a single file. This wouldn&#8217;t be too bad if you were to stack a <a href="http://code.google.com/p/fuse-zip/">fuse-zip</a> or <a href="http://en.wikipedia.org/wiki/Archivemount">archivemount</a>-based tarball-backed filesystem on top. Don&#8217;t even think about JFFS(2) or ext2 &#8211; they each require more than 4kB for a single block.</li>
<li>The single file has a fixed size of 3584.</li>
<li>No operation besides: `getattr`, `readdir`, `open`, `read`, `write`, `truncate`, and `chmod` is supported.</li>
<li>The filesystem probably isn&#8217;t &#8220;eject-safe&#8221;. See FUSE&#8217;s `direct_io` for a starting point.</li>
</ul>
<span id="The_blob"><h3>The blob</h3></span>
<p>Additionally, a proprietary blob &#8220;driver&#8221; named `aksusbd` and a static library from the SDK named `libhasp_linux.a` are required. I had trouble with version 3.5.0 so I included v1.8.1 with the haspfuse code.</p>
<p>`aksusbd` is a userspace driver that employs usbfs to interact with the token. Unfortunately, the deprecation of usbfs is <a href="http://www.alteraforum.com/forum/showthread.php?t=5893">apparently now complete with the release of the 2.6.31.20 Ubuntu kernel</a>. This means that <a href="https://help.ubuntu.com/community/VirtualBox/USB">the old standby methods for re-enabling it</a> no longer work.</p>
<p>You&#8217;ll need to use a custom kernel with usbfs support, or better yet, develop an open source driver for these tokens!</p>
<p>The latter approach would be especially helpful because my friend Bob claims that &#8220;`aksusbd` is setuid root and full of vulnerabilities&#8221;. But that&#8217;s another story&#8230;</p>
<p>Be aware that various AKS licenses and draconian US laws may prohibit you from reverse engineering `akusbd`.</p>
<span id="What_Bob_and_I_learned"><h3>What Bob and I learned</h3></span>
<ul>
<li>Filesystem design for severely space-constrained storage devices.</li>
<li>How to build a virtual filesystem using the FUSE C API.</li>
<li>Methods for rebuilding ELF symbol tables and the idiosyncrasies that result when the binary is dynamically-linked and uses <a href="http://en.wikipedia.org/wiki/Native_POSIX_Thread_Library">the Native POSIX Thread Library (NTPL)</a>.</li>
<li>The software tools available for USB protocol reversing.</li>
<li>The myriad sorts of implementation failures that lead to &#8220;cracked&#8221; hardware tokens.</li>
</ul>
<span id="Further_reading"><h3>Further reading</h3></span>
<ul>
<li><a href="http://www.etokenonlinux.org/et/">etokenonlinux.org</a> &#8211; A great resource for using other AKS tokens to do two-factor authentication, one-time password storage, and encrypted partition unlocking <em>The Right Way™</em>. Provided by Cornelius Koelbel.</li>
<li>Guy-Gregoire Leclercq&#8217;s <a href="http://www.stacksegment.net/wiki/index.php/Aladdin_eToken_64k">detailed notes on using the eToken 64k with OpenCT/OpenSC on Debian</a>.</li>
<li>Andy Smith&#8217;s rebuilt, <a href="http://andys.org.uk/bits/2009/12/23/openssh-and-opensc-for-debian-and-ubuntu/">OpenSC-enabled, openssh-client and how to store SSH keys</a> on an eToken with it.</li>
</ul>
<ol class="footnotes">
<li id="footnote_0_542" class="footnote">Well, mortals too squeamish to run <a href="http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs">Plan 9</a> as their every-day operating system ;]</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://unsyncopated.com/blog/index.php/2010/03/12/libhasp-repurposing-a-copy-protection-dongle-for-general-purpose-data-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creds101 v0.1 Release</title>
		<link>http://unsyncopated.com/blog/index.php/2010/02/20/creds101-v0-1-release/</link>
		<comments>http://unsyncopated.com/blog/index.php/2010/02/20/creds101-v0-1-release/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 14:38:45 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Python programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Table of Contents]]></category>

		<guid isPermaLink="false">http://unsyncopated.com/blog/index.php/2010/02/20/creds101-v0-1-release/</guid>
		<description><![CDATA[I&#8217;m happy to announce the first release of a credentials (e.g. &#8220;usernames and passwords&#8221;) management system that I&#8217;ve been working on for the past few weeks. It&#8217;s called Creds101 and this excerpt from the documentation gives some more detail: Creds101 has 2 parts: Software that you run on your computer (the &#8220;host&#8221;) to send commands [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce the first release of a credentials (e.g. &#8220;usernames and passwords&#8221;) management system that I&#8217;ve been working on for the past few weeks. It&#8217;s called Creds101 and this excerpt from <a href="http://unsyncopated.com/corral/creds101-0.1/index.html">the documentation</a> gives some more detail:</p>
<hr />Creds101 has 2 parts:</p>
<ol>
<li>Software that you run on your computer (the &#8220;host&#8221;) to send commands to&#8230;</li>
<li>A USB &#8220;token&#8221; which A) encrypts and stores credentials from the host and B) decrypts and displays them on its LCD.</li>
</ol>
<p>Creds101 serves the same purpose as traditional &#8220;password database&#8221; solutions but it is different in two fundamental ways:</p>
<ol>
<li>Credentials aren&#8217;t stored on the user&#8217;s computer &#8211; they&#8217;re stored on a USB &#8220;token&#8221;.</li>
<li>Sensitive credential data <em>cannot be read by malicious software on the user&#8217;s computer</em> &#8211; credentials can only be viewed on the token&#8217;s &#8220;trusted LCD display&#8221;.</li>
</ol>
<hr />
<span id="Contents"><h3>Contents</h3></span>
<div class='toc wptoc'>
<h2>Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Contents">Contents</a>
	</li>
	<li>
		<a href="#Whats_in_v0.1">What's in v0.1?</a>
	</li>
	<li>
		<a href="#Whats_next">What's next?</a>
	</li>
	<li>
		<a href="#What_I_learned">What I learned</a>
	</li>
	<li>
		<a href="#Download__Quickstart">Download / Quickstart</a>
	</li>
	<li>
		<a href="#Further_reading">Further reading</a>
	</li>
</ol>
</ol>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<span id="What8217s_in_v0.1"><h3>What&#8217;s in v0.1?</h3></span>
<ul>
<li><a href="http://www.methods.co.nz/asciidoc/">AsciiDoc</a>-based documentation including the &#8220;host-&gt;token&#8221; serial command protocol and data-flow diagrams illustrating how credentials are encrypted, stored, decrypted, and displayed by the token.</li>
<li>A <a href="http://docs.python.org/library/unittest.html">unittest</a> test suite which exercises each of the commands accepted by the token. Install <a href="http://twistedmatrix.com/trac/">Twisted</a> and try
<pre class="brush: bash;">PYTHONPATH=src trial src/TestSimulatorToken.py</pre>
</li>
<li>A cross-platform &#8220;token administration&#8221; GUI for storing and retrieving credentials. Try
<pre class="brush: bash;">bin/creds101-admin-gui --use-simulator</pre>
<p>or see screenshot 1.						<div class="flickr-gallery image none"><a href="http://www.flickr.com/photos/55502932@N00/4373389528"><img class="flickr small" title="Screenshot 1 - GUIs" alt="Screenshot 1 - GUIs" src="http://farm5.static.flickr.com/4066/4373389528_7f97d950e4_m.jpg" /></a></div>
					</li>
<li>A command-line &#8220;token administration&#8221; interface. Try
<pre class="brush: bash;">bin/creds101 --help</pre>
</li>
<li>A &#8220;token simulator&#8221; that allows us to 1) develop tests 2) iron out token design issues <em>before</em> coding in C for an embedded platform. Try
<pre class="brush: bash;">bin/creds101-simulator --gui</pre>
<p>or see screenshot 1.</li>
<li>						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/4372493561"><img class="flickr small" title="Photo 2 - Desoldering flash part" alt="Photo 2 - Desoldering flash part" src="http://farm3.static.flickr.com/2709/4372493561_13955be0f6_m.jpg" /></a></div>
					The beginnings of the code for an <a href="http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove">Arduino</a>-based token. Take a look in `src/arduino`. This includes code for&#8230;
<ul>
<li>Receiving commands from the &#8220;host&#8221; via the Arduino&#8217;s FTDI serial-over-USB chip.</li>
<li>Reading and writing data to the 512 bytes of internal EEPROM or an attached SPI <a href="http://www.atmel.com/products/dataflash/default.asp">DataFlash</a> part. See photos 2 and 3.</li>
<li>Displaying text on a <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9394">SparkFun SerLCD</a> LCD module.</li>
<li>Encrypting and decrypting data with 128-bit AES.</li>
</ul>
</li>
</ul>
<span id="What8217s_next"><h3>What&#8217;s next?</h3></span>
<ul>
<li>						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/4373266740"><img class="flickr small" title="Photo 3 - New leads" alt="Photo 3 - New leads" src="http://farm3.static.flickr.com/2706/4373266740_32369563b4_m.jpg" /></a></div>
					Completing the Arduino token implementation so that we have something that&#8217;s suitable for everyday use.</li>
<li>Completing a thumbdrive-sized token implementation &#8211; the ideal form factor.</li>
<li>The smaller tasks that can be found in the `TODO` file.</li>
</ul>
<span id="What_I_learned"><h3>What I learned</h3></span>
<ul>
<li>How to create slick, source-based docs with the AsciiDoc tool suite. As much as I like MoinMoin markup, the wiki engine itself isn&#8217;t amenable to being invoked from a build automation tool.</li>
<li>GUI design with <a href="http://glade.gnome.org/">Glade</a>, a slick <a href="http://en.wikipedia.org/wiki/Rapid_application_development">RAD</a> tool used by many free software projects.</li>
<li>GUI interaction with <a href="http://www.pygtk.org/">PyGTK</a>. I wrote a well-behaved worker thread that runs alongside the GTK main loop for the token simulator component.</li>
<li>The theory and implementation of &#8220;Secret Sharing&#8221; schemes especially Shamir&#8217;s Secret Sharing Scheme (SSSS). We discarded SSSS in favor of the current &#8220;store-the-key-on-the-host, store-the-ciphertext-on-the-token&#8221; design.</li>
<li>A handful of Python skills&#8230;
<ul>
<li>Finding a script&#8217;s location <em>from within the script</em>. Handy for using `bin/foo -&gt; src/foo.py` symlinks in conjunction with external (e.g. Glade XML) resources.</li>
<li>Python&#8217;s built-in <a href="http://docs.python.org/library/xmlrpclib.html">XML-RPC</a> library. Reconciling UNIX socket semantics with thread semantics gave me fits before I switched to this IPC mechanism.</li>
<li>Steven Bethard&#8217;s superior <a href="http://code.google.com/p/argparse/">argparse</a> module which makes handling subcommands and required positional arguments a breeze compared with Python&#8217;s standard optparse module.</li>
</ul>
</li>
</ul>
<span id="Download__Quickstart"><h3>Download / Quickstart</h3></span>
<p>Creds101 is licensed under the GPL.</p>
<p>Here are the steps to grab the v0.1 source tarball from <a href="http://unsyncopated.com/hg/creds101/">the hgweb interface</a> and take the GUIs for a test drive!</p>
<pre class="brush: bash;">
$ wget http://unsyncopated.com/hg/creds101/archive/0.1.tar.gz
$ tar xzf 0.1.tar.gz
$ cd creds101-0.1
$ bin/creds101-simulator --gui &amp;           # launch the token simulator
$ bin/creds101-admin-gui --use-simulator &amp; # connect to the simulator
</pre>
<span id="Further_reading"><h3>Further reading</h3></span>
<p>You can see our design notes, plans, and a list of similar projects at <a href="https://www.unsyncopated.com/wiki/Creds101">the wiki page</a> but beware the outdated Secret Sharing content.</p>
<p>I&#8217;m accumulating all the research papers, datasheets, and application notes I&#8217;ve encountered during this project in <a href="http://unsyncopated.com/hg/creds101-research_materials/file/tip">a &#8220;research materials&#8221; repository</a>. You might find the contents useful if you&#8217;re trying to choose an AES implementation for an AVR microcontroller or if your project falls into one of these categories: &#8220;cryptographic co-processor&#8221;, &#8220;hardware security module&#8221;, &#8220;embedded secret secret sharing&#8221;, &#8220;ubiquitous/pervasive computer security&#8221;, or &#8220;tamper evidence/proof&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://unsyncopated.com/blog/index.php/2010/02/20/creds101-v0-1-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending data via cellular voice connections with Linux</title>
		<link>http://unsyncopated.com/blog/index.php/2009/11/19/sending-data-via-cellular-voice-connections-with-linux/</link>
		<comments>http://unsyncopated.com/blog/index.php/2009/11/19/sending-data-via-cellular-voice-connections-with-linux/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 10:45:03 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Footnotes]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shell programming]]></category>
		<category><![CDATA[Syntax highlighter]]></category>
		<category><![CDATA[Table of Contents]]></category>

		<guid isPermaLink="false">http://unsyncopated.com/blog/index.php/2009/11/20/sending-data-via-cellular-voice-connections-with-linux/</guid>
		<description><![CDATA[&#8220;A5/1 [the encryption scheme used in most cellular voice calls] has operated unchanged for the last 21 years but it has now reached its cryptographic end-of-life, engulfed by the march of Moore&#8217;s Law. However, the operational end-of-life of A5/1 may still be decades away as there are approximately 2 billion GSM subscribers, commanding about 80% of [...]]]></description>
			<content:encoded><![CDATA[<div>
<p style="padding-left: 30px;">&#8220;A5/1 [the encryption scheme used in most cellular voice calls] has operated unchanged for the last 21 years but it has now reached its cryptographic end-of-life, engulfed by the march of Moore&#8217;s Law. However, the operational end-of-life of A5/1 may still be decades away as there are approximately 2 billion GSM subscribers, commanding about 80% of the global mobile market. This would be a tough product recall indeed. A5/1 is well-positioned to become the NT of the mobile crypto world, and I see the makings of a long tail of GSM vulnerability.&#8221; - <a href="http://ch.linkedin.com/pub/luke-o-connor/1/bb6/152">Dr. Luke O&#8217;Connor</a> at <a href="http://lukenotricks.blogspot.com/2009/09/another-crack-at-open-rainbow-tables.html">NoTricks: Another crack at open Rainbow Tables for A5/1</a></p>
<div class='toc wptoc'>
<h2>Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Introduction">Introduction</a>
	</li>
	<li>
		<a href="#The_modem__Hardware_components">The modem / Hardware components</a>
	</li>
	<li>
		<a href="#Transmitting_audio_from_a_PC_to_a_cell_phone__Software_components">Transmitting audio from a PC to a cell phone / Software components</a>
	</li>
	<li>
		<a href="#Demonstration__OKCrypto_scripts">Demonstration / OKCrypto scripts</a>
	</li>
	<li>
		<a href="#Encryption">Encryption</a>
	</li>
	<li>
		<a href="#Further_work">Further work</a>
	</li>
	<li>
		<a href="#What_I_learned">What I learned</a>
	</li>
	<li>
		<a href="#Conclusion__Download">Conclusion / Download</a>
	</li>
	<li>
		<a href="#Further_reading">Further reading</a>
	</li>
</ol>
</ol>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<span id="Introduction"><h3>Introduction</h3></span>
<p>The ability to intercept and decrypt GSM cell phone conversations is now well within the reach of hobbyists.<sup>1</sup><sup>2</sup></p>
<p>My friend Scott and I were discussing this sobering fact one night and we began wondering if any systems exist which provide end-to-end encryption for this insecure link.</p>
<p>Sure, there are plenty of solutions for people with access to cellular dataconnections, but what can voice call participants use to foil eavesdroppers?</p>
<p>We didn&#8217;t find any low-cost systems so we decided to create our own. OKCrypto is the Linux-based encrypting software modem that we&#8217;ve made. It consists of two components: the modem component and crypto component.</p>
<span id="The_modem__Hardware_components"><h3>The modem / Hardware components</h3></span>
<p>We needed the ability to send data before we could try sending  encrypteddata, so the first step was to design a simple software modem.</p>
<p>Rather than executing the modem code on the cell phones themselves, I decided to host the modem code on a the sender and receiver&#8217;s Linux systems. This design provides two benefits:</p>
<ol>
<li>The modem code and crypto code has access to the rich Linux API.</li>
<li>Sensitive code and data are isolated from the both the cell phone itself and from the cell infrastructure. We have clean separation between trusted (PC) and untrusted (cell) environments.</li>
</ol>
<p>Thus, the &#8220;real work&#8221; in OKCrypto is done on the PC &#8211; the cell phones simply allow the PCs to talk to each other. See figure 1 for an overview of the hardware involved in the system. 						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/4153181728"><img class="flickr small" title="Fig. 1 - Hardware components" alt="Fig. 1 - Hardware components" src="http://farm3.static.flickr.com/2534/4153181728_a0fe8e3a63_m.jpg" /></a></div>
					</p>
<p>Conceptually, the modem is similar to the analog Plain Old Telephone Service (POTS) modems from the Bad Old Days before broadband service became popular. Instead of an audio coupler, we&#8217;re using Bluetooth to connect our PC to our phone line. Instead of custom hardware, our modem is comprised of some glue scripts and the software packages they connect &#8211; all running on a Linux PC.</p>
<p>The modem doesn&#8217;t provide an asynchronous full-duplex communication link like traditional modems. This modem&#8217;s operation is simpler: The sender&#8217;s modem dials the number of, and subsequently transmits a pre-prepared chunk of data to, the recipient&#8217;s modem. It then hangs up.</p>
<p>The modem uses Dual-tone multi-frequency (DTMF) signaling to encode the data it transmits. I chose DTMF because I was familiar with it and because Debian provides a package for <a href="http://www.baycom.org/~tom/ham/linux/multimon.html">Multimon</a>. OKCrypto uses two utilities that Multimon provides:</p>
<ol>
<li>gen &#8211; a DTMF generation utility (digits-&gt;wav file)</li>
<li>multimon &#8211; a DTMF detection utility (wav file-&gt;digits)</li>
</ol>
<span id="Transmitting_audio_from_a_PC_to_a_cell_phone__Software_components"><h3>Transmitting audio from a PC to a cell phone / Software components</h3></span>
<p>I&#8217;d been working on a few Bluetooth security projects at the time, so the Hands-Free Profile (HFP)<sup>3</sup> came immediately to mind as a convenient way to transfer audio (and any data we&#8217;ve encoded in the audio) between a PC and a cell phone during a call.</p>
<p>-flickr size=&#8221;small&#8221; float=&#8221;right&#8221;-4153181752-/flickr-In most cases HFP is used to connect a a Bluetooth phone to a Bluetooth headset so that the headset can be used to make calls via the phone. See figure 2.</p>
<p>-flickr size=&#8221;small&#8221; float=&#8221;right&#8221;-4153181518-/flickr-In the PC world, HFP is typically used to connect a desktop computer to a bluetooth headset. See figure 3. In that configuration, the PC fulfills the first of two roles mandated by the HFP specification: the Audio Gateway (AG) role. The headset fulfills the hands-free (HF) role.</p>
						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/4152393267"><img class="flickr small" title="Fig. 4 - PC ~ Cell phone" alt="Fig. 4 - PC ~ Cell phone" src="http://farm3.static.flickr.com/2737/4152393267_95526e2aaf_m.jpg" /></a></div>
					For our purposes, we need the PC to appear to be a bluetooth headset to a cell phone &#8211; the PC must fulfill the HF role. See figure 4. This is similar to how call-handling in-vehicle GPS/stereo units work.</p>
<p>Support for the HF role in <a href="http://www.bluez.org/">bluez</a>, the Linux Bluetooth stack (pronounced &#8220;blue-zee&#8221;), is just now maturing<sup>4</sup> so I went searching for a userspace implementation of the HFP protocol stack.</p>
<p>One of the best, chan_mobile, is distributed as an add-on to the popular open-source private branch exchange (PBX) <a href="http://www.asterisk.org/">Asterisk</a> system. If you configure chan_mobile to use your cell phone, Asterisk can make both outbound calls and receive inbound calls with the phone.</p>
<p>Asterisk is the largest software component of the OKCrypto modem. It not only provides a reliable HFP HF role implementation which works with a wide array of modern phones (see above), but also many essential telephony operations:</p>
<ol>
<li>Recording audio during a call. OKCrypto uses Asterisk&#8217;s built-in voicemail capabilities.</li>
<li>Transmitting audio during a call.</li>
<li>Pausing for a given time period.</li>
<li>Logging phone call details.</li>
</ol>
<p>See figure 5 for an overview of the software components in the OKCrypto system. Note that the same software is used on both the sender and receiver&#8217;s PCs.						<div class="flickr-gallery image right"><a href="http://www.flickr.com/photos/55502932@N00/4153379126"><img class="flickr small" title="Fig. 5 - Software components" alt="Fig. 5 - Software components" src="http://farm3.static.flickr.com/2521/4153379126_22a0fbc569_m.jpg" /></a></div>
					
<span id="Demonstration__OKCrypto_scripts"><h3>Demonstration / OKCrypto scripts</h3></span>
<p>Let&#8217;s look at how we can use this modem to send a 16-byte binary file over a cellular voice connection.</p>
<p>First, the sender and recipient will need to perform some set-up steps:</p>
<ol>
<li>1. Acquire a Linux-supported computer and Bluetooth adapter. I found that using a virtual machine introduces latency that bluez/btusb cannot tolerate.</li>
<li>Acquire a HFP-capable cell phone.</li>
<li>Install Linux, <a href="http://sox.sourceforge.net/">SoX</a>, Python, multimon, Asterisk, the Asterisk &#8220;add-ons&#8221;, GPG, and the OKCrypto scripts.</li>
<li>Pair cell phone with computer. Grant HFP access.</li>
<li>Configure chan_mobile</li>
<li>Start Asterisk Next, the sender can issue this command at a shell to send the file &#8216;/tmp/foo&#8217; to the recipient at 585-555-3258.
<pre class="brush: bash;">$ ./bin_to_int_seq.py /tmp/foo | ./ast_send.sh 5855553258 [...]
$ cksum /tmp/foo 668417501 16 /tmp/foo</pre>
<p>She&#8217;ll notice her PC making a call with her phone, silently transmitting the data, and disconnecting. Behind the scenes, the OKCrypto scripts will&#8230;</li>
<li>Convert the bytes in /tmp/foo to a series of decimal digits.</li>
<li>Encode the digits as DTMF tones with gen from the multimon package. 1. Increase the pitch (time-independent) to prevent any intermediary systems (esp. Asterisk) from interpreting the tones.</li>
<li>Queue the final audio file for transmission by Asterisk.</li>
</ol>
<p>The recipient will hear his phone ring once before his PC answers the call, records the audio, and disconnects. When the call is complete, Asterisk will invoke one of the OKCrypto scripts to&#8230;</p>
<ol>
<li>Decrease the pitch to yield the original DTMF tones.</li>
<li>Decode the DTMF tones to a series of decimal digits.</li>
<li>Convert the digits to a series of bytes which is written to &#8216;/tmp/bar&#8217;.
<pre class="brush: bash;">$ tr -d '\n' &lt; /tmp/newest_vm.txt | ./int_seq_to_bin.py /tmp/bar [...]
$ cksum /tmp/bar 668417501 16 /tmp/bar</pre>
</li>
</ol>
<span id="Encryption"><h3>Encryption</h3></span>
<p>Now that we can reliably send data, let&#8217;s make sure that it&#8217;s encrypted first. This turns out to be one of the simplest components of the system &#8211; many good crypto APIs are available.</p>
<p>I use <a href="http://www.gnupg.org/">GnuPG</a>:</p>
<pre class="brush: bash;">$ gpg --symmetric --force-mdc --cipher-algo AES256 filetoencrypt </pre>
<p>The `&#8211;force-mdc` option provides integrity checking &#8211; useful for handling transmission errors. Consider these GPG options carefully and make sure they fit your requirements.</p>
<span id="Further_work"><h3>Further work</h3></span>
<p>Here are a few ideas we&#8217;re pursuing for the future of this project:</p>
<ul>
<li>Moving the modem code to the cell phone. This would simplify the setup but potentially risk security.</li>
<li>Improving modem error rate. Data is often erroneously duplicated during transmission.</li>
<li>Increasing the modem throughput. The current code averages a meager 10 bytes/second.</li>
<li>Hiding the data within a steganographic channel in a normal voice conversation.</li>
<li>Incorporating GPG into the OKCrypto scripts.</li>
<li>Packaging the system as a LiveCD/Live flash drive.</li>
<li>Implementing key exchange.</li>
<li>Building an embedded device dedicated to OKCrypto.</li>
</ul>
<span id="What_I_learned"><h3>What I learned</h3></span>
<p>I gained experience in the follow areas during the design, implementation. and testing:</p>
<ul>
<li>GSM, CDMA crypto. I suspect the cellular phone industry would make a great case study in protocol security by obscurity.</li>
<li>Cellular voice codecs used by large carriers. Trivia: your calls only require ~10kbps.<sup>5</sup></li>
<li>Bluetooth HFP specification and available implementations.</li>
<li>Debugging latency tolerances in virtual machine USB &#8220;passthrough&#8221; subsystems.</li>
<li>The <a href="http://www.twilio.com/">Twilio</a> telephony API. I used Twilio when I only had one cell phone to debug with.</li>
<li>Asterisk administration.</li>
</ul>
<span id="Conclusion__Download"><h3>Conclusion / Download</h3></span>
<p>I&#8217;ve described a method to securely transmit data over any of the widely-available cell voice networks. The implementation requires only commodity hardware, open-source software, and minimal setup.</p>
<p>Be aware that transmitting data by &#8220;automated means&#8221; may violate the terms of your cellular service contract. I disclaim all liability. This information is provided for educational purposes only.</p>
<p>You can download the OKCrypto system here: http://www.unsyncopated.com/corral/okcrypto_v0.1.tar.gz</p>
<p>It is licensed under the LGPL.</p>
<span id="Further_reading"><h3>Further reading</h3></span>
<ul>
<li>You&#8217;ll find lots of links to cell security architecture articles, Bluetooth HFP implementations, and Asterisk administration web pages on the wiki at <a href="http://www.unsyncopated.com/wiki/Crypto%20Phone/Stacked%20Linux-based%20CPhone%20Brainstorming">Crypto Phone/Stacked Linux-based CPhone Brainstorming</a></li>
</ul>
<p>Update 1/13/09 - Check out some technical notes on our recent progress with a faster and more reliable modem: <a href="https://www.unsyncopated.com/wiki/OKCrypto/Progress%20Report%20for%2001-09-2010">OKCrypto/Progress Report for 01-09-2010</a></p>
</div>
<ol class="footnotes">
<li id="footnote_0_317" class="footnote"><a href="http://spectrum.ieee.org/telecom/wireless/open-source-effort-to-hack-gsm">Open-Source Effort to Hack GSM</a> John Blau &#8211; IEEE Spectrum Magazine &#8211; December 2009 issue</li>
<li id="footnote_1_317" class="footnote"><a href="https://har2009.org/program/attachments/119_GSM.A51.Cracking.Nohl.pdf">Subverting the security base of GSM</a> Karsten Nohl &#8211; Hacking at Random &#8211; 8/15/2009</li>
<li id="footnote_2_317" class="footnote"><a href="http://www.bluetooth.com/Bluetooth/Technology/Works/HFP.htm">Bluetooth Hands-Free Profile (HFP) 1.5</a> &#8211; Bluetooth Special Interest Group &#8211; 11/25/2005</li>
<li id="footnote_3_317" class="footnote"><a href="https://bugs.maemo.org/show_bug.cgi?id=2754#c1">Comment #1 on Maemo bug #2754</a> &#8211; Johan Hedberg &#8211; 1/25/2009</li>
<li id="footnote_4_317" class="footnote"><a href="http://en.wikipedia.org/w/index.php?title=Adaptive_Multi-Rate_audio_codec&amp;oldid=327719647">Adaptive Multi-Rate audio codec</a> &#8211; Wikipedia &#8211; 11/24/2009</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://unsyncopated.com/blog/index.php/2009/11/19/sending-data-via-cellular-voice-connections-with-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a local mirror of Ubuntu&#8217;s most popular packages</title>
		<link>http://unsyncopated.com/blog/index.php/2009/11/04/creating-a-local-mirror-of-ubuntus-most-popular-packages/</link>
		<comments>http://unsyncopated.com/blog/index.php/2009/11/04/creating-a-local-mirror-of-ubuntus-most-popular-packages/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 22:25:55 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Syntax highlighter]]></category>
		<category><![CDATA[Table of Contents]]></category>

		<guid isPermaLink="false">http://unsyncopated.com/blog/index.php/2009/11/04/creating-a-local-mirror-of-ubuntus-most-popular-packages/</guid>
		<description><![CDATA[The problem You want to create local mirrors of the apt repositories that you use but you don&#8217;t have enough hard drive space to mirror every package. Or maybe you have a slow link and you don&#8217;t want to spend time downloading packages that you&#8217;re unlikely to need. The solution Only mirror packages whose popularity [...]]]></description>
			<content:encoded><![CDATA[<span id="The_problem"><h3>The problem</h3></span>
<p>You want to create local mirrors of the apt repositories that you use but you don&#8217;t have enough hard drive space to mirror every package. Or maybe you have a slow link and you don&#8217;t want to spend time downloading packages that you&#8217;re unlikely to need.</p>
<span id="The_solution"><h3>The solution</h3></span>
<p>Only mirror packages whose popularity (as reported by popcon&#8217;s &#8220;installed&#8221; metric) matches a certain threshold.</p>
<span id="The_explanation"><h3>The explanation</h3></span>
<p>I&#8217;ve been hacking without a network connection recently and one of the biggest pain points is not having access to my distro&#8217;s software package repository.</p>
<p>For example, while writing some Python screen-scraping code last week I realized I didn&#8217;t have the Python library I wanted to parse some HTML with &#8211; <a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup</a>. Rather than postpone my work on the script until I found a weefee signal, it would have been nice to simply install the package from a local mirror of the repository.</p>
<p>I soon discovered two common tools that can be used to create a local mirror of a repository &#8211; Frans Pop&#8217;s <a href="http://alioth.debian.org/~fjp/log/posts.html">debmirror</a> and Dmitriy Khramtsov&#8217;s <a href="http://apt-mirror.sourceforge.net/">apt-mirror</a>.</p>
<p>I chose apt-mirror, skimmed <a href="http://popey.com/blog/2006/10/24/Creating_an_Ubuntu_repository_mirror_with_apt-mirror/">Alan Pope&#8217;s handy step-by-step guide</a> and kicked off the mirror script&#8230;</p>
<pre class="brush: bash;">
$ sudo -u apt-mirror apt-mirror

[...]
52.7 GiB will be downloaded into archive.
Downloading 75 archive files using 10 threads...
</pre>
<p>ACK! That&#8217;s a lot of gibibytes.</p>
<p>Eventually I&#8217;d like a complete mirror, but for now, I only want the packages I&#8217;m likely to need. <a href="http://www.frontier.com">My broadband connection</a> isn&#8217;t as &#8220;broad&#8221; as I would like.</p>
<p>The <a href="http://popcon.debian.org/">Debian Popularity Contest</a> (&#8220;popcon&#8221;) came to mind and sure enough, Ubuntu also provides <a href="http://popcon.ubuntu.com/by_inst">a flat text file</a> containing the names of all packages sorted by the frequency with which they&#8217;re installed by users.</p>
<p>I downloaded this file and hacked up the primary apt-mirror perl script to consult the file, only mirroring binary and source packages if they meet a chosen popularity threshold.</p>
<p>Here&#8217;s the meat from <a href="http://unsyncopated.com/corral/apt-mirror-0.4.5-1ubuntu2_popcon.patch">a patch that applies cleanly to apt-mirror version 0.4.5-1ubuntu2</a>:</p>
<pre class="brush: perl;">

sub should_process {
# print &quot;should_process()\n&quot;;
my $pkg_name = shift;
my $section_name = shift;
my @popular_pkgs = @{ $_[0] };

# if the pkg isn't in the 'game' section...
if($section_name !~ /game/){
my %is_popular;
for (@popular_pkgs) { $is_popular{$_} = 1 };

if( $is_popular{$pkg_name} ) {
# print &quot;processing popular pkg: &quot; . $pkg_name . &quot;\n&quot;;
return 1;
} else {
# print &quot;skipping unpopular pkg: &quot; . $pkg_name . &quot;\n&quot;;
return 0;
}
} else {
# print &quot;skipping game pkg: &quot; . $pkg_name . &quot;\n&quot;;
return 0;
}
}

# [...]

# open our popcon database
my $db_path = &quot;/home/tz/Desktop/by_inst&quot;;
open(FILE,$db_path) or die &quot;Can't open popcon db: $!&quot;;
my @data=; # beware record separator ($/) tweak below
close FILE;
my $num_comment_lines = 11;
my $threshold = 3000;
my $cur_line;
my @popular_pkgs;
# for each of the first $threshold lines, grab pkg name
foreach $cur_line (@data[$num_comment_lines .. ($num_comment_lines + $threshold)]) {
# print &quot;cur_line: $cur_line&quot;;
my @tokens = split / +/, $cur_line;
# print &quot;pkgname: &quot; . $tokens[1] . &quot;\n&quot;;
push( @popular_pkgs, $tokens[1] );
}

# [...]

if( should_process( $lines{&quot;Package:&quot;}, $lines{&quot;Section:&quot;},@popular_pkgs ) ) {
add_url_to_download($uri . &quot;/&quot; . $lines{&quot;Directory:&quot;} . &quot;/&quot; . $file[2], $file[1]);
}
</pre>
<p>Tweak the path to the flat file (`$db_path`) and the threshold (`$threshold`!) to suit your needs.<br />
<!-- echo "As you can see, I also modified the\nscript to skip games. Games tend to be\nlarge and there aren't many that I use\noften, except perhaps cowsay(1) :]" |cowsay -f gnu --></p>
<pre> ________________________________________
/ As you can see, I also modified the    \
| script to skip games. Games tend to be |
| large and there aren't many that I use |
\ often, except perhaps cowsay(1) :]     /
 ----------------------------------------
    \               ,-----._
  .  \         .  ,'        `-.__,------._
 //   \      __\\'                        `-.
((    _____-'___))                           |
 `:='/     (alf_/                            |
 `.=|      |='                               |
    |)   O |                                  \
    |      |                               /\  \
    |     /                          .    /  \  \
    |    .-..__            ___   .--' \  |\   \  |
   |o o  |     ``--.___.  /   `-'      \  \\   \ |
    `--''        '  .' / /             |  | |   | \
                 |  | / /              |  | |   mmm
                 |  ||  |              | /| |
                 ( .' \ \              || | |
                 | |   \ \            // / /
                 | |    \ \          || |_|
                /  |    |_/         /_|
               /__/</pre>
<span id="Future_improvements"><h3>Future improvements</h3></span>
<ul>
<li>Download popcon db file, rather than expect that it already exists on disk.</li>
<li>Read desired popularity threshold from mirror.list rather than using a hard-coded value.</li>
<li>Read desired sections as above.</li>
<li>Speed holes! My perl-fu is weak.</li>
</ul>
<span id="Tips"><h3>Tips</h3></span>
<ul>
<li>I found a faster mirror half-way through creating my local mirror. Renaming `/var/spool/apt-mirror/{mirror,skel}/${OLD_MIRROR` to `/var/spool/apt-mirror/{mirror,skel}/${NEW_MIRROR}` was sufficient.</li>
<li>If you try to install a package from your local mirror which doesn&#8217;t exist, you&#8217;ll get a 404 error &#8211; nothing catastrophic happens.</li>
<li>Beware <a href="http://sourceforge.net/projects/apt-mirror/forums/forum/197335/topic/1747995">permissions issues</a>. Avoid running apt-mirror as root rather than the prescribed `apt-mirror` user.</li>
<li>debmirror has a `&#8211;exclude-deb-section` option</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://unsyncopated.com/blog/index.php/2009/11/04/creating-a-local-mirror-of-ubuntus-most-popular-packages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

