<?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>reverse engineering &#8211; Matthew Petroff</title>
	<atom:link href="https://mpetroff.net/tag/reverse-engineering/feed/" rel="self" type="application/rss+xml" />
	<link>https://mpetroff.net</link>
	<description>mpetroff.net</description>
	<lastBuildDate>Wed, 30 Nov 2016 02:00:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Ricoh Theta S Updater and Firmware Analysis</title>
		<link>https://mpetroff.net/2016/08/ricoh-theta-s-updater-and-firmware-analysis/</link>
					<comments>https://mpetroff.net/2016/08/ricoh-theta-s-updater-and-firmware-analysis/#comments</comments>
		
		<dc:creator><![CDATA[Matthew Petroff]]></dc:creator>
		<pubDate>Sun, 28 Aug 2016 17:39:07 +0000</pubDate>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[reverse engineering]]></category>
		<category><![CDATA[Ricoh]]></category>
		<category><![CDATA[Theta S]]></category>
		<guid isPermaLink="false">https://mpetroff.net/?p=2236</guid>

					<description><![CDATA[Ricoh provides a &#8220;Basic app&#8221; for Windows and Mac that will update the Theta S&#8217; firmware and stitch the dual-fisheye video output into equirectangular video. The application UI and glue code, SphericalViewer.swf, is built using Adobe Flex, while the video &#8230; <a href="https://mpetroff.net/2016/08/ricoh-theta-s-updater-and-firmware-analysis/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p><span class="dropcap">R</span>icoh provides a &#8220;<a href="https://theta360.com/en/support/download/">Basic app</a>&#8221; for Windows and Mac that will update the Theta S&#8217; firmware and stitch the dual-fisheye video output into equirectangular video. The application UI and glue code, <code>SphericalViewer.swf</code>, is built using Adobe Flex, while the video stitching portion, camera communications portion, and firmware updater are native code. The video stitcher is built using <a href="http://opencv.org/">OpenCV</a> and <a href="https://ffmpeg.org/">FFmpeg</a>. Although reverse engineering native code is rather involved, reverse engineering Flash objects is much easier. Running <code>SphericalViewer.swf</code> through the <a href="https://www.free-decompiler.com/flash/">JPEXS flash decompiler</a> produced fairly readable output.</p>
<p>The most interesting part was related to the configuration file, <code>CommonConfig.dat</code>. After opening the file in a text editor, it was immediately obvious that it was Base64-encoded, but the decoded output was gobbledygook. However, I was able to decode it by analyzing the appropriate function in the decompiled Flash object. Indeed, the first step was to Base64-decode the file&#8217;s contents. The next step explains why the decoded output didn&#8217;t make sense—it was encrypted. After the Base64-decode, the result needs to be twice decrypted using an 256-bit AES key in Cipher Block Chaining (CBC) mode. This would normally prove to be extremely difficult, but the encryption key is defined as a variable in the same function, which makes it quite easy. This allowed me to write a <a href="https://gist.github.com/mpetroff/8b33bc7d2a8a312c6b8e9fec94aa6568">configuration file decoder</a> in Python. Once decoded, the configuration file is just an XML file. I&#8217;m not sure what the point of encrypting the configuration file is when the encryption key is easily accessible, and I&#8217;m really not sure what the point of encrypting it twice is, particularly with the same key.<br />
<span id="more-2236"></span></p>
<div class="highlighted-source default xml">
<pre><span></span><span class="nt">&lt;CommonConfig&gt;</span>

  <span class="nt">&lt;domainInfos&gt;</span>

    <span class="nt">&lt;domainInfo</span> <span class="na">domainCode=</span><span class="s">&quot;staging&quot;</span><span class="nt">&gt;</span>
      <span class="nt">&lt;serverUri</span> <span class="na">url=</span><span class="s">&quot;https://api.theta360stage.com&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;browserUri</span> <span class="na">url=</span><span class="s">&quot;https://theta360stage.com&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;updateConfirmSiteUri</span> <span class="na">url=</span><span class="s">&quot;https://staging-hydrangea-statics.s3.amazonaws.com/app/viewer/update_staging.xml&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;firmUpdate</span> <span class="na">baseUrl=</span><span class="s">&quot;https://staging-hydrangea-statics.s3.amazonaws.com/app/firmUpdate&quot;</span> <span class="na">fileName=</span><span class="s">&quot;firmUpdateRoot.xml&quot;</span> <span class="na">fileNameM15=</span><span class="s">&quot;firmUpdateRoot_m15.xml&quot;</span> <span class="na">fileNameM20=</span><span class="s">&quot;firmUpdateRoot_m20.xml&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/domainInfo&gt;</span>

    <span class="nt">&lt;domainInfo</span> <span class="na">domainCode=</span><span class="s">&quot;integration&quot;</span><span class="nt">&gt;</span>
      <span class="nt">&lt;serverUri</span> <span class="na">url=</span><span class="s">&quot;https://api.osaroid.info&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;browserUri</span> <span class="na">url=</span><span class="s">&quot;https://www.osaroid.info&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;updateConfirmSiteUri</span> <span class="na">url=</span><span class="s">&quot;https://hydrangea-statics.s3.amazonaws.com/app/viewer/update_integration.xml&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;firmUpdate</span> <span class="na">baseUrl=</span><span class="s">&quot;https://hydrangea-statics.s3.amazonaws.com/app/firmUpdate&quot;</span> <span class="na">fileName=</span><span class="s">&quot;firmUpdateRoot.xml&quot;</span> <span class="na">fileNameM15=</span><span class="s">&quot;firmUpdateRoot_m15.xml&quot;</span> <span class="na">fileNameM20=</span><span class="s">&quot;firmUpdateRoot_m20.xml&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/domainInfo&gt;</span>

    <span class="nt">&lt;domainInfo</span> <span class="na">domainCode=</span><span class="s">&quot;kuma&quot;</span><span class="nt">&gt;</span>
      <span class="nt">&lt;serverUri</span> <span class="na">url=</span><span class="s">&quot;https://api.kuma.osaroid.info&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;browserUri</span> <span class="na">url=</span><span class="s">&quot;https://kuma.osaroid.info&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;updateConfirmSiteUri</span> <span class="na">url=</span><span class="s">&quot;NO_SETTING&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;firmUpdate</span> <span class="na">baseUrl=</span><span class="s">&quot;NO_SETTING&quot;</span> <span class="na">fileName=</span><span class="s">&quot;firmUpdateRoot.xml&quot;</span> <span class="na">fileNameM15=</span><span class="s">&quot;firmUpdateRoot_m15.xml&quot;</span> <span class="na">fileNameM20=</span><span class="s">&quot;firmUpdateRoot_m20.xml&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/domainInfo&gt;</span>

    <span class="nt">&lt;domainInfo</span> <span class="na">domainCode=</span><span class="s">&quot;kan&quot;</span><span class="nt">&gt;</span>
      <span class="nt">&lt;serverUri</span> <span class="na">url=</span><span class="s">&quot;https://api.apekan.osaroid.info&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;browserUri</span> <span class="na">url=</span><span class="s">&quot;https://apekan.osaroid.info&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;updateConfirmSiteUri</span> <span class="na">url=</span><span class="s">&quot;NO_SETTING&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;firmUpdate</span> <span class="na">baseUrl=</span><span class="s">&quot;NO_SETTING&quot;</span> <span class="na">fileName=</span><span class="s">&quot;firmUpdateRoot.xml&quot;</span> <span class="na">fileNameM15=</span><span class="s">&quot;firmUpdateRoot_m15.xml&quot;</span> <span class="na">fileNameM20=</span><span class="s">&quot;firmUpdateRoot_m20.xml&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/domainInfo&gt;</span>

    <span class="nt">&lt;domainInfo</span> <span class="na">domainCode=</span><span class="s">&quot;m15&quot;</span><span class="nt">&gt;</span>
      <span class="nt">&lt;serverUri</span> <span class="na">url=</span><span class="s">&quot;https://api.m15.pacpac.theta360devel.com&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;browserUri</span> <span class="na">url=</span><span class="s">&quot;https://m15.pacpac.theta360devel.com&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;updateConfirmSiteUri</span> <span class="na">url=</span><span class="s">&quot;NO_SETTING&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;firmUpdate</span> <span class="na">baseUrl=</span><span class="s">&quot;NO_SETTING&quot;</span> <span class="na">fileName=</span><span class="s">&quot;firmUpdateRoot.xml&quot;</span> <span class="na">fileNameM15=</span><span class="s">&quot;firmUpdateRoot_m15.xml&quot;</span> <span class="na">fileNameM20=</span><span class="s">&quot;firmUpdateRoot_m20.xml&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/domainInfo&gt;</span>

    <span class="nt">&lt;domainInfo</span> <span class="na">domainCode=</span><span class="s">&quot;production&quot;</span><span class="nt">&gt;</span>
      <span class="nt">&lt;serverUri</span> <span class="na">url=</span><span class="s">&quot;https://api.theta360.com&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;browserUri</span> <span class="na">url=</span><span class="s">&quot;https://theta360.com&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;updateConfirmSiteUri</span> <span class="na">url=</span><span class="s">&quot;https://theta360-statics.s3.amazonaws.com/app/viewer/update_production.xml&quot;</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;firmUpdate</span> <span class="na">baseUrl=</span><span class="s">&quot;https://theta360-statics.s3.amazonaws.com/app/firmUpdate&quot;</span> <span class="na">fileName=</span><span class="s">&quot;firmUpdateRoot.xml&quot;</span> <span class="na">fileNameM15=</span><span class="s">&quot;firmUpdateRoot_m15.xml&quot;</span> <span class="na">fileNameM20=</span><span class="s">&quot;firmUpdateRoot_m20.xml&quot;</span> <span class="nt">/&gt;</span>
    <span class="nt">&lt;/domainInfo&gt;</span>

    <span class="nt">&lt;/domainInfos&gt;</span>

<span class="nt">&lt;/CommonConfig&gt;</span>
</pre>
</div>
<p>The configuration file contains a series of different update servers, although only the production server, which is hosted using Amazon S3, seems to work. Upon downloading the XML files, the first thing we learn is the internal names for the different Theta cameras: the Theta S is the <code>m20</code>; the Theta M15 is, obviously, the <code>m15</code>; and the original Theta is the <code>m10</code>. We also find the firmware download URLs and, by testing URL permutations, are able to determine and download all released firmware versions: 1.21, 1.30, 1.42, 1.50, and 1.62 for the Theta S. Here are example URLs for the Theta S <a href="https://theta360-statics.s3.amazonaws.com/app/firmUpdate/firmUpdateRoot_m20.xml">root update information file</a>, <a href="https://theta360-statics.s3.amazonaws.com/app/firmUpdate/m20/01.62/firmUpdate.xml">firmware information file</a>, and the <a href="https://theta360-statics.s3.amazonaws.com/app/firmUpdate/m20/01.62/gy1_v162.frm">firmware itself</a>.</p>
<p>Opening the firmware in a hex editor shows that it is identified with <code>UNITY FILE V1.10 / RICOH COMPANY</code> at the beginning of the file. This appears to be the same format use by Ricoh for other camera firmware, but I couldn&#8217;t find any information about it. Running the firmware through <a href="http://binwalk.org/">Binwalk</a> shows that it contains ARM instructions, and an entropy analysis shows that it is not encrypted. I didn&#8217;t make any progress besides this.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mpetroff.net/2016/08/ricoh-theta-s-updater-and-firmware-analysis/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: cdn0.mpetroff.net
Minified using Disk

Served from: mpetroff.net @ 2026-03-31 01:31:16 by W3 Total Cache
-->