<?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>/dev/ttyS0 </title>
	<atom:link href="http://www.devttys0.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devttys0.com</link>
	<description>Embedded Device Hacking</description>
	<lastBuildDate>Tue, 30 Apr 2013 13:02:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Finding All Paths Between Two Functions in IDA</title>
		<link>http://www.devttys0.com/2013/04/finding-all-paths-between-two-functions-in-ida/</link>
		<comments>http://www.devttys0.com/2013/04/finding-all-paths-between-two-functions-in-ida/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 02:02:16 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1525</guid>
		<description><![CDATA[A common need that I have when reversing code is to find all possible code paths between two functions. Say for example that I&#8217;m looking for calls to dangerous functions, like sprintf, and I want to find all possible code paths that lead from my current function to sprintf. Manually … <a href="http://www.devttys0.com/2013/04/finding-all-paths-between-two-functions-in-ida/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
				<content:encoded><![CDATA[<p>A common need that I have when reversing code is to find all possible code paths between two functions. Say for example that I&#8217;m looking for calls to dangerous functions, like sprintf, and I want to find all possible code paths that lead from my current function to sprintf. Manually going through the call graph from my starting function can often be, well, tedious:</p>
<div class="wp-caption aligncenter" style="width: 2079px"><a href="http://idapathfinder.googlecode.com/svn/wiki/images/xrefs.jpg"><img src="http://idapathfinder.googlecode.com/svn/wiki/images/xrefs.jpg" width="2069" height="528" class /></a><p class="wp-caption-text">websReadEvent call graph</p></div>
<p>Unfortunately I couldn&#8217;t find an easy way to make IDA display all code paths between two functions, and <em>only</em> the paths between those two functions. Normal call graphs show everything going to or from a single function, and while proximity view can be told to find a path between two nodes, it only displays the first path that it finds.</p>
<p>So I wrote <a href="http://code.google.com/p/idapathfinder/">idapathfinder</a>, a plugin to find all code paths between two functions. This can significantly narrow down the number of paths that require investigation:</p>
<div class="wp-caption aligncenter" style="width: 410px"><a href="http://idapathfinder.googlecode.com/svn/wiki/images/idapathfinder.jpg"><img src="http://idapathfinder.googlecode.com/svn/wiki/images/idapathfinder.jpg" width="400" height="500" class /></a><p class="wp-caption-text">All paths between websReadEvent and sprintf</p></div>
<p>Note that the graphs generated by idapathfinder are solely dependent on IDA&#8217;s knowledge of function cross-references, so if for example you have a function that iterates over function pointers in a function table, those relationships will not be identified.</p>
<p>You can download idapathfinder <a href="http://code.google.com/p/idapathfinder/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2013/04/finding-all-paths-between-two-functions-in-ida/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Binwalk 1.2 Release</title>
		<link>http://www.devttys0.com/2013/04/binwalk-1-2-release/</link>
		<comments>http://www.devttys0.com/2013/04/binwalk-1-2-release/#comments</comments>
		<pubDate>Tue, 02 Apr 2013 17:50:35 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1514</guid>
		<description><![CDATA[Binwalk 1.2 has been released, and in addition to the usual signature / speed improvements, it sports several new features: Recursive file scanning and extraction Entropy and strings analysis Plugin support Recursive Extraction Often files extracted by binwalk need to be further scanned / analyzed. This can now be automated … <a href="http://www.devttys0.com/2013/04/binwalk-1-2-release/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
				<content:encoded><![CDATA[<p>Binwalk 1.2 has been <a href="http://code.google.com/p/binwalk/downloads/detail?name=binwalk-1.2.tar.gz">released</a>, and in addition to the usual signature / speed improvements, it sports several new features:</p>
<ul>
<li>Recursive file scanning and extraction</li>
<li>Entropy and strings analysis</li>
<li>Plugin support</li>
</ul>
<p><span id="more-1514"></span></p>
<p>
<strong>Recursive Extraction</strong></p>
<p>Often files extracted by binwalk need to be further scanned / analyzed. This can now be automated with the &#8211;matryoshka option, which will recursively extract and scan files up to eight levels deep:</p>
<blockquote>
<pre>
$ binwalk -e --matryoshka firmware.bin
</pre>
</blockquote>
<p>
<strong>Entropy Analysis</strong></p>
<p>Binwalk&#8217;s signature analysis is great, but how do you know it didn&#8217;t miss something? What do you do if binwalk doesn&#8217;t find anything at all? </p>
<p>Examining a file&#8217;s entropy can reveal a lot about its contents, such as which parts of the file may be compressed or encrypted:</p>
<div class="wp-caption aligncenter" style="width: 1810px"><a href="http://binwalk.googlecode.com/svn/wiki/images/lgdtv_entropy.png"><img src="http://binwalk.googlecode.com/svn/wiki/images/lgdtv_entropy.png" width="1800" height="988" class /></a><p class="wp-caption-text">$ binwalk &#8211;entropy lg_dtv.bin</p></div>
<p>What&#8217;s more, you can combine binwalk&#8217;s entropy analysis with other scans, such as the standard signature scan, or a strings / opcode scan:</p>
<div class="wp-caption aligncenter" style="width: 1810px"><a href="http://binwalk.googlecode.com/svn/wiki/images/lgdtv_binwalk_entropy.png"><img src="http://binwalk.googlecode.com/svn/wiki/images/lgdtv_binwalk_entropy.png" width="1800" height="988" class /></a><p class="wp-caption-text">$ binwalk &#8211;entropy &#8211;binwalk lg_dtv.bin</p></div>
<div class="wp-caption aligncenter" style="width: 1810px"><a href="http://binwalk.googlecode.com/svn/wiki/images/lgdtv_strings_opcode_entropy.png"><img src="http://binwalk.googlecode.com/svn/wiki/images/lgdtv_strings_opcode_entropy.png" width="1800" height="988" class /></a><p class="wp-caption-text">$ binwalk &#8211;entropy &#8211;strings &#8211;opcodes lg_dtv.bin</p></div>
<p><strong>Plugin Support</strong></p>
<p>In addition to a scriptable API, binwalk now supports plugins that are afforded considerable control over binwalk&#8217;s scan process. Plugins are particularly useful for extending or modifying binwalk&#8217;s analysis where custom signatures fall short.</p>
<p>Plugins are easy to write; check out some of the <a href="http://code.google.com/p/binwalk/wiki/Plugins#Examples">examples</a> on the <a href="http://code.google.com/p/binwalk/wiki/TableOfContents?tm=6">wiki</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2013/04/binwalk-1-2-release/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>EDE101 April 2013 Registration Open</title>
		<link>http://www.devttys0.com/2013/03/ede101-april-2013-registration-open/</link>
		<comments>http://www.devttys0.com/2013/03/ede101-april-2013-registration-open/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 03:31:01 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1505</guid>
		<description><![CDATA[Registration is open for the April 2013 offering of our Embedded Device Exploitation 101 course. if (stuff_you_like &#038; (hardware &#124; firmware &#124; zero_days)): print "You should come!"]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.tacnetsol.com/training">Registration is open</a> for the April 2013 offering of our Embedded Device Exploitation 101 course. </p>
<blockquote>
<pre>
if (stuff_you_like &#038; (hardware | firmware | zero_days)):
   print "You should come!"
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2013/03/ede101-april-2013-registration-open/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interview on PaulDotCom</title>
		<link>http://www.devttys0.com/2013/02/interview-on-pauldotcom/</link>
		<comments>http://www.devttys0.com/2013/02/interview-on-pauldotcom/#comments</comments>
		<pubDate>Mon, 11 Feb 2013 20:55:07 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1502</guid>
		<description><![CDATA[Woohoo! I&#8217;m getting interviewed on PaulDotCom! I guess this means I&#8217;m internet famous now. Don&#8217;t miss it!]]></description>
				<content:encoded><![CDATA[<p>Woohoo! I&#8217;m getting interviewed on PaulDotCom! I guess this means I&#8217;m internet famous now. <a href="http://pauldotcom.com/2013/02/special-pauldotcom-security-we.html">Don&#8217;t miss it</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2013/02/interview-on-pauldotcom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binwalk v1.0, Now With Python!</title>
		<link>http://www.devttys0.com/2013/02/binwalk-v1-0-now-with-python/</link>
		<comments>http://www.devttys0.com/2013/02/binwalk-v1-0-now-with-python/#comments</comments>
		<pubDate>Wed, 06 Feb 2013 21:26:32 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1498</guid>
		<description><![CDATA[Binwalk 1.0 has just been released and has been completely re-written as a Python module. This means that not only does it feature smarter scanning and signature processing features that were much, much easier to implement in Python, but it is now fully scriptable. Aside from a few new options … <a href="http://www.devttys0.com/2013/02/binwalk-v1-0-now-with-python/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
				<content:encoded><![CDATA[<p>Binwalk 1.0 has just been <a href="http://code.google.com/p/binwalk/downloads/list">released</a> and has been completely re-written as a Python module. This means that not only does it feature smarter scanning and signature processing features that were much, much easier to implement in Python, but it is now fully scriptable.</p>
<p>Aside from a few new options (and the removal of a few depreciated ones), the command line usage is pretty much the same. My personal favorite options to pass to binwalk are &#8216;-re&#8217;, which besides being a reference to reverse engineering, will attempt to extract data from the target file and clean up after itself (very handy for when there are a lot of false positive LZMA files extracted!):</p>
<blockquote>
<pre>
$ binwalk -re firmware.bin
</pre>
</blockquote>
<p>Scripting with binwalk is pretty straight forward. To perform a simple scan (equivalent to running binwalk with no command line options):</p>
<blockquote>
<pre>
import pprint
from binwalk import Binwalk

binwalk = Binwalk()
pprint.PrettyPrinter().pprint(binwalk.scan('firmware.bin'))
binwalk.cleanup()
</pre>
</blockquote>
<p>Check out the <a href="http://code.google.com/p/binwalk/wiki/TableOfContents?tm=6">wiki</a> for more command line usage and API examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2013/02/binwalk-v1-0-now-with-python/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>February EDE Class</title>
		<link>http://www.devttys0.com/2013/01/february-ede-class/</link>
		<comments>http://www.devttys0.com/2013/01/february-ede-class/#comments</comments>
		<pubDate>Fri, 25 Jan 2013 19:07:58 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1493</guid>
		<description><![CDATA[Registration for our February Embedded Device Exploitation course is now open! Class dates are February 12th &#038; 13th, so register now while you still can. http://www.tacnetsol.com/training]]></description>
				<content:encoded><![CDATA[<p>Registration for our February Embedded Device Exploitation course is now open! Class dates are February 12th &#038; 13th, so register now while you still can. <img src='http://www.devttys0.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>http://www.tacnetsol.com/training</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2013/01/february-ede-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binwalk 0.5 Release</title>
		<link>http://www.devttys0.com/2012/12/binwalk-0-5-release/</link>
		<comments>http://www.devttys0.com/2012/12/binwalk-0-5-release/#comments</comments>
		<pubDate>Sat, 22 Dec 2012 03:50:03 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1483</guid>
		<description><![CDATA[In celebration of the world not ending, a new version of Binwalk has been released. Notable changes: Much improved signatures for several common file types, particularly JFFS2 &#8220;Smart signature&#8221; keyword support, for more reliable and faster scans Ability to invoke external applications to process extracted files The latter feature is … <a href="http://www.devttys0.com/2012/12/binwalk-0-5-release/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
				<content:encoded><![CDATA[<p>In celebration of the world not ending, a new version of Binwalk has been <a href="https://code.google.com/p/binwalk/downloads/list">released</a>. Notable changes:</p>
<ul>
<li>Much improved signatures for several common file types, particularly JFFS2</li>
<li>&#8220;<a href="https://code.google.com/p/binwalk/wiki/MagicSignatures">Smart signature</a>&#8221; keyword support, for more reliable and faster scans</li>
<li>Ability to invoke external applications to process extracted files</li>
</ul>
<p>The latter feature is probably of most interest, and is implemented as an extension of the pre-existing &#8211;dd option:</p>
<blockquote>
<pre>
$ <strong>binwalk --dd='gzip:gz:gunzip %e' firmware.bin</strong>
</pre>
</blockquote>
<p>The above command instructs Binwalk to extract any file whose description contains the text &#8216;gzip&#8217;, save it to disk with a &#8216;gz&#8217; file extension, and to then run the &#8216;gunzip %e&#8217; command (the %e is a placeholder that will be replaced with the actual name of the extracted file). This allows for auto extraction and decompression of gzipped files.</p>
<p>Although multiple &#8211;dd options may be specified, there are probably several common file types that you always want to be extracted whenever they are encountered. Binwalk 0.5 allows you to place multiple &#8211;dd arguments into the $HOME/.binwalk/extract.conf file:</p>
<blockquote>
<pre>
# Extract and decompress gzip and lzma files
gzip:gz:gunzip %e
lzma:7z:7zip -d %e

# Extract private keys, but don't run anything
private key:key
</pre>
</blockquote>
<p>The extract rules from this file are applied whenever the &#8211;extract option is specified:</p>
<blockquote>
<pre>
$ <strong>binwalk --extract firmware.bin</strong>
</pre>
</blockquote>
<p>There are several default extract rules that come with Binwalk by default. These are stored in /usr/local/etc/binwalk/extract.conf, and will be updated whenever the &#8211;update option is specified. Note that many of these extract rules expect the <a href="https://code.google.com/p/firmware-mod-kit/">firmware-mod-kit</a> to be installed to /opt/firmware-mod-kit, but these rules can be overridden by those in the $HOME/.binwalk/extract.conf file.</p>
<p>This means that a Binwalk scan can now not only identify embedded files, but also extract and decompress them for you automatically:</p>
<blockquote>
<pre>
$ <strong>binwalk --extract firmware.bin</strong> 

DECIMAL   	HEX       	DESCRIPTION
-------------------------------------------------------------------------------------------------------
0         	0x0       	TRX firmware header, little endian, header size: 28 bytes,  image size: 13533184 bytes, CRC32: 0x15289B44 flags/version: 0x10000
28        	0x1C      	gzip compressed data, was "piggy", from Unix, last modified: Mon Dec  3 13:09:06 2012, max compression
2005108   	0x1E9874  	Squashfs filesystem, little endian, non-standard signature,  version 3.1, size: 11525877 bytes, 2743 inodes, blocksize: 131072 bytes, created: Mon Dec  3 13:49:31 2012 

$ <strong>ls</strong>
1C  1E9874.squashfs  firmware.bin  squashfs-root/
$ <strong>ls squashfs-root</strong>
bin  dev  etc  home  JNAP  lib  libexec  linuxrc  mnt  opt  proc  root  sbin  sys  tmp  usr  var  www
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2012/12/binwalk-0-5-release/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>IDAScript For Linux and OSX</title>
		<link>http://www.devttys0.com/2012/11/idascript-for-linux-and-osx/</link>
		<comments>http://www.devttys0.com/2012/11/idascript-for-linux-and-osx/#comments</comments>
		<pubDate>Thu, 15 Nov 2012 04:53:07 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1471</guid>
		<description><![CDATA[Being able to run IDA scripts from the command line is very useful, but can be a bit kludgy. Fortunately, idascript was written to simplify this process. Unfortunately (for me), it was written for Windows. Since I work primarily in a Linux environment, I re-wrote the idascript utility in Python. … <a href="http://www.devttys0.com/2012/11/idascript-for-linux-and-osx/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
				<content:encoded><![CDATA[<p>Being able to run IDA scripts from the command line is very useful, but can be a bit kludgy. Fortunately, <a href="http://www.hexblog.com/?p=128">idascript</a> was written to simplify this process. Unfortunately (for me), it was written for Windows.</p>
<p>Since I work primarily in a Linux environment, I <a href="http://www.devttys0.com/wp-content/uploads/2012/11/idascript.tar.gz">re-wrote</a> the idascript utility in Python. I also added a few features to the idascript Python module, for convenience:</p>
<ul>
<li>Script arguments are accessible via the normal sys.argv</li>
<li>The script can be terminated via the normal sys.exit function</li>
<li>The directory to your collection of IDA scripts (specified during install) is added to sys.path</li>
</ul>
<p>Installation is straightforward:</p>
<blockquote>
<pre>
eve@eve:~/idascript$ <strong>sudo ./install.py</strong> 
Absolute path to your IDA install directory: <strong>/opt/ida/bin</strong>
 
Absolute path to the directory where you usually keep all your IDA scripts: <strong>/opt/ida/scripts</strong>
 
IDA_INSTALL_PATH = /opt/ida/bin
IDA_SCRIPT_PATH = /opt/ida/scripts
IDA_OUT_FILE = /tmp/idaout.txt
</blockquote>
</pre>
<p>Using existing IDAPython scripts with idascript is as easy as importing the idascript module:</p>
<blockquote>
<pre>
import idascript

print "Cross references to strcpy:"

for xref in XrefsTo(LocByName("strcpy")):
    print "0x%.8X  %s" % (xref.frm, GetDisasm(xref.frm))
</pre>
</blockquote>
<p>And usage of idascript itself is the same as the original idascript utility:</p>
<blockquote>
<pre>
eve@eve:~$ <strong>idascript ./target.idb ./strcpy.py</strong> 
Cross references to strcpy:
0x00407F68  jalr    $t9 ; strcpy
0x0040B9B8  jalr    $t9 ; strcpy
0x0040E5BC  jr      $t9 ; strcpy
0x0041D448  jalr    $t9 ; strcpy
0x00422C04  jalr    $t9 ; strcpy
0x00422D04  jalr    $t9 ; strcpy
0x00424C4C  jalr    $t9 ; strcpy
0x00425400  jalr    $t9 ; strcpy
0x00430358  jalr    $t9 ; strcpy
0x0043045C  jalr    $t9 ; strcpy
0x00434118  jalr    $t9 ; strcpy
0x00436A30  jalr    $t9 ; strcpy
0x0043CE48  jalr    $t9 ; strcpy
0x00407F58  la      $t9, strcpy
0x0040B9AC  la      $t9, strcpy
0x0040E598  la      $t9, strcpy
0x0041D440  la      $t9, strcpy
0x00422BF8  la      $t9, strcpy
0x00422CF8  la      $t9, strcpy
0x00422D74  la      $t9, strcpy
0x00424C44  la      $t9, strcpy
0x004253F0  la      $t9, strcpy
0x004302D8  la      $t9, strcpy
0x00430454  la      $t9, strcpy
0x00434110  la      $t9, strcpy
0x00436A28  la      $t9, strcpy
0x0043CE40  la      $t9, strcpy
0x00498ECC  .word strcpy
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2012/11/idascript-for-linux-and-osx/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>December EDE Class</title>
		<link>http://www.devttys0.com/2012/11/december-ede-class/</link>
		<comments>http://www.devttys0.com/2012/11/december-ede-class/#comments</comments>
		<pubDate>Sat, 10 Nov 2012 01:27:21 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=1469</guid>
		<description><![CDATA[Our next Embedded Device Exploitation class will be held on December 12th and 13th. Registration is open now!]]></description>
				<content:encoded><![CDATA[<p>Our next Embedded Device Exploitation class will be held on December 12th and 13th. <a href="http://www.tacnetsol.com/training/">Registration</a> is open now!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2012/11/december-ede-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverse Engineering Serial Ports</title>
		<link>http://www.devttys0.com/2012/11/reverse-engineering-serial-ports/</link>
		<comments>http://www.devttys0.com/2012/11/reverse-engineering-serial-ports/#comments</comments>
		<pubDate>Thu, 01 Nov 2012 02:15:04 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Embedded Systems]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.devttys0.com/?p=414</guid>
		<description><![CDATA[Given the name of this blog and the number of requests that I&#8217;ve had, I think it&#8217;s high time we discussed serial ports; specifically, serial ports in embedded systems. My goal here is to describe the techniques that I&#8217;ve found effective in identifying and reverse engineering embedded serial ports through … <a href="http://www.devttys0.com/2012/11/reverse-engineering-serial-ports/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
				<content:encoded><![CDATA[<p>Given the name of this blog and the number of requests that I&#8217;ve had, I think it&#8217;s high time we discussed serial ports; specifically, serial ports in embedded systems. </p>
<p>My goal here is to describe the techniques that I&#8217;ve found effective in identifying and reverse engineering embedded serial ports through the use of definitive testing and educated guesses, and without the need for expensive equipment.</p>
<hr />
<h1>Introduction</h1>
<p>Serial ports are extremely useful to embedded developers, who commonly use them for:</p>
<ul>
<li>Accessing the boot loader</li>
<li>Observing boot and debug messages</li>
<li>Interacting with the system via a shell</li>
</ul>
<p>Needless to say, this functionality is also useful to hackers, so finding a serial port on an embedded device can be very advantageous. As a case study, we&#8217;ll be examining the PCB of a Westell 9100EM FiOS router for possible serial ports:</p>
<div id="attachment_1378" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/westell_board.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/westell_board-300x200.jpg" alt="" title="westell_board" width="300" height="200" class="size-medium wp-image-1378" /></a><p class="wp-caption-text">Westell 9100EM PCB</p></div>
<p><span id="more-414"></span></p>
<p>Now, these aren&#8217;t your dad&#8217;s RS-232 serial ports that we&#8217;re looking for; these are Universal Asynchronous Receiver Transmitters (UARTs), commonly found in embedded devices. Although protocol compatible, RS-232 and UART are not voltage compatible (from here on out I will use the terms &#8220;UART&#8221; and &#8220;serial port&#8221; interchangeably). UARTs most commonly operate at 3.3 volts, but can also be found operating at other standard voltages (5, 1.8, etc).</p>
<p>Unfortunately there aren&#8217;t any industry standardized UART pin outs, and manufacturers don&#8217;t often go around advertising or documenting their debug interfaces, so we&#8217;ll need to do a bit of work in order to interface with these serial ports. Specifically, we need to reverse engineer both the hardware interface and the software protocol settings.</p>
<p>Let&#8217;s start with the hardware interface first. For this, you&#8217;ll need a multimeter and a pair of eyeballs (or even one will do just fine). Yes, oscilloscopes and logic analyzers are useful and sometimes necessary, but 99% of the time a trusty multimeter and a bit of knowledge is all you need.</p>
<hr />
<h1>Identifying Serial Headers</h1>
<p>The first step is to try to identify potential candidates for serial port headers. Most serial port headers have at a minimum four pins:</p>
<ul>
<li>Vcc</li>
<li>Ground</li>
<li>Transmit</li>
<li>Receive</li>
</ul>
<p>Typically you&#8217;ll want to look for a single row of 4-6 pins, although this is not a hard and fast rule and they can come in any pin configuration the manufacturer has decided on.</p>
<p>On our 9100EM PCB we find two possible candidates, labeled P1402 and P1404:</p>
<div id="attachment_1379" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/connectors.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/connectors-300x200.jpg" alt="" title="headers" width="300" height="200" class="size-medium wp-image-1379" /></a><p class="wp-caption-text">Possible serial port headers</p></div>
<p>Sometimes you won&#8217;t have a nicely broken out set of pins like this, and you&#8217;ll have to examine test points on the board; usually starting with test points closest to the SoC is a good idea. Here is an example of a serial port exposed via test points on a different board, the <a href="http://bitsum.com/openwiking/owbase/WL530G/">WL530G</a>:</p>
<div id="attachment_1402" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/wl530g_connectors.jpeg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/wl530g_connectors-300x224.jpeg" alt="" title="wl530g_serial_port" width="300" height="224" class="size-medium wp-image-1402" /></a><p class="wp-caption-text">Serial port test points on a WL530G</p></div>
<p>In either case the process of pin identification is the same, but usually takes longer if there is no header since there will likely be more than 4 test points on the board that you will need to examine.</p>
<p>At this point either P1402 or P1404 could be serial port headers. Or they could both be serial port headers. Or neither could be a serial port header. So we&#8217;ll examine the pins on each header individually to try to gain some insight.</p>
<hr />
<h1>Visual Inspection</h1>
<p>First, let&#8217;s visibly inspect the pins. We&#8217;ll start by taking a look at P1402:</p>
<div id="attachment_1380" class="wp-caption aligncenter" style="width: 759px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_top_2.png"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_top_2.png" alt="" title="p1402_top_2" width="749" height="311" class="size-full wp-image-1380" /></a><p class="wp-caption-text">P1402 top</p></div>
<div id="attachment_1382" class="wp-caption aligncenter" style="width: 912px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_bottom.png"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_bottom.png" alt="" title="p1402_bottom" width="902" height="406" class="size-full wp-image-1382" /></a><p class="wp-caption-text">P1402 bottom</p></div>
<p>On the top layer of the PCB the right most pin is labeled as pin &#8220;1&#8243;. This is not terribly important, but it gives a common frame of reference when describing the pin numbers.</p>
<p>On the bottom of the PCB we see that pin 3 has four traces in a crosshair pattern that connect it to the surrounding ground plane. This easily identifies pin 3 as ground. </p>
<p>Pins 2 and 4 have thin traces connected to them, while pin 1 is connected to a fatter trace. Wide traces are typically used for supplying power, while narrow traces are usually used for signal traces. This suggests that pin 1 is Vcc and pins 2 and 4 are potentially transmit and receive (although we don&#8217;t yet know which is which).</p>
<p>Let&#8217;s take a look at the P1404 header now:</p>
<div id="attachment_1384" class="wp-caption aligncenter" style="width: 810px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_top.png"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_top.png" alt="" title="p1404_top" width="800" height="407" class="size-full wp-image-1384" /></a><p class="wp-caption-text">P1404 top</p></div>
<div id="attachment_1385" class="wp-caption aligncenter" style="width: 906px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_bottom.png"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_bottom.png" alt="" title="p1404_bottom" width="896" height="229" class="size-full wp-image-1385" /></a><p class="wp-caption-text">P1404 bottom</p></div>
<p>Here, the left most pin is marked as pin 1. Again, we see that pin 3 is connected to ground on the bottom layer of the PCB. Pin 4 also has a thin trace connected to it, so it could be a transmit or receive pin. </p>
<p>The other two pins of P1404 however have no visible traces connected to them on either the top or bottom layers of the PCB. It could be that they aren&#8217;t connected to anything, but more likely their traces are connected on one of the inner layers of the PCB that we can&#8217;t see. Time to break out the multimeter.</p>
<hr />
<h1>Identifying Grounded Pins</h1>
<p>A continuity test introduces a small current into the circuit; if enough current passes from one probe to the other (i.e., there is sufficiently little resistance), the multimeter will emit an audible tone indicating that the points that the probes are touching are electrically connected. </p>
<p>The first thing we want to do is perform a continuity test between ground and all the pins on each of the headers using the multimeter. This will tell us which pins are connected directly to ground. We&#8217;ll start with P1402.</p>
<p>Metal shielding is a convenient ground point to use for testing. Placing one probe on a shield and touching the other to pin 3, the multimeter emits a continuous audible tone, indicating that pin 3 is connected to ground as we previously observed:</p>
<div id="attachment_1386" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin3_continuity.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin3_continuity-300x200.jpg" alt="" title="p1402_pin3_continuity" width="300" height="200" class="size-medium wp-image-1386" /></a><p class="wp-caption-text">Continuity test between pin 3 and ground</p></div>
<p>Performing the same test against pins 2 and 4 results in no audible tone, so we know those pins aren&#8217;t grounded. </p>
<p>The same continuity tests for P1404&#8242;s pins 2, 3 and 4 produce the same results. Thus we know that for both P1402 and P1404 pin 3 is grounded and pins 2 and 4 are not.</p>
<hr />
<h1>Identifying Vcc</h1>
<p>Vcc is less important to identify since we don&#8217;t actually need to connect anything to it, but locating the Vcc pin is a good exercise and is useful in eliminating the Vcc pin as a possible candidate for transmit or receive.</p>
<p>Based on the trace widths, we suspect that pin 1 is Vcc; measuring the voltage on pin 1 when the board is powered on appears to confirm this:</p>
<div id="attachment_1387" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin1_continuity.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin1_continuity-300x200.jpg" alt="" title="p1402_pin1_continuity" width="300" height="200" class="size-medium wp-image-1387" /></a><p class="wp-caption-text">Measuring voltage on P1402 pin 1</p></div>
<div id="attachment_1423" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/3_3v.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/3_3v-300x200.jpg" alt="" title="3_3v" width="300" height="200" class="size-medium wp-image-1423" /></a><p class="wp-caption-text">A steady voltage reading on P1402 pin 1</p></div>
<p>The same voltage readings hold true for P1404&#8242;s pin 1 as well, suggesting that both P1402 and P1404 have pin 1 tied to Vcc.</p>
<p>Another method of identifying Vcc is to perform a continuity test between ground and the suspected Vcc pin. Although it may first appear counter intuitive, this will commonly result in a very short beep (though not a continuous tone).</p>
<p>What happens with the Vcc continuity test is that there is usually a filter capacitor connected between the Vcc pin and ground. This is done to eliminate any possible noise in the power lines on the PCB, and such filter capacitors are used liberally in any well designed board. Due to the nature of <a href="http://www.youtube.com/watch?v=NInt1Ss3vQ4">how capacitors work</a>, they will &#8220;pass&#8221; a direct current very briefly until they are charged to capacity, at which point they will cease &#8220;passing&#8221; direct current and will &#8220;block&#8221; direct current, resulting in the short beep observed during the continuity test (it is worth nothing that current doesn&#8217;t actually pass <em>through</em> a capacitor, although it appears that way to an outside observer). </p>
<p>Although it doesn&#8217;t always work, the continuity test is a more conclusive method of determining Vcc than simply measuring the voltage on each pin, as any number of pins could all read the same voltage. Note that you will also need a multimeter with a rather responsive continuity tester in order to perform this test properly; cheaper ones can take up to a second or more before they are triggered, at which point the capacitor has already been charged. Most multimeters in the $100 range should suffice.</p>
<hr />
<h1>Identifying the Transmit Pin</h1>
<p>The transmit pin is fairly easy to identify provided that the serial port is active and is transmitting data (and if it&#8217;s not, this entire effort will likely be futile anyway). The transmit pin on the board will be pulled high to the same voltage as Vcc (typically 3.3 volts). As it transmits bits of data, the voltage will drop to 0 volts (to send a &#8220;space&#8221;), then back to 3.3 volts (to send a &#8220;mark&#8221;). When reading a changing DC voltage, digital multimeters will end up displaying an average of the sampled voltage; this means that the average voltage &#8211; and thus, the voltage displayed on the multimeter &#8211; will briefly dip down during bursts of activity on the transmit pin. </p>
<p>The most activity on the transmit pin typically occurs during system boot up when all the boot information from the bootloader/kernel/system is being printed to the serial port. By monitoring pins 2 and 4 during boot, we should be able to easily identify which of them is the transmit pin. Let&#8217;s try header P1402 first:</p>
<div id="attachment_1388" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin2.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin2-300x200.jpg" alt="" title="p1402_pin2" width="300" height="200" class="size-medium wp-image-1388" /></a><p class="wp-caption-text">Measuring voltage on P1402 pin 2</p></div>
<div id="attachment_1389" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin4.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1402_pin4-300x200.jpg" alt="" title="p1402_pin4" width="300" height="200" class="size-medium wp-image-1389" /></a><p class="wp-caption-text">Measuring voltage on P1402 pin 4</p></div>
<p>The voltage readings for both pins 2 and 4 on header P1402 are a steady 3.3 volts with no fluctuations:</p>
<div id="attachment_1423" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/3_3v.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/3_3v-300x200.jpg" alt="" title="3_3v" width="300" height="200" class="size-medium wp-image-1423" /></a><p class="wp-caption-text">Voltage reading for P1402 pins 2 and 4</p></div>
<p>This is not encouraging, so let&#8217;s move on to the P1404 header. We&#8217;ll start with pin 2:</p>
<div id="attachment_1390" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_pin2.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_pin2-300x200.jpg" alt="" title="p1404_pin2" width="300" height="200" class="size-medium wp-image-1390" /></a><p class="wp-caption-text">Measuring voltage on P1404 pin 2</p></div>
<p>The voltage reading on pin 2 hovers around 40 millivolts for the first few seconds, then it jumps to a steady 2.3 volts:</p>
<div id="attachment_1424" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/40_mv.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/40_mv-300x200.jpg" alt="" title="40_mv" width="300" height="200" class="size-medium wp-image-1424" /></a><p class="wp-caption-text">Initial voltage reading for P1404 pin 2</p></div>
<div id="attachment_1425" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/2_3v.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/2_3v-300x200.jpg" alt="" title="2_3v" width="300" height="200" class="size-medium wp-image-1425" /></a><p class="wp-caption-text">Final voltage reading for P1404 pin 2</p></div>
<p>Let&#8217;s check pin 4 next:</p>
<div id="attachment_1432" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_pin4.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_pin4-300x200.jpg" alt="" title="p1404_pin4" width="300" height="200" class="size-medium wp-image-1432" /></a><p class="wp-caption-text">Measuring voltage on P1404 pin 4</p></div>
<p>The voltage reading for pin 4 is a steady 3.3 volts for the first few seconds:</p>
<div id="attachment_1423" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/3_3v.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/3_3v-300x200.jpg" alt="" title="3_3v" width="300" height="200" class="size-medium wp-image-1423" /></a><p class="wp-caption-text">Initial voltage reading for P1404 pin 4</p></div>
<p>Then suddenly we begin seeing rapid but substantial changes to the voltage on pin 4:</p>
<div id="attachment_1426" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/2_4v.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/2_4v-300x200.jpg" alt="" title="2_4v" width="300" height="200" class="size-medium wp-image-1426" /></a><p class="wp-caption-text">P1404 pin 4 voltage dropping to 2.4 volts</p></div>
<div id="attachment_1427" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/3_1v.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/3_1v-300x200.jpg" alt="" title="3_1v" width="300" height="200" class="size-medium wp-image-1427" /></a><p class="wp-caption-text">P1404 pin 4 voltage rising back up to 3.2 volts</p></div>
<div id="attachment_1428" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/2_3v1.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/2_3v1-300x200.jpg" alt="" title="2_3v" width="300" height="200" class="size-medium wp-image-1428" /></a><p class="wp-caption-text">P1404 pin 4 voltage dropping back down to 2.3 volts</p></div>
<p>There is definitely some activity on P1404&#8242;s pin 4, indicating that it is in fact an active data pin and likely the transmit pin of a serial port. </p>
<p>Although this is an effective method of identifying the transmit pin, it is worth noting that if the serial port only transmits a small amount of data, the voltage fluctuations will be too brief for the multimeter to register and you will need an oscilloscope or logic analyzer to capture the data activity on the transmit pin. This is rare however; usually there is ample data sent out on the serial port for this method to work.</p>
<hr />
<h1>Identifying the Receive Pin</h1>
<p>Definitively identifying the receive pin is the most difficult, as it has no truly unique defining characteristics. I have observed various voltages for the receive pin from one system to the next, including:</p>
<ul>
<li>Pulled high to the same voltage as Vcc</li>
<li>Pulled high to a voltage a few hundred millivolts lower than that of Vcc</li>
<li>Left &#8220;floating&#8221;, wildly fluctuating around a few hundred millivolts</li>
<li>Left &#8220;floating&#8221; for a few seconds and then pulled high when the serial port is initialized</li>
</ul>
<p>Since we have only one unknown pin left on both headers and we know that only P1404 is active, by process of elimination we can assume that pin 4 on P1404 is the receive pin. However, sometimes it just comes down to connecting a serial adapter to all possible receive pins individually, pressing a few keys in minicom (or your terminal emulator of choice) and seeing what happens. Speaking of connecting our serial adapter, let&#8217;s do just that. </p>
<hr />
<h1>Connecting a UART Adapter</h1>
<p>Inexpensive USB to UART adapters are <a href="http://www.digikey.com/product-detail/en/TTL-232R-3V3/768-1015-ND/1836393">readily available</a> and are supported by default on Linux &#8211; they just show up as a standard USB serial port and can be used with minicom, python, etc. We will need to connect our UART adapter to the serial port in the following manner:</p>
<ul>
<li>The adapter&#8217;s ground pin must be connected to the serial port&#8217;s ground pin</li>
<li>The adapter&#8217;s <em>transmit</em> pin must be connected to the serial port&#8217;s <em>receive</em> pin</li>
<li>The adapter&#8217;s <em>receive</em> pin must be connected to the serial port&#8217;s <em>transmit</em> pin</li>
</ul>
<p>The easiest method of accomplishing this is to cut a <a href="http://www.digikey.com/product-detail/en/4-103327-0/A26514-40-ND/297924">breakaway header</a> to size and solder it in to P1404:</p>
<div id="attachment_1435" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_header_pins.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/p1404_header_pins-300x200.jpg" alt="" title="p1404_header_pins" width="300" height="200" class="size-medium wp-image-1435" /></a><p class="wp-caption-text">Breakaway header soldered into place</p></div>
<p>And use some <a href="https://www.sparkfun.com/products/9140">male-to-female jumpers</a> to connect the appropriate pins between the serial port and the adapter:</p>
<div id="attachment_1436" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.devttys0.com/wp-content/uploads/2012/10/uart_adapter_connected.jpg"><img src="http://www.devttys0.com/wp-content/uploads/2012/10/uart_adapter_connected-300x200.jpg" alt="" title="uart_adapter_connected" width="300" height="200" class="size-medium wp-image-1436" /></a><p class="wp-caption-text">UART adapter wired to P1404</p></div>
<hr />
<h1>Discovering the Baud Rate</h1>
<p>With our hardware in place, we&#8217;re ready to start checking the serial port&#8217;s protocol settings. Serial ports can have a variety of settings, and we need to know all of them in order to communicate with the serial port:</p>
<ul>
<li>What is the baud rate?</li>
<li>How many data bits are used?</li>
<li>How many parity bits are used?</li>
<li>How many stop bits are used?</li>
</ul>
<p>Luckily, the de facto standard is to use 8 data bits, no parity bits and 1 stop bit (abbreviated as &#8220;8N1&#8243;), so that only leaves the baud rate unknown. Trial and error is the fastest and easiest method for identifying the baud rate. Since serial ports are typically used to display debug information (i.e., they transmit ASCII data), and there are only a small number of possible baud rates, it is practical to cycle through all possible baud rates until intelligible data is observed.</p>
<p>Or, at least that&#8217;s the way it works in theory. In practice all of the terminal emulation programs that I&#8217;ve used make it cumbersome to change the baud rate on the fly, if they even support doing so at all. To address this, I wrote a tool called <a href="http://baudrate.googlecode.com">baudrate</a> that attempts to auto detect the baud rate of an actively transmitting serial port (you can also manually cycle through each baud rate if you prefer). Once finished, it saves out a minicom compatible configuration file and optionally fires up minicom for you.</p>
<p>With our UART adapter connected, let&#8217;s run baudrate (I&#8217;m using manual mode for demonstration purposes, but the auto-detection feature works like a charm here as well):</p>
<blockquote>
<pre>
eve@eve:~$ <strong>sudo ./baudrate.py -p /dev/ttyUSB0</strong>

Starting baudrate detection on /dev/ttyUSB0, turn on your serial device now.
Press Ctl+C to quit.


@@@@@@@@@@@@@@@@@@@@@ Baudrate: 115200 @@@@@@@@@@@@@@@@@@@@@
</pre>
</blockquote>
<p>We can change the baud rate to the next higher/lower baud rate by pressing the up/down arrow keys respectively:</p>
<blockquote>
<pre>
@@@@@@@@@@@@@@@@@@@@@ Baudrate: 115200 @@@@@@@@@@@@@@@@@@@@@


@@@@@@@@@@@@@@@@@@@@@ Baudrate: 57600 @@@@@@@@@@@@@@@@@@@@@    <strong><--- Down arrow decreases baud rate</strong>


@@@@@@@@@@@@@@@@@@@@@ Baudrate: 115200 @@@@@@@@@@@@@@@@@@@@@    <strong><--- Up arrow increases baud rate</strong>
</pre>
</blockquote>
<p>OK, now let&#8217;s turn on the 9100EM and see what happens:</p>
<blockquote>
<pre>
@@@@@@@@@@@@@@@@@@@@@ Baudrate: 115200 @@@@@@@@@@@@@@@@@@@@@

Starting entry for CP1 @0xa3400000
memsize=52
CPU revision is: 00019641
Primary instruction cache 16kB, physically tagged, 4-way, linesize 32 bytes.
Primary data cache 16kB 4-way, linesize 32 bytes.
Linux version 2.4.21openrg-rmk1 #2 Thu Aug 28 19:30:48 CDT 2008
Determined physical RAM map:
User-defined physical RAM map:
 memory: 03400000 @ 00000000 (usable)
On node 0 totalpages: 13312
zone(0): 4096 pages.
zone(1): 9216 pages.
zone(2): 0 pages.
Kernel command line:  mem=52M
mips_counter_frequency:166666667
r4k_offset: 00196e6a(1666666)
Calibrating delay loop... 222.00 BogoMIPS
Memory: 44356k/53248k available (1568k kernel code, 8892k reserved, 6696k data, 4k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
Checking for 'wait' instruction...  unavailable.
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware on host bus 0.
Autoconfig PCI channel 0x801d19e0
Scanning bus 00, I/O 0x1ae00000:0x1b000001, Mem 0x18000000:0x1a000001
00:0e.0 Class 0200: 168c:001a (rev 01)
        Mem at 0x18000000 [size=0x10000]
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
...
</pre>
</blockquote>
<p>It looks like the first baud rate we tried, 115200, is correct (this is not surprising as 115200 is one of the more common baud rates used in practice). Pressing Ctl+C we can stop the capture and save the settings to a minicom config file, in this case I just named it &#8217;9100em&#8217;:</p>
<blockquote>
<pre>
Detected baudrate: 115200

Save minicom configuration as: <strong>9100em</strong>
 
Configuration saved. Run minicom now [n/Y]? <strong>n</strong>

eve@eve:~$
</pre>
</blockquote>
<hr />
<h1>Getting a Shell</h1>
<p>Now we can run minicom:</p>
<blockquote>
<pre>
eve@eve:~$ <strong>minicom 9100em</strong>
</pre>
</blockquote>
<p>And see what we get:</p>
<blockquote>
<pre>
...
12/31 19:00:57 - Starting SoC reset sequence...
12/31 19:00:58 - Clink FS shared data area written
12/31 19:00:58 - CLNK_ETH_CTRL_RESET returned status 0 after 0.914 seconds
12/31 19:00:58 - FSUPDATE: Pass = 1, Tuned Freq = 1000 MHz (8)
12/31 19:01:10 - Clink Reset Cause :0x4 Reg:0x80240100 Dbg:0x0
12/31 19:01:10 - Starting SoC reset sequence...
12/31 19:01:11 - Clink FS shared data area written
12/31 19:01:11 - CLNK_ETH_CTRL_RESET returned status 0 after 0.903 seconds
12/31 19:01:12 - FSUPDATE: Pass = 1, Tuned Freq = 1150 MHz (14)

Username: <strong>admin</strong>
Password: <strong>*********</strong>

Wireless Broadband Router> <strong>help</strong>
Error: help should be called with at least 1 argument
help   Show help for commands within this menu

Usage:
        help all - show all available commands in the current level
        help [category]... category - show commands in a certain category
        help [category]... command - show detailed help for a specific command
        help -s string - search for categories/commands containing the string

Availble help Categories
help upnp - show help about UPnP commands
help conf - show help about Read and write Wireless Broadband Router configuration data
help option_manager - show help about Option Manager
help fireball - show help about Fireball configuration and control
help cwmp - show help about CWMP related commands
help bridge - show help about API for managing ethernet bridge
help firewall - show help about Control and display Firewall and NAT data
help connection - show help about API for managing connections
help inet_connection - show help about API for managing internet connections
help misc - show help about API for Wireless Broadband Router miscellaneous tasks
help firmware_update - show help about Firmware update commands
help log - show help about Contorols Wireless Broadband Router logging behaviour
help dev - show help about Device related commands
help kernel - show help about Kernel related commands
help system - show help about Commands to control Wireless Broadband Router execution
help flash - show help about Flash and loader related commands
help net - show help about Network related commands
help cmd - show help about Commands related to the Command module

Returned -1
Wireless Broadband Router> <strong>help system</strong>

Command Category system - Commands to control Wireless Broadband Router execution
die               Exit from Wireless Broadband Router and return ret
ps                Print Wireless Broadband Router's tasks
entity_close      Close an entity
etask_list_dump   Dump back trace of all etasks
restore_default   Restore default configuration
reboot            Reboot the system
ver               Display version information
print_config      Print compilation configuration. Search for option if specified
exec              Execute program
cat               Print file contents to console
shell             Spawn busybox shell in foreground
date              Print the current UTC and local time
exit              Exit sub menu
help              Show help for commands within this menu

Returned 0
Wireless Broadband Router>
</pre>
</blockquote>
<p>Some serial ports require a login, others don&#8217;t. In this case the login was just the administrator user name and password for the device, which drops us to a custom command line shell with which we can manage the router. Based on the output from &#8216;<a href="http://www.youtube.com/watch?v=BgwU923Iaps&#038;t=29m45s">help</a>&#8216;, the &#8216;system shell&#8217; command should provide a root shell, which it does:</p>
<blockquote>
<pre>
Wireless Broadband Router> <strong>system shell</strong>

BusyBox v1.01 (2005.09.07-07:38+0000) Built-in shell (lash)
Enter 'help' for a list of built-in commands.

/ # <strong>cat /proc/cpuinfo</strong>
system type             : TWINPASS-E
processor               : 0
cpu model               : unknown V4.1
BogoMIPS                : 222.00
wait instruction        : no
microsecond timers      : yes
tlb_entries             : 16
extra interrupt vector  : yes
hardware watchpoint     : yes
VCED exceptions         : not available
VCEI exceptions         : not available
/ # 
</pre>
</blockquote>
<hr />
<h1>Conclusion</h1>
<p>That&#8217;s it! Using just a multimeter and some free software we have logically identified the serial port&#8217;s physical interface, discovered its baud rate and gotten a shell with which we can further interrogate the system. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.devttys0.com/2012/11/reverse-engineering-serial-ports/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
