<?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; http</title>
	<atom:link href="http://travisaltman.com/category/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://travisaltman.com</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 02:25:16 +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>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>Webscarab Tutorial Part 3 (fuzzing)</title>
		<link>http://travisaltman.com/webscarab-tutorial-part-3-fuzzing/</link>
		<comments>http://travisaltman.com/webscarab-tutorial-part-3-fuzzing/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 15:30:45 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[SQL injection]]></category>

		<guid isPermaLink="false">http://travisaltman.com/webscarab-tutorial-part-3-fuzzing/</guid>
		<description><![CDATA[Part 2 covered the neat functionality of session ID analysis within Webscarab.  Now we&#8217;ll focus on another great function within Webscarab, fuzzing.  I define fuzzing as testing the input of an application by trying various parameters that the input may not expect.  These parameters don&#8217;t have to be random, in my opinion [...]]]></description>
			<content:encoded><![CDATA[<p>Part 2 covered the neat functionality of session ID analysis within Webscarab.  Now we&#8217;ll focus on another great function within Webscarab, fuzzing.  I define fuzzing as testing the input of an application by trying various parameters that the input may not expect.  These parameters don&#8217;t have to be random, in my opinion it&#8217;s best when you tailor your parameters depending on the application.  When fuzzing you typically want to inject &#8220;command &amp; control&#8221; parameters into the input to find the most serious vulnerability.  For example if a web application is expecting a social security number I may inject html parameters such as &#8221; &lt; / &gt; &#8221; to manipulate the look, feel, and operation of a web application.  I don&#8217;t want to delve a whole lot into fuzzing because there are books out there that talk about this one subject.  This tutorial is going to focus on using Webscarab to fuzz web applications and find vulnerabilities.  Hopefully by the end of this tutorial you will better understand the technical aspects of fuzzing as oppose to the concept of fuzzing, but more reading on fuzzing web applications may be required.</p>
<p><span id="more-50"></span></p>
<p>This tutorial will once again be targeting Foundstone&#8217;s Hacme Casino which intentionally has vulnerabilities built into the application.  Fuzzing can focus on different types of vulnerabilities and parameters within web applications (e.g. XSS, SQL injection, queries, directory paths, etc&#8230;), although this tutorial will focus on parameters vulnerable to SQL injection.  Foudstone&#8217;s documentation lets us know that the username input is vulnerable to SQL injection so we can try fuzzing it with Webscarab to find other possible injections.  First we&#8217;ll try and login with the username &#8216;test&#8217; and password &#8216;test&#8217;.  This can be seen in Figure 1.</p>
<p align="center"> <a href="http://travisaltman.com/wp-content/loginhacmecasinowithusernametest.png" title="Try logging into Hacme Casino"><img src="http://travisaltman.com/wp-content/loginhacmecasinowithusernametest.png" alt="Try logging into Hacme Casino" /></a></p>
<p align="center">Figure 1: Trying to login</p>
<p>This will not log us into the application but Webscarab will capture the login process in the summary tab.  Once this has happened find the login conversation in the summary tab.  After you have found the login conversation simply right click and select &#8220;Use as fuzz template&#8221;, this will send the parameters and headers associated with that request / conversation to the fuzzing tab.  Selection of the login request can be seen in Figure 2.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/rightclickuseasfuzztemplateforhacmecasinologin.png" title="Right click request to use as a fuzz template"><img src="http://travisaltman.com/wp-content/rightclickuseasfuzztemplateforhacmecasinologin.png" alt="Right click request to use as a fuzz template" /></a></p>
<p align="center">Figure 2: Send conversation to fuzz template</p>
<p align="left">Now navigate to the Fuzzer tab within Webscarab.  Here you&#8217;ll see all the parameters that are associated with that request / conversation.  You could add parameters to the request and see how the web application reacts to different paths, value, or types.  You could also delete parameters for simplicity and to also see how the application reacts with those parameters missing.  Once you have determined the parameters for fuzzing you&#8217;ll need to define a fuzz source.  So click on the &#8220;Sources&#8221; button beside &#8220;Start&#8221; and &#8220;Stop&#8221; within the Fuzzer tab.  Here you will choose a dictionary style text file that contains parameters you want to fuzz with.  I chose a SQL injection dictionary because we know the &#8220;username&#8221; field is vulnerable to SQL injections.  The selection of the SQL injection dictionary can be seen in Figure 3.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/pickingsqlinjectionfuzzsources.png" title="Choosing SQL injection dictionary as a fuzz source"><img src="http://travisaltman.com/wp-content/pickingsqlinjectionfuzzsources.png" alt="Choosing SQL injection dictionary as a fuzz source" /></a></p>
<p align="center">Figure 3: Choosing fuzz source</p>
<p align="left">In my SQL injection dictionary I have 66 items, but Webscarab does not have a limit.  There are lots of SQL injection dictionaries out there, some are even dedicated towards different platforms (e.g. MySQL, MS SQL Server, DB2, etc&#8230;).  I got most of my SQL attacks from Andres Andreu&#8217;s website <a href="http://www.neurofuzz.com/">Neurofuzz</a>, the dictionary I pulled from can be found <a href="http://www.neurofuzz.com/modules/software/wsfuzzer/All_attack.txt">here</a>.  In this tutorial we won&#8217;t be trying to fuzz for XSS vulnerabilities but <a href="http://ha.ckers.org/">ha.ckers.org</a> has a now infamous <a href="http://ha.ckers.org/xss.html">XSS dictionary</a> which is a great resource.  Once all dictionary sources are added go to the main Fuzzer tab and assign parameters a fuzz source.  This can be done via a drop down menu as seen in Figure 4.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/choosesqlinjectionfuzzsourcefromdropdownlist.png" title="Choosing fuzz source for each parameter"><img src="http://travisaltman.com/wp-content/choosesqlinjectionfuzzsourcefromdropdownlist.png" alt="Choosing fuzz source for each parameter" /></a></p>
<p align="center">Figure 4: Drop down menu containing fuzz source</p>
<p align="left">In order to prevent a parameter from being fuzzed simply leave the &#8220;Fuzz Source&#8221; field blank or delete the parameter altogether.  In this case the &#8220;user_login&#8221; is the only parameter that will reiterate through the SQLattack dictionary.  The next step is to click on &#8220;Start&#8221; and let Webscarab try all of your parameters within the dictionary.  This means the value &#8220;test&#8221; will be replaced with values inside the SQL injection attack dictionary and new request  is sent to the web server for every attack parameter inside your dictionary.  The fuzzer in action can be seen in Figure 5.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/runningfuzzerandwatchingrequests.png" title="Running the fuzzer"><img src="http://travisaltman.com/wp-content/runningfuzzerandwatchingrequests.png" alt="Running the fuzzer" /></a></p>
<p align="center">Figure 5: Running the fuzzer</p>
<p align="left">Notice the &#8220;Total Requests&#8221; and the &#8220;Current Request&#8221;, once the fuzzer has run through all of the parameters in the SQL injection dictionary both of these numbers will be 68.  Also notice the ID number 97 on the left hand side of the table, this is the first request of the fuzzing operation.  The last request will have an ID number of 164, it&#8217;s important to keep track of these request ID&#8217;s when reviewing results of the fuzzing operation.  I have found myself reviewing requests that weren&#8217;t fuzzed and accidentally identified requests as not being vulnerable when in fact they were.</p>
<p align="left">Once the fuzzer has made all of the requests a review of the results is needed to see if any of the attack parameters succeeded in a SQL injection.  I do this simply by going back to the summary tab and opening up the first conversation of the fuzzing process.  I then manually step through every conversation involved in the fuzzing operation and look for any &#8220;interesting differences&#8221; between responses.  The phrase interesting differences is in quotation marks because fuzzing and looking for SQL injections is not an exact science but knowing how an application normally deals with the input will be helpful in determining what should and should not be expected in a HTTP response.  Let&#8217;s take a look at some of our fuzzing conversations to get a better idea of discovering differences.  Have a look at the first fuzzing request, note the value of the &#8220;user_login&#8221; parameter in the request and the value of the &#8220;Location&#8221; in the response.  This can be seen in Figure 6.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/nosqlinjectionfuzzparameterconversation97markedup.png" title="First fuzzed conversation"><img src="http://travisaltman.com/wp-content/nosqlinjectionfuzzparameterconversation97markedup.png" alt="First fuzzed conversation" /></a></p>
<p align="center">Figure 6: First fuzzed conversation</p>
<p align="left">Here it&#8217;s seen that the first value in the attack dictionary was actually used for the username value, good to know Webscarab is functioning properly.  The top of Figure 6 shows that a POST request is sent to /account/login to check the credentials of the user, since the first SQL injection is not a valid user the response is to redirect back to the login screen.  Keep in mind when looking at these conversation screen shots that the top half of the figure is the request and the lower half is the response.  It can be deferred from this conversation that if an invalid username is inserted into the web application the response will be a redirect to the login screen.  So when looking through the other SQL injected conversations it would be a good idea to look for a redirect to another location or an error message.  It&#8217;s always a good idea to look for database error messages when trying to find SQL injection vulnerabilities within a web application.  Stepping through the other conversations I notice something different, this can be seen in Figure 7.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/sqlinjectionfuzzparameterconversation103withredtext.png" title="Successful SQL injection"><img src="http://travisaltman.com/wp-content/sqlinjectionfuzzparameterconversation103withredtext.png" alt="Successful SQL injection" /></a></p>
<p align="center">Figure 7: SQL injection changed redirect location</p>
<p align="left">Looks like on conversation 103 one of the SQL injections in the attack dictionary changed the location of the redirect to /lobby/games.  Let&#8217;s throw the injection value back into the web application and see what the response may be.  The request can be seen in Figure 8.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/sqlinjectiononusernamewithcommentsatendofinjection.png" title="SQL injection on Hacme Casino username"><img src="http://travisaltman.com/wp-content/sqlinjectiononusernamewithcommentsatendofinjection.png" alt="SQL injection on Hacme Casino username" /></a></p>
<p align="center">Figure 8: SQL injection request on Hacme Casino</p>
<p align="left">The response to this SQL injection can be seen below in Figure 9.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/aftersqlinjectionviawebinterface.png" title="Successful SQL injection"><img src="http://travisaltman.com/wp-content/aftersqlinjectionviawebinterface.png" alt="Successful SQL injection" /></a></p>
<p align="center">Figure 9: SQL injection response (Great success!)</p>
<p align="left">Looks like the SQL injection gave us access to Andy Aces&#8217; account.  This occurred because we added the phrase &#8220;or 1=1&#8243; (which is always true) to the end of the SQL query that authenticates the users to Hacme Casino.  The reason Andy Aces&#8217; account was hijacked is because his name is the first one in the database.  Guess having the last name Altman could be bad for me as well?  Looking through the other conversations there appears to be another SQL injection that worked as well, this can be seen in Figure 10.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/sqlinjectionfuzzparameterconversation117withredtext.png" title="Another successful SQL injection"><img src="http://travisaltman.com/wp-content/sqlinjectionfuzzparameterconversation117withredtext.png" alt="Another successful SQL injection" /></a></p>
<p align="center">Figure 10: Another successful SQL injection</p>
<p align="left">The hits just keep on coming.  This may seem to easy but there are plenty of web applications out in the wild that don&#8217;t validate input and let malicious users manipulate their application and backend databases.  SQL injections within a web application can be a serious vulnerability depending on the data held within the database.  Had this scenario been real a malicious user could have taken over Andy Aces&#8217; account and had his way inside the online casino.</p>
<p align="left">The fuzzing functionality of Webscarab makes web application vulnerability assessment a more automated process.  Manually entering all of those SQL injection attacks can take a very long time.  There is a downside to the dictionary approach though, your dictionary may not be as creative as a malicious user.  Some people believe that a fuzzer should generate random input and that you should try thousands of requests in order to properly test a web application.  Thousands of random requests could be better but stepping through those requests to determine validity can make for a long day.  Although if one were to take the random input approach Webscarab has a solution for stepping through those results, the Compare and Search functionality.  I may dive into the Compare and Search functionality at a later date, these functions can really speed up the process of web vulnerability assessment.  Also keep your eye open for a video tutorial of Webscarab coming soon, you could always subscribe to my feed for the latest and greatest.</p>
<p align="left">Once again I hope this tutorial was helpful in showing you the great features of Webscarab, as always your comments and feedback are welcomed.</p>
<p align="left">travis@home:~$ more references</p>
<p align="left"><a href="http://www.owasp.org/index.php/Fuzzing_with_WebScarab">Owasp Webscarab fuzzing tutorial</a></p>
<p align="left"><a href="http://dawes.za.net/rogan/webscarab/docs/">Rogan Dawes documentation for Webscarab</a></p>
<p align="left"><a href="http://www.foundstone.com/us/resources/proddesc/hacmecasino.htm">Foundstone Hacme Casino</a></p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/webscarab-tutorial-part-3-fuzzing/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Webscarab Tutorial Part 2 (sessiond ID analysis)</title>
		<link>http://travisaltman.com/webscarab-tutorial-part-2-sessiond-id-analysis/</link>
		<comments>http://travisaltman.com/webscarab-tutorial-part-2-sessiond-id-analysis/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 17:18:49 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://travisaltman.com/webscarab-tutorial-part-2-sessiond-id-analysis/</guid>
		<description><![CDATA[Part 1 of this series focused on the basics of using a HTTP proxy to assess a web application.  I encourage people to play around with HTTP proxies with a web application that they use frequently, it&#8217;s interesting to see what information is being passed between the client and server.  This communication can [...]]]></description>
			<content:encoded><![CDATA[<p>Part 1 of this series focused on the basics of using a HTTP proxy to assess a web application.  I encourage people to play around with HTTP proxies with a web application that they use frequently, it&#8217;s interesting to see what information is being passed between the client and server.  This communication can sometimes include your private information so it&#8217;s good to understand how that particular web application is handling your information.</p>
<p><span id="more-38"></span></p>
<p>Part 2 in this series is going to focus on session ID analysis.  If you are not familiar with session ID&#8217;s I&#8217;ll do a quick explanation.  HTTP is a stateless protocol, so it&#8217;s equivalent to walkie talkies or CB radios.  You&#8217;ll send a request and wait for a reply, you don&#8217;t have a constantly open communication line as you would with a phone.   So in order to emulate this open communication the HTTP protocol uses session ID&#8217;s, commonly known as cookies.  These cookies are simply agreements between you and the web application that you are who you claim to be.  Once you have exchanged your cookie with the website you can then talk back and forth as long as the cookie is tied to your communication.  So there&#8217;s the quick and dirty intro to session ID&#8217;s.  So the next logical question is how does this session ID process work or even better how should it work?  Let&#8217;s use a web mail application as an example:</p>
<ol>
<li>You login to your web mail account</li>
<li>Your web mail provider sends you a &#8220;<strong>random</strong>&#8221; cookie that is tied to your login session</li>
<li>Each time you click on a new message within your Inbox your cookie is sent along to validate who you claim to be, that way you&#8217;ll get your next message and not another person&#8217;s message.</li>
</ol>
<p>These are the basic steps.  The main thing to remember is that your login credentials are tied to the session ID / cookie.  So the key to keeping your conversations private is protecting the session ID and making it hard to guess.  Session ID&#8217;s are similar to passwords in that regard, you always want to keep them a secret and make them hard to guess.  When Webscarab analyzes the session ID it only focuses on if the session is easy or hard to guess (aka <strong>randomness</strong>).  So enough with the chit chat let&#8217;s see how Webscarab analyzes session ID&#8217;s.</p>
<p>Once again we&#8217;re going to be analyzing the Hacme Casino web application.  The login page for this application can be seen in Figure 1.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/hacmecasinologinpage.PNG" title="Hacme Casino Login Page"><img src="http://travisaltman.com/wp-content/hacmecasinologinpage.PNG" alt="Hacme Casino Login Page" /></a></p>
<p align="center">Figure 1: Hacme Casino login</p>
<p align="left">So with Webscarab already running in the background I&#8217;ll go ahead and login into Hacme Casino and click on a few links.  Navigating inside the application will generate requests and responses that we can later analyze.  Now the login process should generate a session ID but there could be other session ID&#8217;s generated within the application that you may want to analyze as well.  You could always keep an eye on the summary tab to see if you are capturing cookies.  There are other ways to maintain state within a web application but cookies are the most common.  When looking at the summary tab for the login process you can see that cookies are being set.  This can be seen in the first conversation in the bottom row on Figure 2.</p>
<p align="center"><a href="http://travisaltman.com/wp-content/summaryhacmeloginviawebscarab.PNG" title="Webscarab summary of Hacme Casino login process"><img src="http://travisaltman.com/wp-content/summaryhacmeloginviawebscarab.PNG" alt="Webscarab summary of Hacme Casino login process" /></a></p>
<p align="center">Figure 2: Login process for Hacme Casino</p>
<p align="left">So the conversation with the path /account/login is setting a cookie, also the top pane has a check mark indicating that the login URL is setting a cookie as well.  This is definitely a good target because we know the functionality of this session ID is to maintain my balance and gambling stats.  Some session ID&#8217;s can be tough to figure out and sometimes it seems like developers set cookies for no reason.  So now let&#8217;s walk through the steps to analyze the session ID associated with /account/login.</p>
<ol>
<li><strong>Log out of the current session.</strong>  I can&#8217;t stress this enough, the first time I was using this feature I bumbled around for a couple of hours trying to figure out why it wasn&#8217;t analyzing the sessions.  Further down in this article I&#8217;ll show you a screen shot of what it looks like when you try and analyze the session you are currently logged into.</li>
<li>Navigate to the Session ID Analysis tab &gt;&gt; Collection tab within Webscarab.  There you will see a drop down list labeled &#8220;Previous Requests&#8221;, here you can pick a conversation from your history of transactions within the web application to analyze.  We already know that we want to analyze the /account/login conversation because we saw that it was setting cookies.  If you were unsure which conversation used session ID&#8217;s you could click on the &#8220;Test&#8221; button to verify if session information existed.  Figure 3 shows a screen shot of me choosing the /account/login conversation for analysis.</li>
<p align="center"><a href="http://travisaltman.com/wp-content/sessionidcollectiontab.PNG" title="Choosing conversation with the Session ID &gt;&gt; Collection tab"><img src="http://travisaltman.com/wp-content/sessionidcollectiontab.PNG" alt="Choosing conversation with the Session ID &gt;&gt; Collection tab" /></a></p>
<p align="center">Figure 3: Choosing conversation in Collection tab</p>
<li>After you have chosen your conversation for analysis you will then click on the &#8220;Fetch&#8221; button to start collecting session ID&#8217;s from the web server.  The default number of session ID&#8217;s collected is set at 100 but you can choose more if you like.  My background is math and science so I&#8217;m of the opinion that you can never have to many data points.  Play with this number if you like, in my experience more samples will do a better job at producing trends and pointing out weaknesses in random number generation.  The law of diminishing returns will eventually kick in though.  So after you have clicked the &#8220;Fetch&#8221; button you will need to move over to the &#8220;Analysis&#8221; tab.  When you first click on the &#8220;Analysis&#8221; tab it may seem like nothing is happening, this is because you need to select your session ID from the &#8220;Session Identifier&#8221; drop down list.  This drop down list can be seen in Figure 4.</li>
<p align="center"> <a href="http://travisaltman.com/wp-content/sessionidanalysistab.PNG" title="Session ID analysis tab"><img src="http://travisaltman.com/wp-content/sessionidanalysistab.PNG" alt="Session ID analysis tab" /></a></p>
<p align="center">Figure 4: Choosing session in Analysis tab</p>
<blockquote></blockquote>
<p align="left">Once you have selected your session that you are analyzing the table should begin to populate with the number of samples that you chose in the Collection tab.  Webscarab takes the session ID&#8217;s found within the web application and converts them into numbers so that they can be easily parsed.  These numbers are then compared to one another for predictability.  Figure 5 below shows what happens when you try to analyze the current session, you&#8217;ll get zeros for both the Numeric value and the difference.  This is because the session ID / cookie stays the same.</p>
<blockquote></blockquote>
<p align="center"> <a href="http://travisaltman.com/wp-content/chosecurrentsessionforanalysis.PNG" title="Choosing session for analysis"><img src="http://travisaltman.com/wp-content/chosecurrentsessionforanalysis.PNG" alt="Choosing session for analysis" /></a></p>
<p align="center">Figure 5: Analyzing current session</p>
<p align="left">&nbsp;</p>
<li>The fourth and final step is neatest part of the session ID analysis functionality within Webscarab, the Visualization tab.  This tab creates a graph using the numbers from the Analysis tab.  This will give you a quick visual representation of how weak or strong the session ID&#8217;s are.  The graphical analysis of the Hacme Casino session ID&#8217;s can be seen below in Figure 6.</li>
</ol>
<p align="center"><a href="http://travisaltman.com/wp-content/cookiesovertimegraph.PNG" title="Cookies over time graph"><img src="http://travisaltman.com/wp-content/cookiesovertimegraph.PNG" alt="Cookies over time graph" /></a></p>
<p align="center">Figure 6: Cookies over time for Hacme Casino</p>
<blockquote>
<p align="left">It appears that the session ID&#8217;s created for Hacme Casino are random or at the very least not easy to guess.  Your average malicious user is going to see that the session ID&#8217;s are going to be difficult to guess, so they&#8217;ll move on and try another vector to get inside the web application.  A malicious user will be looking for easy access so they will be looking for session ID&#8217;s that are very easy to guess.  Figure 7 shows an application that implements session ID&#8217;s that are very easy to guess.</p>
</blockquote>
<p align="center"> <a href="http://travisaltman.com/wp-content/weakcookiesovertime.JPG" title="Weak cookies over time"><img src="http://travisaltman.com/wp-content/weakcookiesovertime.JPG" alt="Weak cookies over time" /></a></p>
<p align="center">Figure 7: Weak cookies over time</p>
<blockquote>
<p align="left">This graph was not generated using Foundstone&#8217;s Hacme Casino but had a malicious user seen this type of graph it would be very easy for them to guess a session ID and essentially hijack that person&#8217;s Hacme Casino account.  From the casino example you can see how dangerous weak session ID&#8217;s can be.  Session ID&#8217;s are the &#8220;key&#8221; to someone&#8217;s account information.  This is possible due to the stateless nature of HTTP.  So a malicious user could hijack your account without ever knowing your username or password.</p>
</blockquote>
<p align="left">This concludes Part 2 of the Webscarab tutorial.  If you have something to add or see an error please leave a comment or contact me.  Part 3 is going to focus on the fuzzing functionality within Webscarab.  Until then try the session ID functionality on a web application that you use often and see how weak or strong their session ID management is.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/webscarab-tutorial-part-2-sessiond-id-analysis/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Webscarab Tutorial Part 1 (learning the basics)</title>
		<link>http://travisaltman.com/webscarab-tutorial-part-1-learning-the-basics/</link>
		<comments>http://travisaltman.com/webscarab-tutorial-part-1-learning-the-basics/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 11:54:20 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://travisaltman.com/webscarab-tutorial-part-1-learning-the-basics/</guid>
		<description><![CDATA[This tutorial is designed to walk you through the basics of using a HTTP proxy. A HTTP proxy is very useful when it comes to web application vulnerability assessment. A proxy will allow you to record all of your transactions while using the web application producing a history of pages you have visited and links [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">This tutorial is designed to walk you through the basics of using a HTTP proxy.<span> </span>A HTTP proxy is very useful when it comes to web application vulnerability assessment.<span> </span>A proxy will allow you to record all of your transactions while using the web application producing a history of pages you have visited and links you have clicked.<span> </span>A proxy also allows you to see the HTTP request and responses, basically you&#8217;ll see what is being sent behind the scenes.<span> </span>This document will go into more detail about what a HTTP proxy can do as we step through some exercises on analyzing traffic from a web application.</p>
<p><span id="more-30"></span></p>
<p class="MsoNormal">This tutorial is going to focus on Webscarab, although there are other numerous useful tools on the market (e.g. Paros, Burp).<span> </span>The first thing we&#8217;ll need to do is obtain Webscarab, I like to use the version signed by Rogan Dawes, <span> </span>which can be found <a href="http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project">here</a>.<span> </span>Go to the downloads section and make sure you get the Java Web Start version signed by Rogan Dawes.<span> </span>The second thing we&#8217;ll need to do is start up Webscarab.<span> </span>By default Webscarab listens on port 8008 but this can be easily changed to any port.<span> </span>These settings can be seen in Figure 1.</p>
<p class="MsoNormal"><a title="Webscarab proxy port settings" href="http://travisaltman.com/wp-content/webscarabproxysettings.JPG"><img src="http://travisaltman.com/wp-content/webscarabproxysettings.JPG" alt="Webscarab proxy port settings" /></a></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family: 'Times New Roman';">Figure 1: Webscarab proxy settings</span></p>
<p class="MsoNormal">We&#8217;ll also need to configure our browser so that our communication is pointed through the proxy.  In recent versions of Firefox the path should be Tools &gt;&gt; Options &gt;&gt; Advanced Tab &gt;&gt; Network Tab &gt;&gt; Settings. Once there you&#8217;ll need to highlight &#8220;Manual proxy configuration&#8221;, then for &#8220;HTTP Proxy&#8221; type in &#8220;localhost&#8221; and for port use 8008.  You&#8217;ll also need to do this for the SSL proxy if the web application uses SSL. These settings can be seen in Figure 2.</p>
<p class="MsoNormal"><a title="Firefox proxy settings" href="http://travisaltman.com/wp-content/firefoxproxysettings.JPG"><img src="http://travisaltman.com/wp-content/firefoxproxysettings.JPG" alt="Firefox proxy settings" /></a></p>
<p class="MsoNormal">Figure 2: Firefox proxy settings</p>
<p class="MsoNormal">The path to change IE settings: Tools &gt;&gt; Internet Options &gt;&gt; Connections tab &gt;&gt; LAN settings.<span> </span>Here you&#8217;ll need to check the box that says &#8220;Use a proxy server for your LAN&#8221;, this can be seen in Figure 3.</p>
<p class="MsoNormal"><a title="Internet Explorer proxy settings" href="http://travisaltman.com/wp-content/ieproxysettings.JPG"><img src="http://travisaltman.com/wp-content/ieproxysettings.JPG" alt="Internet Explorer proxy settings" /></a></p>
<p class="MsoNormal">Figure 3: IE proxy settings</p>
<p class="MsoNormal">This tutorial is going to show how Webscarab can walk through and assess the Hacme Casino web application provided by Foundstone, Figure 4 shows the login page for this application.</p>
<p class="MsoNormal"><a title="Hacme Casino Login Page" href="http://travisaltman.com/wp-content/hacmecasinologinpage.PNG"><img src="http://travisaltman.com/wp-content/hacmecasinologinpage.PNG" alt="Hacme Casino Login Page" /></a></p>
<p class="MsoNormal">Figure 4: Hacme Casino login page</p>
<p class="MsoNormal">I have already created an account within the application with the username &#8220;hacker&#8221; and a password of &#8220;passwd&#8221;.  So with Webscarab already running in the background I am going to login to Hacme Casino.  If you are on the summary tab within Webscarab you will notice requests and responses filling up rows in the bottom pane.  Webscarab is logging all communication between you and the web server, this includes all images, CSS files, Javascript files, parameters, etc&#8230;  The top pane of the summary tab shows you a directory structure of your history through the web application.  This summary tab can be seen in Figure 5.</p>
<p><a title="Webscarab summary of Hacme Casino login process" href="http://travisaltman.com/wp-content/summaryhacmeloginviawebscarab.PNG"><img src="http://travisaltman.com/wp-content/summaryhacmeloginviawebscarab.PNG" alt="Webscarab summary of Hacme Casino login process" /></a></p>
<p>Figure 5: Webscarab summary tab</p>
<p>Now a summary of your history is neat but that only scratches the surface of Webscarab&#8217;s functionality.<span> </span>One of the best functions of a HTTP proxy is the ability to intercept requests on the fly or replay those requests at a later time.<span> </span>In order to intercept requests / responses make sure you have checked the &#8220;Intercept requests&#8221; / &#8220;Intercept responses&#8221; checkboxes in the Proxy &gt;&gt; Manual Edit tab.<span> </span>These settings can be seen in Figure 6.</p>
<p><a title="Webscarab intercept settings" href="http://travisaltman.com/wp-content/webscarabinterceptsettings.JPG"><img src="http://travisaltman.com/wp-content/webscarabinterceptsettings.JPG" alt="Webscarab intercept settings" /></a></p>
<p>Figure 6: Webscarab intercept settings</p>
<p>You may be wondering why you would want to intercept or repeat a HTTP request / response.<span> </span>The simple answer is to learn more about what a website is doing with your input (e.g. SSN, credit card, personal information).<span> </span>Application security folks, developers, or curious people may want to understand more about the web application they&#8217;re using.<span> </span>Intercepting a request / response will allow you to see and manipulate communication being sent back and forth.<span> </span>Application security analysts like to replay requests over and over again with different inputs to see what the application will allow as input.<span> </span>This will give security analysts an idea of how secure the application is.<span> </span>Had we intercepted the login process you would have seen the inputs for username and password being sent to the web server.<span> </span>A screen shot of this can be seen in Figure 7.</p>
<p><a title="Interception of Hacme Casino login credentials" href="http://travisaltman.com/wp-content/intercepthacmelogincredentials.PNG"><img src="http://travisaltman.com/wp-content/intercepthacmelogincredentials.PNG" alt="Interception of Hacme Casino login credentials" /></a></p>
<p>Figure 7: Interception of the login process for Hacme Casino</p>
<p>You can see in Figure 7 that Webscarab has intercepted both the username &#8220;hacker&#8221; and password &#8220;passwd&#8221;.<span> </span>A HTTP proxy is able to see the password even though each character was replaced by an asterisk within the application.<span> </span>At this point you could accept the request or manipulate the parameters.<span> </span>You could try to login as someone at this point even though you initially typed in a different username and password.<span> </span>With a HTTP proxy you could manipulate any request / response not just the login process.</p>
<p>This covers Part 1 of the tutorial on Webscarab.<span> </span>OWASP also has a great write up, called <a href="http://www.owasp.org/index.php/WebScarab_Getting_Started">Getting Started</a>, going over basically what I have covered here.<span> </span>So if you ever wanted to know more about a web application Webscarab is a great tool that can help you learn more.<span> </span>In Part 2 of this series we&#8217;ll analyze how an application maintains state by using the &#8220;SessionID Analysis&#8221; functionality of Webscarab.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/webscarab-tutorial-part-1-learning-the-basics/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Tunneling HTTP thru SSH</title>
		<link>http://travisaltman.com/tunneling-http-thru-ssh/</link>
		<comments>http://travisaltman.com/tunneling-http-thru-ssh/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 19:22:26 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[privacy]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=12</guid>
		<description><![CDATA[The purpose of this tutorial is to give a quick, concise overview of how to secure your communications through a non-trusted or insecure channel.  You could also use this tutorial to evade organizational firewalls and web filters but, I am more concerned about keeping my communications private rather than evading organizational filters.  I [...]]]></description>
			<content:encoded><![CDATA[<p>The purpose of this tutorial is to give a quick, concise overview of how to secure your communications through a non-trusted or insecure channel.  You could also use this tutorial to evade organizational firewalls and web filters but, I am more concerned about keeping my communications private rather than evading organizational filters.  I have seen other tutorials that show how to accomplish tunneling http traffic over SSH but not in a very simple manner, so I hope this tutorial will accomplish this goal as well as help others.  As always your feedback is welcome, either by commenting on this article or via my contact form.</p>
<p><span id="more-12"></span></p>
<p>Prerequisites:</p>
<ol>
<li>Remote PC running an SSH server.  Windows XP default does not come with an SSH client / server, so I recommend OpenSSH.  Most Linux distributions already have installed a SSH client / server that can be used.</li>
<li>Determine which ports you are going to use?  It is sometimes difficult to determine which ports you are allowed to use but most organizations are going to have port 80, 443, and most likely 22 open for communication.  In this tutorial we are going to use ports 22 and 80 for our tunneling although you can use any port that is open.</li>
</ol>
<p><strong>Tunneling with Windows XP, IE (internet explorer), Firefox, and Putty (SSH client):</strong></p>
<p>I recommend the Putty client when using XP because it&#8217;s free and easy, but you can use any SSH client.  For this tutorial I will only focus on Putty.  So the first step is to configure Putty for tunneling.  Click on the &#8220;Tunnels&#8221; tab underneath the branch of &#8220;SSH&#8221; within Putty.  There under the Source port form you will add what port will be doing all of the forwarding.  I have chosen to use port 80 as most organizations allow the use of this port.  You will also put in the IP address of your remote PC that is running a SSH server.  You&#8217;ll also need to highlight the button that says dynamic.  A screen shot of this can be seen in Figure 1.</p>
<p><a title="Putty port forwarding configuration page" href="http://travisaltman.com/wp-content/puttyportforwardingmenu.png"><img src="http://travisaltman.com/wp-content/puttyportforwardingmenu.png" alt="Putty port forwarding configuration page" /></a></p>
<p>Figure 1:  Putty port forwarding configuration page</p>
<p>Once you have done this click the Add button, this will create the forwarded port for the session.  You will notice that it puts a letter beside the port you have chosen.  This can be seen in figure 2.</p>
<p><a title="Add port and destination settings" href="http://travisaltman.com/wp-content/addportanddestinationforwardingputty.png"><img src="http://travisaltman.com/wp-content/addportanddestinationforwardingputty.png" alt="Add port and destination settings" /></a></p>
<p>Figure 2:  Add port and destination settings</p>
<p>Once you have set up port forwarding you can then go back to the main &#8220;Session&#8221; page and type in the IP address of your remote PC.  You can also see that I am connecting to the remote SSH server on port 22.  This could easily be changed to a port of your choosing.  If your organization doesn&#8217;t allow communication on port 22 but does allow port 443 simply put 443 in the port form.  If this were the case you need to make sure that the remote SSH server is listening on port 443 instead of the default 22. Once you have done this you can save your session so that you can easily connect the next time.  You can see that I have named my session HTTPtunnelViaSSH in Figure 3.</p>
<p><a title="Putty main menu" href="http://travisaltman.com/wp-content/puttymainmenu.png"><img src="http://travisaltman.com/wp-content/puttymainmenu.png" alt="Putty main menu" /></a></p>
<p>Figure 3: Putty main menu</p>
<p>Now click open and another window will open asking for authentication credentials on the remote PC.  Once connected the cursor will move down to the next line, this is the normal operation of Putty.  If you didn&#8217;t input your authentication credentials correctly you will get a message stating so.  A successful connection with Putty can be seen in Figure 4.</p>
<p><a title="Successfull connection with Putty" href="http://travisaltman.com/wp-content/successfullconnectionputty.jpg"><img src="http://travisaltman.com/wp-content/successfullconnectionputty.jpg" alt="Successfull connection with Putty" width="626" height="244" /></a></p>
<p>Figure 4:  Successfull connection via Putty</p>
<p>Now once a successful connection has been made with Putty we need to configure our browser to use the SSH proxy so that all of our HTTP traffic is funneled over our secure connection.  We will first configure Firefox.  The actual steps to get to the &#8220;Connection Settings&#8221; within Firefox may vary depending on which version you&#8217;re running but generally the path is:  Tools &gt;&gt; Options &gt;&gt; Advanced Tab &gt;&gt; Network Tab &gt;&gt; Settings.  Once there you will need to highlight the &#8220;Manual proxy configuration&#8221;, then for the &#8220;SOCKS Host&#8221; use localhost.  The port will be port 80 in this case because we told Putty to tunnel our connection via port 80, YMMV (your method may vary).  The screen shot of this configuration can be seen in Figure 5.</p>
<p><a title="Firefox proxy settings for tunneling HTTP over SSH" href="http://travisaltman.com/wp-content/firefoxconfigsettingsforhttptunnel.png"><img src="http://travisaltman.com/wp-content/firefoxconfigsettingsforhttptunnel.png" alt="Firefox proxy settings for tunneling HTTP over SSH" /></a></p>
<p>Figure 5:  Firefox configuration settins for tunneling HTTP over SSH</p>
<p>The same concept applies when configuring internet explorer.  Once again the location of the &#8220;Proxy settings&#8221; for internet explorer will vary depending upon which version you are running but generally the path is: Tools &gt;&gt; Internet Options &gt;&gt; Connections tab &gt;&gt; LAN settings.  Here you will need to check the box that says &#8220;Use a proxy server for your LAN&#8221;, this screenshot can be seen in Figure 6.</p>
<p><a title="Proxy server settings for internet explorer" href="http://travisaltman.com/wp-content/proxyserversettingsforie.png"><img src="http://travisaltman.com/wp-content/proxyserversettingsforie.png" alt="Proxy server settings for internet explorer" /></a></p>
<p>Figure 6:  Proxy server settings for Inernet Explorer</p>
<p>You must then click on the &#8220;Advanced&#8221; tab to fill out the Socks connection form.  Once again we&#8217;ll use the &#8220;localhost&#8221; as the host and port 80 for our tunnel.  This screenshot can be seen in Figure 7.</p>
<p><a title="Socks settings for internet explorer" href="http://travisaltman.com/wp-content/sockssettingsforie.png"><img src="http://travisaltman.com/wp-content/sockssettingsforie.png" alt="Socks settings for internet explorer" /></a></p>
<p>Figure 7:  Socks settings for Internet Explorer</p>
<p>Once you have completed this step you are done, just click all of the OK buttons.  You should now be tunneling all of your HTTP connections to your remote PC in a secure shell, congratulations.  You have now stuck it to the man, whomever that may be.</p>
<p><strong>Tunneling HTTP via SSH with Linux, Firefox, and SSH:</strong></p>
<p>The procedures for tunneling HTTP traffic in Linux is almost exactly the same as it is in Linux, the only exception being the SSH client.  The operating systems have really nothing to do with this whole process.  There are numerous SSH clients that can be used with Linux although most distributions come with a SSH client.  I will be using the command line interface as oppose to a GUI interface.  So using your favorite shell use the following 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">ssh travis@YourRemotePC -D 80</div></div>
<p>After issuing this command you will be prompted for your password.  Keep in mind that you may need to be &#8220;root&#8221; in order to run this command.  Unlike Putty you will be given the prompt for the remote PC instead of the cursor going to the next line.  After the connection has been established just go into the settings for Firefox, as seen in figure 5, and type in &#8220;localhost&#8221; and which port you are forwarding your traffic.  Once again we could have chosen any open port to tunnel out HTTP traffic.  This is accomplished with the -D option within the SSH command, instead of 80 you could have chosen port 443.  That&#8217;s it for Linux, you are now keeping your communications private and secure, congrats.</p>
<p>As always I welcome your feedback in the comments section if you have found this article erroneous or have a better solution.</p>
<p>References:</p>
<p>http://polishlinux.org/apps/ssh-tunneling-to-bypass-corporate-firewalls/, http://www.forniol.cat/?p=50</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/tunneling-http-thru-ssh/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

