<?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>debugmode</title>
	<atom:link href="http://debugmo.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://debugmo.de</link>
	<description>Projects, hardware fun and everything between it.</description>
	<lastBuildDate>Wed, 06 Mar 2013 22:02:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What&#8217;s Inside: Tektronix DPO5034</title>
		<link>http://debugmo.de/2013/03/whats-inside-tektronix-dpo5034/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=whats-inside-tektronix-dpo5034</link>
		<comments>http://debugmo.de/2013/03/whats-inside-tektronix-dpo5034/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 22:02:34 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[What's Inside]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=302</guid>
		<description><![CDATA[Expectations This post is about a teardown of an DPO5000 oscilloscope (DPO5034). This is a 2011, mid-range, Windows-based Tektronix oscilloscope. List price is $12.000, but eBay has them &#8211; used &#8211; down to $5500 or so if you&#8217;re lucky. This particular model is a 350MHz, 5Gs/s model without MSO functionality (adding 16 digital channels, a [...]]]></description>
			<content:encoded><![CDATA[<h1>Expectations</h1>
<p>This post is about a teardown of an DPO5000 oscilloscope (DPO5034). This is a 2011, mid-range, Windows-based Tektronix oscilloscope. List price is $12.000, but eBay has them &#8211; used &#8211; down to $5500 or so if you&#8217;re lucky. This particular model is a 350MHz, 5Gs/s model without MSO functionality (adding 16 digital channels, a &#8220;poor man&#8217;s logic analyzer&#8221; -even though it rather *makes* you poor when buying it, since it&#8217;s pretty expensive). The higher end models in that series support up to 2GHz bandwidth, 10GS/s (albeit only on two channels in an interleaving configuration) and  support the &#8220;MSO&#8221; function out of the box. The top-end model (MSO5204) has a list price of $28.700. What do we expect from a teardown of an oscilloscope?</p>
<p><a href="http://www.microwavejournal.com/articles/10796-time-is-on-our-side-oscilloscopes-for-microwave-engineering">http://www.microwavejournal.com/articles/10796-time-is-on-our-side-oscilloscopes-for-microwave-engineering</a> has a block diagram that we somehow expect to find in our scope:</p>
<div style="background:#ffffff"><img src="http://www.microwavejournal.com/legacy_assets/images/10436_Figure4x500.gif"></div>
<p>That block diagram isn&#8217;t too surprising. What will be more interesting is how they actually implemented it. Turns out &#8211; there&#8217;s a lot of commodity hardware in it, but also a bunch of custom ASICs. </p>
<p>Here&#8217;s a picture of the mainboard (click <a href="https://picasaweb.google.com/106225052902927978382/DPO5034Teardown?authuser=0&#038;authkey=Gv1sRgCMaH68jnt-uPKw&#038;feat=directlink">here</a> for the raw pictures). </p>
<p><a href="https://picasaweb.google.com/lh/photo/U7FF6DA7bwapyYeTv6eu9taArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh5.googleusercontent.com/-AnDFr5LeNWo/UTZ9WIX6jII/AAAAAAAAUfs/kpNqWEoCoEU/s640/block%2520diagram%2520mainboard.jpg" height="287" width="640" /></a></p>
<p>But before the signal gets here, it will first go through the analog frontend. But guess what &#8211; I&#8217;ve opened up that one, too!</p>
<h1>Analog Frontend</h1>
<p>The analog frontend is a seperate board that sits in the front of the oscilloscope (behind the frontpanel).</p>
<p><a href="https://picasaweb.google.com/lh/photo/vYYd1KM1-KQViKOua6Ak_9aArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh3.googleusercontent.com/-idhHK0wH0Vg/UTZ9WD38B1I/AAAAAAAAUfo/GsXxmlo6Gs0/s640/block%2520diagram%2520afe.jpg" height="489" width="640" /></a></p>
<p>The signal enters the oscilloscope on the BNC connectors on the front of the scope. Additionally to the signal connection, there are data connections and power supplies for the probe &#8211; called TekVPI. Those data and power connections are handled by the front panel, which I did not photograph. It&#8217;s mostly 12V plus I2C and an interrupt pin.</p>
<p>The frontend attenuates/amplifies the signal and converts it to a 50-Ohm differential signal suitable for the ADC. All the low-noise operation happens in this path of the scope. The analog frontend consists of 4 channels, each with an optional 50-Ohm coupling or optional AC-coupling, a passive (RC-based) attenuation circuit with selectable signal paths, an active pre-amplifier with a Tektronix-ASIC (internally called &#8220;Tek026&#8243; though the package mark doesn&#8217;t mention this part number) and a bandwidth-limiting lowpass filter (implemented as a differential pi-Filter). Higher-bandwidth scopes (1 GHz and 2 GHz models) have an additional second-pass pre-amp called &#8220;Hfd144&#8243;, which is not present on my 350 MHz scope.</p>
<p>Additionally there is the &#8220;Aux&#8221; channel, which is good for triggering only. On the MDO4000-Series, which use the same architecture (but a different Analog Frontend) as the DPO5000-Series, instead of the Aux channel, there is a dedicated RF channel.</p>
<h1>Trigger Asic</h1>
<p><a href="https://picasaweb.google.com/lh/photo/rA2kMOMw4Fkf5SsvEVdl89aArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh5.googleusercontent.com/-8SEc96w6lJk/UQj2I1ZpMqI/AAAAAAAAUYk/XBE2roa9VJc/s640/DSC_0656.JPG" height="424" width="640" /></a></p>
<p>This oscilloscope uses the Tek005 trigger IC, again a Tektronix-specific ASIC. Triggering must be done on the analog signal in order to achieve a sub-sample trigger timing, which is required for things like equivalent-time (ET) sampling. (Equivalent Time sampling is widely explained on the internet, however there is one bit of &#8220;magic sauce&#8221; that&#8217;s usually missing from the explanation: The information on how to re-align the different samples with each other. The answer is that there is a special circuit in an oscilloscope called &#8220;timebase interpolator&#8221;, that can establish the exact trigger point between two ADC samples. For example, if the oscilloscope supports sampling the analog signal with a sample rate of 5 GS/s, there is an ADC value for every 200ps. If the triggering would be digital,  this would be the trigger resolution. Since triggering, at least for simple trigger modes like &#8220;Edge&#8221;, is done on the analog signal, the timebase interpolator can often pinpoint the trigger point down to 10ps or less. By obtaining multiple traces, all shifted by a random sub-cycle delay, a more accurate waveform can be assembled.)</p>
<p>The trigger ASIC also interfaces to the &#8220;slow&#8221; <a href="http://download.micron.com/pdf/datasheets/dram/sdram/256MSDRAM.pdf">MT48LC16M16A2-7E</a> SDRAM (8 chips total, total 256 MByte, or 128 MSamples), which is used for the MSO feature. The total theoretical memory bandwidth is 8 x 16 x 133 Mhz, or 2128 MByte/s, easily covering 500 MSamples/s (each sample being 16 bit). So the MSO feature is actually implemented in the Trigger IC. The &#8220;MagniVu&#8221; feature, which allows capturing with up to 16.5 GSamples/s, but only up to 10k points, is also implemented directly in this IC.</p>
<h1>ADC</h1>
<p><a href="https://picasaweb.google.com/lh/photo/UyaayIKus7-2jqKHo9eWk9aArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh6.googleusercontent.com/-7QsQJebAdBM/UTaALi_ZyeI/AAAAAAAAUf4/pkuZaQeXKdE/s640/DSC_0649_text.jpg" height="424" width="640" /></a></p>
<p>The Tektronix DPO5000-Series supports a sample rate of 5 GS/s when all channels are enabled. That means that there is a total sampling capacity of 20 GS/s on this model &#8211; distributed to the four analog channels. Some models (the 1 GHz and 2 GHz models) allow combining the sample rate of two channels into a single channel, thereby allowing sampling up to two channels at 10 GS/s. It must be noted that no different ADC configuration is used for these models. The 20 GS/s are divided over two ADC chips. Each ADC outputs 10 Gbyte/s of data. </p>
<h1>Demux</h1>
<p>The heart of the oscillscope is a device called &#8220;demux&#8221;.  A demux connects the ADCs with the Acquisition Memory &#8211; in the DPO5000, there are 4 chips for each of the 4 demux. The chips are marked &#8220;D9LHT&#8221;, and <a href="http://www.micron.com/products/support/fbga?fbga=D9LHT">Micron&#8217;s FBGA part decoder</a> tells us that these are MT47H64M16HR-25E:H &#8211; 1 Gbit of DDR2-800 SDRAM. That&#8217;s 512 Mbyte per demux, with a theoretical bandwidth of 800 Mhz x 16 Bits x 4 Chips / 8 Bits = 6.4 Gbyte/s &#8211; barely enough to stream the 5GS/s (=5Gbyte/s) to memory. So the main task for the demux is to store the incoming data from the ADCs to memory. </p>
<p>But the demux also includes a DSP that can provide FIR filtering and other general-purpose data processing on the buffers. This is used for the MDO4000-models, which feature an RF data path, where the Demux-pair (two of the four available are used for the RF path, the other two are used for the analog channels) is used to demodulate the incoming time-domain samples into I and Q, and also transforms them into frequency-domain for a spectrum-analyzer display. </p>
<p>Additional data processing is also used for the &#8220;Enhanced Bandwidth&#8221;-feature, where DSP filters are used to fix a probe&#8217;s frequency response &#8211; the software includes tables for various probes, sometimes even in combination with a specific probe solder-down connector (one example being &#8220;P7380 Right-Angle Flex_25X.flt&#8221;)! This is mostly relevant for the ultra-high bandwidth probes, and thus not really relevant to the midrange scopes.</p>
<p>The demux also contains the &#8220;FastAcq&#8221; or &#8220;DPO&#8221; feature, which is basically an embedded framebuffer with 21-bit counters per pixel. <a href="http://www.tek.com/document/technical-brief/advanced-statistical-analysis-using-waveform-database-acquisition">http://www.tek.com/document/technical-brief/advanced-statistical-analysis-using-waveform-database-acquisition</a> has some more technical details on the DPO/FastAcq feature.</p>
<h1>Display</h1>
<p>The demuxes communicate with an FPGA called &#8220;Mia&#8221;, which merges the outputs of the four channels, and then generates the actual pixel data that is displayed on the screen. The data is transmitted over PCI Express to the integrated PC for display on the integrated touch-screen.</p>
<h1>Comparing DPO5000 with the DPO4000B and MDO4000</h1>
<p>It&#8217;s interesting to compare the DPO5000 oscilloscope with a second-gen DPO4000 (called &#8220;DPO4000B&#8221;-Series) or with the MDO4000. EEVBlog has a nice teardown of a MDO4000 <a href="http://www.flickr.com/photos/eevblog/sets/72157627449876285/with/6104863563/">here</a>.<br />
The obvious part is that the DPO4000-series uses a Linux-based firmware instead of a Windows-based firmware. The DPO5000 comes with an integrated PC that connects to the rest of the scope via a PCI-Express link to &#8220;Mia&#8221; (via a PLX PCI-Express bridge). The DPO4000 does not have this PC (nor the PCIe bridge) &#8211; instead, it has an on-board PowerPC processor that interfaces to Mia, and a few support peripherals (Ethernet Phy, Flash, RAM). </p>
<p>DPO4000 and DPO5000 share the same front-panel, though in slightly different configurations (the DPO4000 has a few buttons around the screen, whereas the DPO5000 has a touch-screen; the MDO4000 additionally has the numeric keypad on the right).</p>
<p>The lower-bandwidth (<1 GHz) DPO4000(B)-Series scopes only support 2.5 GS/s on all four channels - they only have one ADC chip (and two instead of four demuxes).<br />
On the MDO4000-Series, which has the dedicated RF-Input additionally to the analog channels, 10 GS/s, i.e. half of the ADC power, is dedicated to the RF signal. That is why even the higher-bandwidth MDO4000-Models can only capture 5 GS/s on two channels - they have the same ADC configuration as the DPO5000, but already use half of them for RF.</p>
<h1>&#8220;You get what you pay for&#8221;</h1>
<p>The more high end a scope is, the more additional features can be enabled with purchased &#8220;Options&#8221;. This is not only true for Tektronix scopes, it&#8217;s also true for most other test instruments. The reversed logic of this is that the scope itself is more capable, at least in terms of what the hardware can do, than what&#8217;s exposed in the firmware.<br />
For example, we figured out that this scope has 512 Mbyte of RAM per demux. If we assume &#8220;one channel is one demux&#8221; configuration (which is a bit too simplified, but not exactly wrong), that means that the scope could &#8211; in theory &#8211; have a capture depth of 512MSamples. By default, the scope does have a maximum of 12.5 Msamples. Even if we take into account that the user might display up to 4 reference waveforms and 4 math waveforms, and the demux may also store the rasterizer (display) data, that&#8217;s still more than 128 Mbyte per channel, a huge difference to the 12.5 Msamples that the scope offers.</p>
<p>The answer is easy &#8211; there&#8217;s an option, called &#8220;10RL&#8221;, which, according to a <a href="http://www.tti1.co.uk/products-resale/tek/tek-price-hv.pdf">price list</a>, goes for a whopping 7920 Euro, which bumps up the sample depth to 125 Msamples &#8211; without a hardware change, of course, just by entering a software key. I&#8217;d rather skip the discussion about how you pay to use the hardware that you already bought…<br />
Ethically simpler is the discussion about protocol decoder options &#8211; for example the &#8220;SR-COMP&#8221; option that allows you to decode and trigger on RS232 signals that goes for 1480 Euro. That&#8217;s simply software that&#8217;s shipped with your scope, but not enabled &#8211; which I understand: development of this software costs money, so it makes sense to have only people pay for the development who are actually using the software (whether that price is appropriate though can be debated, but should not be an excuse for pirating that feature). </p>
<p>However, that&#8217;s something else from simply limiting the amount of capture memory &#8211; though even in that case you could argue that they may &#8220;subsidize&#8221; the cost of DRAM. But 7920 Euro for a roughly Gbyte worth of RAM? Last time I&#8217;ve checked  a Gbyte of RAM was about 20 Euro &#8211; remember, we&#8217;re talking about standard DDR2 memory, not anything high-speed or custom.</p>
<p>I feel similarly about the &#8220;MSOE&#8221; option &#8211; which enables the use of the existing MSO feature. But either way, I don&#8217;t want to discuss Tektronix&#8217;s business model here. If I wouldn&#8217;t like it, I wouldn’t have bought their hardware.</p>
<h1>Bandwidth</h1>
<p>A much simpler topic then becomes the bandwidth limitation. Tektronix doesn&#8217;t sell a bandwidth upgrade for this scope (unlike for some other series, like the DPO3000), which indicates that bandwidth is indeed a physical limitation, not a software setting. We&#8217;ve seen scope bandwidth hacks before (<a href="http://www.instructables.com/id/Hacking-the-Rigol-DS1052E-Oscilloscope-with-Linux/">http://www.instructables.com/id/Hacking-the-Rigol-DS1052E-Oscilloscope-with-Linux/</a>), where the bandwidth limit was set by a software-controllable filter. Looking at the analog frontend again, we see a suspicious looking circuit:</p>
<p><a href="https://picasaweb.google.com/lh/photo/4kqwGDnoUfQ7NJDuA1nWbNaArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh3.googleusercontent.com/-o1vkgk7gvsE/UTaDKeXDJWI/AAAAAAAAUgU/9CaKxgSJURk/s400/wtfilter.jpg" height="400" width="224" /></a></p>
<p>Would this be a first-order differential low-pass filter? In fact, in bypassing this circuit (and thus removing the anti-alias filter &#8211; please know what you&#8217;re doing, and of course you will loose all warranties, and every time you do this an engineer will die in heaven), suddenly frequencies above 350 MHz become much happier and will make it to the ADCs: (left is an unmodified channel, right is a modified one)</p>
<table>
<tr>
<td><a href="https://picasaweb.google.com/lh/photo/EAu5FpUzOamKWiUojgoHYNaArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh6.googleusercontent.com/-4gijENiuHOM/UTaAjE0nCII/AAAAAAAAUgI/TE8iU5QoY-4/s400/sata_nontweaked000.png" height="230" width="320" /></a></td>
<td>
<p><a href="https://picasaweb.google.com/lh/photo/hyHy-7DK1s99izWZclKbWdaArMQLX0LqNmHIo30nlCo?feat=embedwebsite"><img src="https://lh3.googleusercontent.com/-ghlmxDhDzxU/UTaAjM3kogI/AAAAAAAAUgM/HLE_oszUvmI/s400/sata_tweaked000.png" height="230" width="320" /></a></td>
</tr>
</table>
<p>(This is Gen1 SATA, hence a fundamental frequency of 750 MHz. With a bit of postprocessing, I could even capture Gen1 PCIe with its 1.25 GHz fundamental and decode the bits in software.)</p>
<p>This is of course not the same as an actual instrument with that bandwidth. As mentioned, the 1 GHz+ models have an additional pre-amplifier stage, and of course a well-defined bandwidth limitation. I&#8217;m betting that my hacked up channel doesn&#8217;t have a flat response up to the maximum anymore, but I lack the equipment to actually characterize the behavior.</p>
<h1>Mysteries Left</h1>
<p>There are a few mysteries left.</p>
<ul>
<li>What&#8217;s the unpopulated device at the top right on the mainboard?</li>
<li>Why is the MSO acquisition RAM twice as big and twice as fast as required by the specs?</li>
<li>What the hell did they think when they designed the user interface of the frontpanel? (I could rant about this for hours. The DPO4000&#8242;s UI is designed for this frontpanel, and &#8220;makes sense&#8221;. The DPO7000 (and all higher end models) have a slightly larger front panel, which for example allows directly changing the trigger source. The DPO5000, however, has the UI logic of the DPO7000, but the frontpanel of the DPO4000. This combination makes no sense. Barely a function can be achieved without using the touchscreen. On the other hand, there are countless buttons (when was the last time you &#8211; intentionally &#8211; pressed &#8220;Autoset&#8221;? Default setup? &#8220;R&#8221;? &#8220;Play/Pause&#8221;? Why are there two &#8211; lighted! &#8211; dedicated buttons for &#8220;Coarse&#8221; and &#8220;Fine&#8221;, but no dedicated button for switching between &#8220;offset&#8221; and &#8220;position&#8221;? Why is there a dedicated &#8220;intensity&#8221; button? This could go on for a while.) Please, Tektronix, either allow customization of Frontpanel button to UI mapping, or just have someone use this scope for a day and then reimplement the mapping.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2013/03/whats-inside-tektronix-dpo5034/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real Life Statistics</title>
		<link>http://debugmo.de/2013/03/real-life-statistics/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=real-life-statistics</link>
		<comments>http://debugmo.de/2013/03/real-life-statistics/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 22:02:26 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=292</guid>
		<description><![CDATA[I recently noticed the above relationship between posts-per-year and family size. This is Paul Matti, born 2012-03-05 (07:01am). He turned one today, and his sister also thinks that he is awesome.]]></description>
			<content:encoded><![CDATA[<p><img src="http://debugmo.de/wp-content/uploads/2013/03/ppyc.png" alt="" title="Post-per-year vs. Family Size" width="554" height="436" class="alignnone size-full wp-image-293" /><br />
<span id="more-292"></span><br />
I recently noticed the above relationship between posts-per-year and family size.</p>
<p><a href="https://picasaweb.google.com/lh/photo/dHj6goMyg9I0Okl_Qy1f9mKFMf1wVFVAnjeji9UpoN0?feat=embedwebsite"><img src="https://lh6.googleusercontent.com/-vx5oRaWNKME/T1vR_9QzxHI/AAAAAAAAQMI/UZ_kKiQ_JWo/s640/DSC_6785.jpg" height="367" width="554" /></a> <br />
This is Paul Matti, born 2012-03-05 (07:01am). He turned one today, and his sister also thinks that he is awesome.<br />
<a href="https://picasaweb.google.com/lh/photo/CXQ5ceNcHiRNS5NCAK5KEzcezply8C_5P0JZxDuqiUA?feat=embedwebsite"><img src="https://lh3.googleusercontent.com/-HMRmCE7a8q4/UPEvtWCgBHI/AAAAAAAAUOY/mauFl-KGxUw/s640/DSC_0302.JPG" height="367" width="554" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2013/03/real-life-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xvcd &#8211; The Xilinx Virtual Cable Daemon</title>
		<link>http://debugmo.de/2012/02/xvcd-the-xilinx-virtual-cable-daemon/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xvcd-the-xilinx-virtual-cable-daemon</link>
		<comments>http://debugmo.de/2012/02/xvcd-the-xilinx-virtual-cable-daemon/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 00:05:23 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=275</guid>
		<description><![CDATA[I recently discovered an almost undocumented function in Xilinx ISE: the Xilinx virtual cable driver. It&#8217;s basically &#8220;a platform cable without a platform cable&#8221; (as marcan said so nicely) &#8211; it allows you use Impact (and Chipscope, and all other tools) over TCP/IP. Normally, ISE comes with a limited set of cable drivers: It supports [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered an almost undocumented function in Xilinx ISE: the Xilinx virtual cable driver. It&#8217;s basically &#8220;a platform cable without a platform cable&#8221; (as <a href="http://marcansoft.com/blog/">marcan</a> said so nicely) &#8211; it allows you use Impact (and Chipscope, and all other tools) over TCP/IP.<br />
<span id="more-275"></span><br />
Normally, ISE comes with a limited set of cable drivers: It supports cables on the parallel port, such as the Xilinx Parallel Cable III (DLC5), which can be <a href="http://dev.ivanov.eu/index.php?page=dlc5-jtag">DIY&#8217;ed easily</a>, or the faster <a href="http://www.xilinx.com/support/documentation/data_sheets/ds097.pdf">Xilinx Parallel Cable IV</a> (which has an integrated CPLD), or the &#8211; quite expensive, but also <a href="http://bunniestudios.com/blog/images/ntw_mar_2011_full.jpg">sophisticated</a> &#8211; <a href="http://www.xilinx.com/support/documentation/data_sheets/ds593.pdf">USB Platform cables</a>. There are also cheap clones of the platform cables (the first version used an FX2+CPLD), which I won&#8217;t link to, and then there&#8217;s <a href="http://digilentinc.com/">Digilent Inc.</a>, which build actually useful FPGA development board, which have a USB platform cable on board (like the very cool, but slightly outdated <a href="http://www.xilinx.com/products/boards-and-kits/HW-SPAR3A-SK-UNI-G.htm">Spartan-3A starter kit</a>). Unfortunately, the USB platform cable itself is mysteriously missing in the schematics. Newer boards as the <a href="http://www.digilentinc.com/atlys/">Digilent Atlys</a> or the <a href="http://www.xilinx.com/products/boards-and-kits/AES-S6MB-LX9.htm">Avnet Spartan-6 LX9 MicroBoard</a> (an, excuse me, terrible board &#8211; but that aside) don&#8217;t have the clumsy and expensive FX2+CPLD combination anymore. Instead, they come with a cheaper solution and a corresponding plugin for the Xilinx tools. However, the plugin SDK is not available publicly, so it&#8217;s not easily possible to write a plugin for arbitrary JTAG dongles (like a generic FTDI 2232 board) without either licensing the SDK or reversing the API.</p>
<p>For <a href="http://openvizsla.org/">OpenVizsla</a> I wanted to get programming working from Impact. Programming the CPLD and FPGA is supported via an on-board FTDI chip, and usually done with <a href="http://urjtag.org/">urjtag</a>. However, you can&#8217;t use &#8211; for example &#8211; <a href="http://www.xilinx.com/tools/cspro.htm">Chipscope</a>. </p>
<p>There are solutions like <a href="http://rmdir.de/~michael/xilinx/">this neat hack</a>, which basically LD_PRELOADs into ISE, pretends to be libusb, provides a virtualized platform cable, and then talks to some different back end. </p>
<p>But it turns out &#8211; there&#8217;s a much easier, albeit undocumented, solution. It&#8217;s called <em>xilinx_xvc</em>, or &#8220;Xilinx Virtual Cable&#8221;. It&#8217;s a plugin &#8211; the only one next to the Digilent plugin &#8211; that can be used as a cable. It opens a TCP connection to a specific host, and sends JTAG &#8220;shift&#8221; instructions over TCP. The protocol is really, really simple: There&#8217;s only one command that I ever saw being used, called <code>shift:</code>. After that, a 32-bit little endian word specifies the number of bits, and after that, two byte-padded strings are the bits to be shifted out on TMS and TDI (in that order). The response is a byte-padded string of the bits shifted out on TDO. That&#8217;s all &#8211; a nice, abstracted JTAG PHY.</p>
<p>I implemented a client for this for the awesome <a href="http://kosagi.com/w/index.php?title=NeTV_Main_Page">NeTV</a> <a href="https://github.com/tmbinc/xvcd">here</a> (requires some hardware hacking though to get the JTAG pins connected), and a generic FTDI version (based on libftdi) <a href="https://github.com/tmbinc/xvcd/tree/ftdi">here</a> (feel free to merge and send me a pull request!).</p>
<p>The xvcd is a daemon that listens on port 2542, and allows multiple programs to access the JTAG chain at the same point (it switches between them only when it&#8217;s &#8220;safe&#8221;; it relies on the programs to idle the chain every once in a while by going through TLR and then staying in RTI). It also works around a weirdness where Impact, whenever an IR or DR is written, goes back to the Capture-IR/DR state before exiting back to RTI (which almost always screws up the register). xvcd follow the JTAG state machine and just ignores this these instructions. </p>
<p><a href="http://debugmo.de/wp-content/uploads/2012/02/xvcd.jpg"><img src="http://debugmo.de/wp-content/uploads/2012/02/xvcd-300x258.jpg" alt="" title="xvcd" width="300" height="258" class="alignnone size-medium wp-image-276" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2012/02/xvcd-the-xilinx-virtual-cable-daemon/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What&#8217;s Inside: Hilti PD-30</title>
		<link>http://debugmo.de/2011/12/whats-inside-hilti-pd-30/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=whats-inside-hilti-pd-30</link>
		<comments>http://debugmo.de/2011/12/whats-inside-hilti-pd-30/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 23:00:48 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[What's Inside]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=253</guid>
		<description><![CDATA[I love physics hacks, and I consider phase shift measurements in general as a great hack. As a consequence, I love laser distance meters. A while ago I took apart a Fluke 411D &#8211; coincidentally with nearly identical results as this SparkFun tutorial: I disassembled it, found the serial port, found the &#8220;?\r\n&#8221;, tried sending [...]]]></description>
			<content:encoded><![CDATA[<p>I love physics hacks, and I consider phase shift measurements in general as a great hack. As a consequence, I love laser distance meters.</p>
<p><a href="http://lh6.googleusercontent.com/-yCxgGn3Arow/TvEtfRbfOmI/AAAAAAAAP7M/RVjGT5cNao0/s1600/DSC_5711.JPG"><img src="http://lh6.googleusercontent.com/-yCxgGn3Arow/TvEtfRbfOmI/AAAAAAAAP7M/RVjGT5cNao0/s640/DSC_5711.JPG"></a><span id="more-253"></span></p>
<p>A while ago I took apart a <a href="https://picasaweb.google.com/tmbinc1337/Fluke411D?authuser=0&#038;authkey=Gv1sRgCK_sjqa_ntObiwE&#038;feat=directlink#5609427481377216178">Fluke 411D</a> &#8211; coincidentally with nearly identical results as <a href="http://www.sparkfun.com/tutorials/323">this SparkFun tutorial</a>: I disassembled it, found the serial port, found the &#8220;?\r\n&#8221;, tried sending all kind of data to the other &#8220;RX&#8221; pins &#8211; and didn&#8217;t receive any answer from the device.</p>
<p>Now I was able to take a look at a (much more expensive) <a href="http://www.hilti.com/data/editorials/-18276/PD%2030_32_en.pdf">Hilti PD-30 [PDF]</a>. </p>
<p>It has a much better build quality (which is kind of expected for a 4x expensive device) &#8211; for example it has a glass lens, and the transmit and receive parts are much better aligned and glued together:</p>
<p><a href="https://lh4.googleusercontent.com/-2DOziqiBAYQ/TvEtd2K7fDI/AAAAAAAAP7k/fwP5ned2tlc/s1600/DSC_5708.JPG"><img src="https://lh4.googleusercontent.com/-2DOziqiBAYQ/TvEtd2K7fDI/AAAAAAAAP7k/fwP5ned2tlc/s640/DSC_5708.JPG" /></a></p>
<p>On the Fluke 411D some misalignment had caused the distance range to be significantly impaired (to ~3m) &#8211; very well possible from 3 missing &#8220;shipping screws&#8221; (screws that are left over after you re-assemble a device) that apparently were much more important than I&#8217;ve thought&#8230; </p>
<p>Another interesting tidbit is the difference between the PD-30 and the PD-32: The Hilti PD32 feature two more measurement modes and have two more buttons. Turns out &#8211; the PD30 also has these features, and the buttons are&#8230; not quite&#8230; there. </p>
<p><a href="https://lh4.googleusercontent.com/-DIltiobe8y4/TvEtZzmjtsI/AAAAAAAAP7Q/tAaDkt3mTKo/s1600/DSC_5704.JPG"><img src="https://lh4.googleusercontent.com/-DIltiobe8y4/TvEtZzmjtsI/AAAAAAAAP7Q/tAaDkt3mTKo/s640/DSC_5704.JPG" /></a></p>
<p>So yes, if you press those &#8220;internal&#8221; buttons, they actually work! There&#8217;s even an unexposed (populated!) trigger button on the side.</p>
<p>The microcontroller is a NEC (now Renesas) &#8220;PD3X&#8221; &#8211; where PD3X probably just indicates that they are programmed with a Hilti-supplied Mask ROM for the PD-3X series. That&#8217;d also explain why the PD-32 features are easily available. There&#8217;s also a serial port, which is &#8211; as inverted TTL &#8211; available on the outside. And guess what &#8211; upon power on (and power off), exactly three bytes are transmitted: &#8220;?\r\n&#8221; (interestingly at 9600-7E1). This design seems to be at least related to the Fluke 411D (or the identical &#8220;Prexiso X2&#8243;).</p>
<p>(<a href="https://picasaweb.google.com/tmbinc1337/HiltiPD30?authuser=0&#038;authkey=Gv1sRgCKvn98Sp3M3dTA&#038;feat=directlink#5688377725717558978">Click here for all photos</a>)</p>
<p><strong>Update:</strong></p>
<p><a href="https://lh4.googleusercontent.com/-JPNLxvVOBdw/TvO-vvXqWZI/AAAAAAAAP70/-9xCbvz5pF8/s1600/DSC_5717-1.JPG"><img src="https://lh4.googleusercontent.com/-JPNLxvVOBdw/TvO-vvXqWZI/AAAAAAAAP70/-9xCbvz5pF8/s640/DSC_5717-1.JPG" /></a></p>
<p>Apart from RX and TX being inverted (which is easily fixable with a FT232RL which can be <a href="http://www.ftdichip.com/Support/Utilities.htm#FT_Prog">eeprom-programmed</a> to use inverted UART signals) it &#8220;just works&#8221; &#8211; commands like &#8216;a&#8217; (reset/online mode), &#8216;h&#8217; (tracking) and &#8216;N00N&#8217; (display firmware version) work. More commands can be found for example <a href="http://www.distochina.com/pdf/interfaceManual111_en.pdf">here</a>, but not all of them work. The probably most important one, &#8220;tracking&#8221;, works just fine!</p>
<p>Unfortunately that also means that for the Fluke 411D (or the equivalent versions), the serial port really just doesn&#8217;t react to otherwise &#8220;valid&#8221; commands &#8211; people (including me) have definitely tried &#8220;a\r\n&#8221;. Maybe it requires some special activation sequence, or some special eeprom settings. Who knows&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2011/12/whats-inside-hilti-pd-30/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Almost Secure</title>
		<link>http://debugmo.de/2011/11/almost-secure/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=almost-secure</link>
		<comments>http://debugmo.de/2011/11/almost-secure/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 23:11:19 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=238</guid>
		<description><![CDATA[Vulnerabilities are like good ideas &#8211; you&#8217;re rarely the first one dealing with it. Some vulnerabilities are almost classic, so I&#8217;ll proudly present: 7 old but surprisingly useful bugs that might also affect YOUR device. (With &#8220;you&#8221; either being the designer or attacker.) Just to be clear: none of these exploits are rocket science. This [...]]]></description>
			<content:encoded><![CDATA[<p>Vulnerabilities are like good ideas &#8211; you&#8217;re rarely the first one dealing with it. Some vulnerabilities are almost classic, so I&#8217;ll proudly present: 7 old but surprisingly useful bugs that might also affect YOUR device.<br />
<span id="more-238"></span><br />
<small>(With &#8220;you&#8221; either being the designer or attacker.)</small></p>
<p>Just to be clear: none of these exploits are rocket science. This is kind of the &#8220;low tech&#8221; hacking approach &#8211; no fancy oscilloscopes required, no DPA involved, no FIB to rent. There&#8217;s not even code to disassemble!</p>
<h1>1. ext2 Symlink Directory Traversal</h1>
<p>The first vulnerability is a classic oversight. It applies to many devices that are accepting a mass-storage device (for example USB or micro-SD) and are somehow exposing the contents of this to the outside world. This includes WLAN/3G access points with a &#8220;file share&#8221; ability, NAS and a lot of special purpose devices. Slightly linux-centric (but I&#8217;m sure it applies to many other operating systems as well), these devices usually try to support multiple filesystems by using the equivalent of the &#8220;mount -t auto&#8221;, automatically trying all filesystems from /proc/filesystems when mounting, until one filesystem handler  succeeds in mounting.</p>
<p>While supporting multiple filesystems is normally meant to support FAT, NTFS and maybe HFS+, most kernels also have ext2/ext3 support compiled in; sometimes the rootfs of these devices also uses ext2. This means that if you attach an ext2 formatted storage device, it will be mounted as well. If the device exposes access to this filesystem, it gives you a lot of toys to play with: symlinks, device nodes and all the fancy features.</p>
<p>For example, if the device allows you to browse the attached mass storage, a simple symlink to / might allow you to browse the rootfs:<br />
<code><br />
lrwxrwxrwx  1 root root     13 Oct 25 09:59 rootfs -> /<br />
</code></p>
<p>Certainly, you&#8217;re bound to the permissions of the process that does the access to the files. However, in embedded devices, designers rarely use user permissions (and instead only expose restricted functionality in the application), and since they probably never thought about ext2, restricting permissions and jailing (chroot etc.) wasn&#8217;t deemed useful. After all, vfat partitions (for example) can&#8217;t contain symlinks or useful multi-user permission bits (with HFS+ it&#8217;s a different story, of course).</p>
<p>On this particular device, a configuration file was copied on bootup from an insecure attached mass-storage device to an internal (but still insecure) storage. This allows to place a symlink on the mass-storage device pointing to any regular file in the root partition. It didn&#8217;t allow browsing in the root file system, but could be used to retrieve regular files (so no character devices) with a known filename.</p>
<h1>2. Non-Appropriate Crypto Modes give you a Decryption Oracle</h1>
<p>AES (or any other modern cryptographic standard) is considered &#8220;secure&#8221;. This fact is easy to remember, given that AES is still the recommendation for newly-designed crypto schemes. However, it&#8217;s much harder to understand what &#8220;secure&#8221; actually means. For block ciphers, one important property is that there is, given (even a large number of) ciphertext/plaintext pairs, no more efficient way to recover the key used in the encryption than to do a full brute-force attack over the key space. (There are a few other scenarios that block ciphers need to be &#8220;secure&#8221; against, but this is the most important one).</p>
<p>However, this is not the only property that&#8217;s required when encrypting data. Each usage model has a special requirements, and that&#8217;s why there are several so-called &#8220;<a href="http://csrc.nist.gov/groups/ST/toolkit/BCM/modes_development.html">modes</a>&#8221; of operation. The simplest mode is ECB, replacing each plaintext block with an encrypted version of the block. Explaining why ECB is not sufficient in most cases is <a href="http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29">easy</a>. That leads people to think that CBC would fix all their problems. Hint: It doesn&#8217;t.</p>
<p>One thing that apparently people sometimes expect CBC to provide, which it actually doesn&#8217;t provide, is integrity. Decryption without integrity means that you can replace encrypted content with other encrypted content, and it will produce the corresponding plaintext (assuming you can access parts of the decrypted data). In CBC, the chaining aspect will screw up the first block only, and even that can be manually fixed since the ciphertext is known. If you use AES-CBC for disk encryption, you&#8217;ll likely be screwed. The missing integrity aspect is one reason why proper disk encryption <a href="http://download.microsoft.com/download/0/2/3/0238acaf-d3bf-4a6d-b3d6-0a0be4bbb36e/BitLockerCipher200608.pdf">doesn&#8217;t use plain CBC</a>. </p>
<p>Practically speaking, if you use plain CBC (maybe with a per-sector IV which doesn&#8217;t provide any security advantage), and the attacker can get the contents of a random file from your disk (for example using the symlink hole), all the attacker has to guess is the position of that file in the encrypted disk image. He can then inject arbitrary sectors into this file, dump the file, and recover plaintext. This might sound painful &#8211; and it is &#8211; but if a large-enough file can be found (that isn&#8217;t required to make the system run up to the point where you can read the file), you can extract quite a lot of data per run.</p>
<p>There are cryptographic modes (like XTS) which fix these problems. If you don&#8217;t understand the issue, go read why they&#8217;ve been invented.</p>
<h1>3. Configuration String Sanitizing</h1>
<p>Sigh. A general rule-of-thumb: If a parser acts on user-supplied data, and that parser isn&#8217;t exactly made for what the input file looks like (which would hopefully imply that the creator thought about security side-effects of any invalid user-supplied input string), don&#8217;t try to &#8220;sanitize&#8221; or filter as a frontend. You&#8217;ll miss something. This applies for sanitizing file names (think of the popular Unicode directory traversal bugs), SQL arguments and especially configuration files.</p>
<p>I&#8217;ve seen devices which allow putting an un-encrypted, un-authenticated configuration file on a user-accessible storage. The configuration file was an ASCII file with a number of </p>
<p><code>key=value\n</code></p>
<p>lines. This was then &#8220;sanitized&#8221; by removing all keys that are not in a whitelist (with some bash string parsing foo), and decorated into the following format:</p>
<p><code>export key=value\n</code></p>
<p>The resulting file is then sourced (&#8220;.&#8221;) as part of the init scripts. Needless to say how this can be exploited, leading to arbitrary code execution, for example a conveniently powerful busybox console on the serial port&#8230;</p>
<p>Lesson learned: Don&#8217;t sanitize and then let another parser do the job. Parse and sanitize at the same time.</p>
<h1>4. /dev/mem</h1>
<p>This (linux-centric) one is not really a security hole per se. However, it sometimes allows attackers to &#8220;reverse&#8221; the boot chain &#8211; for example to retrieve (parts of) the bootloader or initrd/initramfs used to boot the system, by creating a memory snapshot right after booting. This technique for example was used to retrieve the <a href="http://www.securityfocus.com/archive/1/476266/100/0/threaded">initrd of the ReadyNAS</a> (which, back then, uncovered a nice little backdoor password). </p>
<p>The device node <tt>/dev/mem</tt> maps the physical address view of the kernel. Extracting contents can be as simple as using &#8220;dd&#8221; (with proper &#8220;skip&#8221; and &#8220;bs&#8221; arguments). Alternatively, using the mmap system call, any memory (including MMIO) can be mapped into a user process. If /dev/mem is opened with O_SYNC, the mapping is cache-inhibited (on most architectures, everything above the memory size is cache-inhibited, too), which allows you to talk to IO devices.</p>
<p>Reading (writing, and mmap&#8217;ing) <tt>/dev/mem</tt> requires proper access permissions and <tt>CAP_RAWIO</tt>. </p>
<p>And really, if there was no <tt>/dev/mem</tt>, you could just load a kernel module providing the same. Root access on an embedded machine equals device pwnage, unless great effort was taken (hint: which is usually not the case).</p>
<p>Again, the existance of <tt>/dev/mem</tt> isn&#8217;t the security hole &#8211; the security hole is allowing the attacker to operate on it. It just makes things much more convenient.</p>
<h1>5. Write-Only Registers with Partial Override allow Key Recovery</h1>
<p>This one is a classic as well. Some hardware implements cryptographic functions (for example AES decryption) in hardware. Some hardware designers cleverly make the registers that are used to configure the key used in the decryption write only &#8211; such as that they can be written with the key, and the key cannot be read back. The key can then only be used in actual AES operations.</p>
<p>This sounds clever at first, <a href="http://debugmo.de/2008/01/wii-hacked-it/">solving real-world problems</a> &#8211; you can&#8217;t just dump the key out of memory. However, as usual, things are not that simple. Almost no CPUs or busses in embedded systems these days can handle atomic writes to key-sized (128 or 256 bit) registers. That means that a key register won&#8217;t be a single register, but consists of multiple registers that need to be written sequentially.</p>
<p>As long as they are written strictly sequential and completely, there is no problem. However, as soon as partial overwrites are allowed, the scheme breaks. For example, if the CPU can do 32-bit writes, and a 128-bit AES key consists of 4 registers with 32-bit each, this allows the attacker to modify the key. By then using the modified key, ciphertext/plaintext pairs can be generated that have known key bits, allowing a brute-force search on the remaining bits.</p>
<p>Practically, there are two possible ways to exploit this. Assume it&#8217;s a decrypt oracle (i.e. the internal key can be used to decrypt arbitrary ciphertext; it works similarly for non-arbitrary ciphertext or encrypt oracles). Now, either</p>
<ul>
<li>Take the reference plaintext by decrypting a constant, for example all-zero. Overwrite as few key material as possible. If the registers honor write masks, you might be able to overwrite as few as 8-bit of the key. If it doesn&#8217;t, it might be as much as 32-bit. In any case, simply loop through all of the 2<sup>8</sup> (or 2<sup>32</sup>) combinations, overwrite the key material partially, take a plaintext with the current key, and compare it with the reference. If it matches the reference, then you found a few bits of the key. Rinse, repeat with the rest.
<li>Overwrite as much key material as possible while still leaving a little bit of key material. Take a plaintext for a constant ciphertext. You can then (offline) run a brute-force attack on this, which is feasible because you reduced the entropy of the key before. Reboot (to restore the full key), Rinse, Repeat</li>
</ul>
<p>The first method is useful if the write granularity is fine (for example 8-bit) &#8211; it will then require 16 * 2<sup>8</sup>=4096 (worst case) decryptions on the device. The second method is useful if the write granularity is larger (for example 32-bit), because the first approach would require 4 * 2<sup>32</sup>=17179869184 (worst case) decryptions on the device, which can take quite a long time. These decryptions can be done offline and parallelized. A 32-bit brute force attack on a modern PC doesn&#8217;t take more than a few minutes, so after extracting the 4 possible plaintexts (keeping the first, second, third, fourth key word) the key can be recovered on a PC.</p>
<p>The disadvantage of the second method is that you need to restore the key material (for example by rebooting) before attacking the next key subset.</p>
<p>A similar method can be used (destructively) to dump OTP fuses that store a key, assuming that no redundant encoding is used (i.e. that you can burn more OTP bits to set bits in the key). </p>
<ol>
<li>Start with the first bit. Take a plaintext. Burn the first fuse, re-sense (if required, to update the key register), take another plaintext.</li>
<li>If the plaintext changed, you know that the bit wasn&#8217;t set before. If the plaintext did not change, the bit was already set. Note that down. </li>
<li>Repeat with the next bit.</li>
</ol>
<p>A somewhat inconvenient method, since it&#8217;ll destroy the OTP key (so you better be sure that you can still execute code even after the key has been partially destroyed &#8211; otherwise you need up to $keysize devices &#8211; which might still be a useful attack).</p>
<p>Some devices will not allow you to overwrite arbitrary parts of the key &#8211; some for example start the key schedule only after writing the last part of the key. However, unless they double-buffer or enforce sequential and complete access (which both involves additional state), this is vulnerable and can be exploited.</p>
<h1>6. Relying on Success</h1>
<p>Back in the <a href="http://rkieslinger.de/dboxlinux/howto.html">d-Box 2 days</a> (German link, sorry), the boot sequence would by default load into a GUI that didn&#8217;t provide any remote access. However, if the boot sequence failed, a remote shell daemon would open. This fact could be abused by short cutting a flash data line in the middle of the boot, causing the GUI binary to fail, eventually giving RSH access to the system. Then, a new, modified rootfs could be mounted (only the kernel was protected with a signature, the filesystem or any files within wasn&#8217;t), leading to arbitrary code execution.</p>
<p>The mistake they did was to assume that in a secure environment (arbitrary flash editing aside) everything would boot as expected. While it might be hard to change data meaningful, it&#8217;s often very easy to change data in a non-meaningful way &#8211; i.e. make something fail.</p>
<p>In a particular case, a kernel image was (securely) loaded into memory, and then launched. The problem is that there is no error checking. If the binary doesn&#8217;t load for some reason, the bootloader still tries to boot from that RAM location, even if it contains garbage. Usually, the bootloader would just abort with a CRC error.</p>
<p>To turn this denial-of-service attack into something useful, you can just pre-populate the memory (assuming you have code execution), reset the device and somehow make the load fail. The memory&#8217;s content will survive a <a href="https://jhalderm.com/pub/papers/coldboot-cacm09.pdf">few seconds</a> without refresh, so it&#8217;ll execute your good code.</p>
<h1>7. $USER</h1>
<p>Cross-compiling sometimes leaks information from the host system into the generated binaries (or files). One example is the kernel&#8217;s LINUX_COMPILE_BY (that&#8217;ll end up in the linux_banner, which is output when the kernel starts and can also be read from /proc/version), but there are more such examples. If you don&#8217;t want people to know who you are (hey, there should be no reason for that, right?), be aware of this fact and better grep all your binaries (including your rootfs) to make sure that nothing leaked.</p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2011/11/almost-secure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What&#8217;s Inside: Metz 50 AF-1 N</title>
		<link>http://debugmo.de/2011/10/whats-inside-metz-50-af-1-n/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=whats-inside-metz-50-af-1-n</link>
		<comments>http://debugmo.de/2011/10/whats-inside-metz-50-af-1-n/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 21:54:06 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[What's Inside]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=227</guid>
		<description><![CDATA[I recently bought a Metz 50 AF-1 N flash that I&#8217;m very happy with. One of the reason why I bought this one was that it has a USB port to upgrade the firmware. (Call me crazy, but that&#8217;s a valid reason for me.) Looking at their firmware, we find a number of &#8220;.mtz&#8221; files [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://picasaweb.google.com/106225052902927978382/Metz50AF1"><img src="https://lh6.googleusercontent.com/-QTWip9S2SgA/TpYIcd7WC7I/AAAAAAAAPY0/JXVJnXw2nWM/s240/DSC_4829.jpg" alt="Metz 50 AF-1 N" /></a><a href="http://lh6.googleusercontent.com/-rmTi0rVh-oQ/TpYIKLWXCnI/AAAAAAAAPZU/6MOahQGrWY4/s1200/DSC_4818.JPG"><img src="http://lh6.googleusercontent.com/-rmTi0rVh-oQ/TpYIKLWXCnI/AAAAAAAAPZU/6MOahQGrWY4/s240/DSC_4818.JPG" alt="digital PCB" /></a></p>
<p>I recently bought a <a href="http://www.metz.de/en/flash-units/product-ranges/system-flash-units/mecablitz-50-af-1-digital.html">Metz 50 AF-1 N</a> flash that I&#8217;m very happy with. One of the reason why I bought this one was that it has a USB port to upgrade the firmware. (Call me crazy, but that&#8217;s a valid reason for me.)</p>
<p>Looking at their <a href="http://www.metz.de/en/flash-units/firmware-download-flash-units/mecablitz-50-af-1-digital/nikon.html">firmware</a>, we find a number of &#8220;.mtz&#8221; files that all look &#8211; weird. Their entropy is much too low for a real encryption scheme (plus they don&#8217;t seem to have any length alignment). One file, MB50AF1_NikonV12.mtz in my case, looks like it&#8217;s the actual firmware for the device.</p>
<p>Looking at a hexdump at the end of this file shows</p>
<p><code>0000029CE0: 64 64 64 64 64 13 73 D0 A0 A3 03 03 03 03 03 03<br />
0000029CF0: 03 13 64 64 D0 A0</code></p>
<p>We could go ahead and try to find the &#8220;de-obfuscation&#8221; algorithm in the executable (or actually go and sniff the communication, with the hope that files are decrypted locally), but there is a thing that striked me: The files end with D0 A0. Other .mtz files also end with A0 or D0 A0.</p>
<p>Can you already spot the algorithm?<br />
<span id="more-227"></span><br />
I have to admit that I didn&#8217;t spot it instantly, even though in retrospect, it&#8217;s obvious. I tried with the usual stuff (histogram to figure out a caesar or &#8220;XOR with constant&#8221; algorithm), and eventually failed. Looking at the ending again &#8211; not surprised if they would be ASCII files, we would expect them to end with 0D 0A, or 0A, depending on the encoding. </p>
<p>A quick python 3-liner later showed that this guess was indeed correct: They simply swap nibbles. Doing this on the largest of the files (MB50AF1_NikonV12.mtz) produces a nice Intel-Hex file. </p>
<p>Next step is to guess the architecture. AVR? Nope, looking at the binary it&#8217;s obvious that they have byte-aligned instructions. PIC? I didn&#8217;t even dare to try. ARM? No byte-aligned instructions either, and the code density was much too high. 8051? Nope. I tried a few more, but none of them produced sensible output. May I ask for an &#8220;heuristically identify me the architecture for this binary, please&#8221; project again?</p>
<p>I finally resorted to the brute-force approach: Opening up the device reveals: It&#8217;s a NEC (now Renesas) μPD78F0396! Here&#8217;s the <a href="http://www1.futureelectronics.com/doc/NEC/UPD78F0397DGC-8EA-A.pdf">datasheet</a>! Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2011/10/whats-inside-metz-50-af-1-n/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;if you call that hacking, then we embrace that.&#8221;, or: please have a cake.</title>
		<link>http://debugmo.de/2011/06/sony-embraces-hackers-wtf/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sony-embraces-hackers-wtf</link>
		<comments>http://debugmo.de/2011/06/sony-embraces-hackers-wtf/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 21:24:11 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=220</guid>
		<description><![CDATA[From nyt: Some hackers say Sony wants to deter customers from modifying the PlayStation3. Is that true? No, there’s a real misnomer there, we embrace independent game development; if you call that hacking, then we embrace that. We give people tools that let them create new experiences. What I don’t think we are in support [...]]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://bits.blogs.nytimes.com/2011/06/13/one-on-one-jack-tretton-sony-c-e-o-america/">nyt</a>:</p>
<blockquote><p><em>Some hackers say Sony wants to deter customers from modifying the PlayStation3. Is that true?</em><br />
No, there’s a real misnomer there, <strong>we embrace independent game development; if you call that hacking, then we embrace that</strong>. We give people tools that let them create new experiences. What I don’t think we are in support of is someone trying to hack our device to pirate software and possibly collapse the platform.</p></blockquote>
<p>No, you fucking don&#8217;t. <a href="http://www.groklaw.net/articlebasic.php?story=20110402000830503">Instead, you call them pirates and sue them</a>:</p>
<blockquote><p>MS. SACKS: Well, certainly one thing we might find is whether or not any of them are engaged in the hacking that we now know was a widespread effort.</p>
<p>Obviously, the people in this class are the people who downloaded, or claim they downloaded the Linux operating system onto their other OS. It is beyond dispute now that there in is an ongoing effort to hack the PS3. In fact, most recently, there was an effort to hack around for update 3.21.</p>
<p>And these people, as members of the class, are engaged in activity that is not only prohibited under Sony&#8217;s agreements, but is illegal. So if, in fact, some of these very sophisticated users, who are included in the five named plaintiffs, are engaged in the hacking, we certainly have the opportunity to find that out.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2011/06/sony-embraces-hackers-wtf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Last Piece</title>
		<link>http://debugmo.de/2010/12/the-last-piece/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-last-piece</link>
		<comments>http://debugmo.de/2010/12/the-last-piece/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 21:10:18 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Triforce]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=211</guid>
		<description><![CDATA[As described in this post on ASSEMblergames.com and in this post, there is still a secret left that needs to be lifted for the newer &#8220;Type 3&#8243; triforces. As a short summary, the new type triforce is probably a cost reduction of the old hardware. As part of this cost reduction, handling of the GDROM [...]]]></description>
			<content:encoded><![CDATA[<p>As described in <a href="http://www.assemblergames.com/forums/showpost.php?p=296558&#038;postcount=7">this post on ASSEMblergames.com</a> and <a href="http://debugmo.de/2008/08/triforce_type3/">in this post</a>, there is still a secret left that needs to be lifted for the newer &#8220;Type 3&#8243; triforces.</p>
<p>As a short summary, the new type triforce is probably a cost reduction of the <a href="http://debugmo.de/2008/05/the-beast-in-parts/">old hardware</a>. As part of this cost reduction, handling of the GDROM and security PIC, which was previously implemented in an SH-4 CPU, was &#8220;removed&#8221;. The network stuff was now handled separately on a MIPS cpu, but <a href="http://debugmo.de/2008/05/pah-security/">several strings that are proven to exist</a> do not exist anymore in the flash rom, at least not as plaintext.<br />
<span id="more-211"></span><br />
On a closer look, a mysterious file &#8220;firmware.asic&#8221; was introduced, 96k in size. Using the <a href="http://code.google.com/p/dolphin-emu/">Dolphin emulator</a> patches (which are finally <a href="http://code.google.com/p/dolphin-emu/source/detail?r=4437">integrated</a>, by the way! Thanks to everyone involved!) I could change the emulated &#8220;INQUIRY&#8221; response. Depending on the first byte, which seems to be a version number, the emulated segaboot would either boot normally, or upload the very firmware.asic file. Apparently the Type-3 triforce needs this firmware before it can work. </p>
<p>As a final hint, segaboot displays, depending on the &#8220;version&#8221;, either &#8220;VxWorks&#8221; or &#8220;RX850&#8243;. While &#8220;VxWorks&#8221; makes sense &#8211; the old triforce&#8217;s NETDIMM is VxWorks based &#8211; a &#8220;RX850&#8243; couldn&#8217;t be found anywhere. <a href="http://www.google.com/search?q=RX850">Searching for RX850</a> yields a NEC (now Renesas) embedded CPU. Would firmware.asic be code for this CPU?</p>
<p>But looking at firmware.asic yields code that looks encrypted. <a href="http://debugmo.de/2008/06/part-5-the-other-way-around/">Again</a> we see repeating 8 byte patterns, a strong sign for a non-chaining block cipher. But &#8211; this time there is no external storage (like the security PIC for games) that would store the key. The key is probably hardcoded and stored deep within the silicon. My guess is that it&#8217;s still DES, given that they use DES for the games.</p>
<p>Brute-forcing the key would be a theoretical solution. After all, we can guess the plaintext for the repeating patterns (usually either all-zero or all-ones). There is a possibility that 8 byte blocks have to be reversed again (like for games). That gives us 4 potential ciphertexts to look for (normal, reversed, inverted, reversed-and-inverted) when encrypting zeros. After all, we only want to walk the keyspace once&#8230;</p>
<p>Today, after only a few hours of parallel search on 9 Xilinx V2P50 FPGAs, I&#8217;d like to announce: <b><code>00 22 44 66 88 aa cc ee</code></b>. Brute-forcing the key is a <em>practical solution</em>. Thanks for keeping the key so simple! The leading zero bits really helped finding the key so fast.</p>
<p>For more details on the brute-force hardware and software setup, see my upcoming <a href="http://events.ccc.de/congress/2010/Fahrplan/events/4203.en.html">27C3 Talk</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2010/12/the-last-piece/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Encrypted Links</title>
		<link>http://debugmo.de/2010/11/encrypted-links/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=encrypted-links</link>
		<comments>http://debugmo.de/2010/11/encrypted-links/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 19:42:45 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=205</guid>
		<description><![CDATA[Just a random failscript we stumbled across: $random_key = get_option('XXXXX_random_code'); $output = "\n".stripslashes($cart_item_name)." - ".$script_location.'download.php?file='.rawurlencode(base64_encode(RC4Crypt::encrypt($random_key,$download))); I vote for removing crypto primitives from PHP altogether. Oh wait, people would just code up their own ROT26 then and use CRC for hashing. Nevermind. Maybe also remove the xor operator then?]]></description>
			<content:encoded><![CDATA[<p>Just a random failscript we stumbled across:<br />
<code>$random_key = get_option('XXXXX_random_code');<br />
$output = "\n".stripslashes($cart_item_name)." - ".$script_location.'download.php?file='.rawurlencode(base64_encode(RC4Crypt::encrypt($random_key,$download)));</code></p>
<p>I vote for removing crypto primitives from PHP altogether.<br />
<span id="more-205"></span><br />
Oh wait, people would just code up their own ROT26 then and use CRC for hashing. Nevermind. Maybe also remove the xor operator then?</p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2010/11/encrypted-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retro Hacking</title>
		<link>http://debugmo.de/2010/11/retro-hacking/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=retro-hacking</link>
		<comments>http://debugmo.de/2010/11/retro-hacking/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 05:23:57 +0000</pubDate>
		<dc:creator>tmbinc</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://debugmo.de/?p=191</guid>
		<description><![CDATA[Remember 10 years ago? I do!]]></description>
			<content:encoded><![CDATA[<p>Remember <a href="http://web.archive.org/web/20001109144500/http://heise.de/">1</a><a href="http://web.archive.org/web/20001110020300/www.apple.com/hardware/">0</a><a href="http://web.archive.org/web/20001109203100/http://www.spiegel.de/index.html"> </a>years ago? I do!<br />
<span id="more-191"></span><br />
<img src="http://lh3.ggpht.com/_5AkmcjP1eXU/S7XQ4kM71NI/AAAAAAAAEAA/opsUDrJ1HPo/s800/DSC00013.JPG"></p>
]]></content:encoded>
			<wfw:commentRss>http://debugmo.de/2010/11/retro-hacking/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
