<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.webos-internals.org/index.php?action=history&amp;feed=atom&amp;title=Decrypt_SSL_%28trusted_man-in-the-middle_technique%29</id>
	<title>Decrypt SSL (trusted man-in-the-middle technique) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.webos-internals.org/index.php?action=history&amp;feed=atom&amp;title=Decrypt_SSL_%28trusted_man-in-the-middle_technique%29"/>
	<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Decrypt_SSL_(trusted_man-in-the-middle_technique)&amp;action=history"/>
	<updated>2026-05-17T21:20:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Decrypt_SSL_(trusted_man-in-the-middle_technique)&amp;diff=14349&amp;oldid=prev</id>
		<title>Destinal: fixed a link</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Decrypt_SSL_(trusted_man-in-the-middle_technique)&amp;diff=14349&amp;oldid=prev"/>
		<updated>2011-03-20T21:43:30Z</updated>

		<summary type="html">&lt;p&gt;fixed a link&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:43, 20 March 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following is a method that can be used to set up a tunnel for an SSL site which you can then sniff and decrypt to observe the traffic in the clear.  This example will demonstrate decrypting the HTTPS transactions to ps.palmws.com (the patch service used in the update process)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following is a method that can be used to set up a tunnel for an SSL site which you can then sniff and decrypt to observe the traffic in the clear.  This example will demonstrate decrypting the HTTPS transactions to ps.palmws.com (the patch service used in the update process)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This method has been successfully used to obtain traces of conversations with the update server, excerpts of which are posted in [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[ update-service-trace ]&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This method has been successfully used to obtain traces of conversations with the update server, excerpts of which are posted in [[ &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Update_Service_Trace &lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Install stunnel'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Install stunnel'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Destinal</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Decrypt_SSL_(trusted_man-in-the-middle_technique)&amp;diff=1114&amp;oldid=prev</id>
		<title>Hopspitfire: New page: At times, it can be useful to sniff or intercept and decode communications from the pre / webOS client and its backend web services.  As many of them utilize SSL for security, however, thi...</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Decrypt_SSL_(trusted_man-in-the-middle_technique)&amp;diff=1114&amp;oldid=prev"/>
		<updated>2009-07-20T22:46:42Z</updated>

		<summary type="html">&lt;p&gt;New page: At times, it can be useful to sniff or intercept and decode communications from the pre / webOS client and its backend web services.  As many of them utilize SSL for security, however, thi...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;At times, it can be useful to sniff or intercept and decode communications from the pre / webOS client and its backend web services.  As many of them utilize SSL for security, however, this can make it difficult for us to observe the actual HTTP transactions between the pre and these services.&lt;br /&gt;
&lt;br /&gt;
The following is a method that can be used to set up a tunnel for an SSL site which you can then sniff and decrypt to observe the traffic in the clear.  This example will demonstrate decrypting the HTTPS transactions to ps.palmws.com (the patch service used in the update process)&lt;br /&gt;
&lt;br /&gt;
This method has been successfully used to obtain traces of conversations with the update server, excerpts of which are posted in [[[ update-service-trace ]]]&lt;br /&gt;
&lt;br /&gt;
'''Install stunnel'''&lt;br /&gt;
&lt;br /&gt;
Ensure that you have installed stunnel on a designated man-in-the-middle server, which should be another system reachable by the pre, over a network interface that you will sniff (capture packets from for decryption)  in later steps.   Stunnel can be installed with &amp;quot;apt-get install stunnel&amp;quot; on debian / ubuntu or built from source code which can be downloaded from [http://www.stunnel.org stunnel.org].&lt;br /&gt;
&lt;br /&gt;
'''Generate CA and server certificates'''&lt;br /&gt;
&lt;br /&gt;
First, download the script &amp;quot;cert.sh&amp;quot; from the (OWASP webscarab project.)&lt;br /&gt;
&lt;br /&gt;
This script will create a directory called &amp;quot;sslcerts&amp;quot; in the current directory, generate / self-sign a  Certificate Authority certificate and then use it to sign a certificate for the hostname you specify.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
wget -O cert.sh 'http://dawes.za.net/gitweb.cgi?p=rogan/webscarab/webscarab.git;a=blob_plain;f=doc/cert.sh;hb=master'&lt;br /&gt;
sh cert.sh ps.palmws.com&lt;br /&gt;
cat sslcerts/ps.palmws.com-cert.pem  sslcerts/private/ps.palmws.com-key.pem &amp;gt; ps.pem&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Set up the tunnel'''&lt;br /&gt;
&lt;br /&gt;
Next, we'll set up a transparent SSL to SSL tunnel.  Port 443 on your server will foward to ps.palmws.com but since your listener uses your cert/key for the client connection, you can use that key to decrypt any of that traffic. &lt;br /&gt;
&lt;br /&gt;
Listen on local IP and de-SSL traffic to localhost:8080&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
sudo stunnel -p ps.pem -d 443 -r 8080&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Listen on 8080, re-SSL to remote server on 443&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
sudo stunnel -c -d 8080 -r ps.palmws.com:443&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Repoint your pre to use the tunnel endpoint as its patch server'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you need to force the pre to use your man in the middle as ps.palmws.com.  To do so, run the following command on the pre (as root):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
echo &amp;quot;192.168.0.1 ps.palmws.com&amp;quot; &amp;gt;&amp;gt; /etc/hosts&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
192.168.0.1 is my server's IP address on a usbnet connection.  Replace this with your own server's IP on wifi, usbnet, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Make the pre trust your CA certificate'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the pre is configured to connect to the man-in-the-middle / tunnel server and the tunnel server will accept an SSL connection from the client and initiat another one on the backend to the real ps.palmws.com server, forwarding traffic between them.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, your ps.palmws.com certificate has not been signed by any known / trusted certifying authority, so, once connected to your MITM server, the Pre will reject its certificate and cancel the update.&lt;br /&gt;
&lt;br /&gt;
To enable your certificate to be considered trusted, your must install the Certificate Authority certificate that signed it (the one we generated earlier) into the trusted root / CA certificate store on the pre.&lt;br /&gt;
&lt;br /&gt;
First, copy sslcerts/ca_cert.pem to your pre.&lt;br /&gt;
&lt;br /&gt;
Then, on your pre, add the contents of that certificate to the certificate store.   (run all these commands as root, ie &amp;quot;sudo su -&amp;quot; first, then cd to the directory where you stored ca_cert.pem):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
CERTSTORE=/etc/ssl/certs/ca-certificates.crt&lt;br /&gt;
openssl x509 -in ca_cert.pem -text -noout|grep Subject:|sed 's/.*Subject: /subject= \//;s/, /\//g' &amp;gt;&amp;gt; $CERTSTORE&lt;br /&gt;
grep '==='  $CERTSTORE | head -1  &amp;gt;&amp;gt; $CERTSTORE&lt;br /&gt;
openssl x509 -in ca_cert.pem &amp;gt;&amp;gt; $CERTSTORE&lt;br /&gt;
echo &amp;gt;&amp;gt; $CERTSTORE&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Sniff the traffic and decrypt it using our private key'''&lt;br /&gt;
&lt;br /&gt;
Now sniff the traffic between the phone and your server.  I use [http://www.wireshark.org/ WireShark] on the PC running the server which is connected to the pre over usbnet.&lt;br /&gt;
&lt;br /&gt;
Wireshark supports decryption of SSL traffic if you have the private key.   See [http://wiki.wireshark.org/SSL WireShark's SSL page] for details.  The binding to enter in the SSL decoding (edit, preferences, protocols, SSL) is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
192.168.0.1,443,http,/path/to/ps.pem&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or on Windows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
192.168.0.1,443,http,c:\path\to\ps.pem&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(replace 192.168.0.1 with your man-in-the-middle server IP address)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With Wireshark running and decrypting all the traffic sent to the tunnel, you should be able to run the update app and watch the communications between your pre and the update service.&lt;br /&gt;
&lt;br /&gt;
'''About:'''&lt;br /&gt;
&lt;br /&gt;
- destinal - initial method and documentation&lt;/div&gt;</summary>
		<author><name>Hopspitfire</name></author>
	</entry>
</feed>