<?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>engfer(s) &#187; Hacks</title>
	<atom:link href="http://www.engfers.com/category/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.engfers.com</link>
	<description>» scrumptions blog &#038; code » nothing more, nothing less</description>
	<lastBuildDate>Tue, 06 Oct 2009 21:52:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to Use HTTP/Radio/Anything Behind a Proxy or Firewall</title>
		<link>http://www.engfers.com/2008/08/21/how-to-use-http_radio_anything-behind-a-proxy-or-firewall/</link>
		<comments>http://www.engfers.com/2008/08/21/how-to-use-http_radio_anything-behind-a-proxy-or-firewall/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 18:14:01 +0000</pubDate>
		<dc:creator>engfer</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[proxies]]></category>

		<guid isPermaLink="false">http://www.engfers.com/?p=143</guid>
		<description><![CDATA[Proxy firewalls and content filters are both good &#38; evil things; they can prevent you from making a bad mistake, or bad mistakes happening to you. However, sometimes it might be useful to punch through a proxy or firewall.  Whether it might be for your youtube fetish, listening to internet radio, or uploading images/media into [...]]]></description>
			<content:encoded><![CDATA[<p><div style="float: left; padding: 0px 5px 5px 0px;"><script type="text/javascript"><!--
google_ad_client = "pub-9461422058527053";
google_ad_slot = "3901277195";
google_ad_width = 300;
google_ad_height = 250;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div> <strong>Proxy firewalls and content filters</strong> are <em>both </em><strong>good </strong>&amp; <strong>evil </strong>things; they can prevent you from making a <em>bad </em>mistake, or bad mistakes happening to <em>you</em>. However, sometimes it might be useful to <span style="text-decoration: underline;">punch</span> through a proxy or firewall.  Whether it might be for your youtube fetish, listening to internet radio, or uploading images/media into WordPress successfully (or you are a proxy admin and you want to prevent this sort of thing), this article on <em>pushing connections through a firewall</em> may be suitable for you.</p>
<p><strong>Caveat</strong>: <em>Doing things like this can be against your proxy provider&#8217;s policies. You are responsible for your own actions. This article is for educational purposes only</em>!</p>
<p><em>System administrators and network security personnel</em>: pay close attention to this article!</p>
<p><span id="more-143"></span></p>
<h3 class="hrule"><span style="color: #3366ff;">Background Information and Explanation</span></h3>
<p>For our background information/explanation, we are going to use HTTP requests from an internet browser</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/http_request_normal.png"><img class="size-full wp-image-202 aligncenter" title="http_request_normal" src="http://www.engfers.com/wp-content/uploads/2008/08/http_request_normal.png" alt="" width="420" height="105" /></a></p>
<p>The above figure shows an example connection in a normal setting <strong>without </strong>a proxy or firewall. HTTP requests are made directly from your browser to the web server endpoint.</p>
<p>If you type http://www.google.com into your browser, the browser <em>assumes </em>that the there is an implicit &#8220;:80&#8243; at the end of your server endpoint and that the web server you are trying to hit is listening on <strong>port 80</strong>. (i.e. you can get the same effect by entering http://www.google.com:80</p>
<ul>
<li><strong>FYI</strong>: 80 is the default <a href="http://en.wikipedia.org/wiki/Http">HTTP</a> web server port and 443 is the default <a href="http://en.wikipedia.org/wiki/Https">HTTP<span style="text-decoration: underline;"><strong>S</strong></span></a> web server port.</li>
</ul>
<p>(If you don&#8217;t know what <a href="http://en.wikipedia.org/wiki/TCP_and_UDP_port">ports</a> are, think of them like much like windows and doors in a building. If you enter through certain doors/windows in the building, you can get to certain parts and rooms of that building. It&#8217;s the same type of thing on a computer except that data is exchanged through those windows.  If you don&#8217;t want people to come in those windows (ports on your machine), you can have them closed or blocked.)</p>
<p>Anyways, the browser begins by making a <a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP</a> socket connection to the specified server on port 80 and begins transmission. Once the server has finished processing the request, it will send back and HTTP response.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-201" title="http_request_firewall" src="http://www.engfers.com/wp-content/uploads/2008/08/http_request_firewall.png" alt="" width="420" height="126" /></p>
<p style="text-align: left;">Now we have a little bit different scenario above.  We are in a setting where we have some <a href="http://en.wikipedia.org/wiki/Proxy_server">proxy server</a> that has a firewall that <em>filters </em>our HTTP requests and also blocks bad responses from the outside world.</p>
<p style="text-align: left;">If you try to make a direct connection to the web server without first configuring your browser, it will not make the connection. However, once your browser is told that there is a proxy server, the request will go through (as long as it passes the filter criteria). In your browser connection settings, you can set your proxy address and ports.</p>
<p style="text-align: left;">For example, say that proxy.engfers.com is your proxy server with the proxy port being 3123 (random port number, but yours might be port 80 or 8080 or anything). Well, the browser first knows that it must make a connection to the proxy server to make it to the outside world, so it makes the proxy connection. Any requests are passed through the proxy port and the firewall and content filter will <em>examine </em>where your request is headed and will allow or deny the passage of your request onto the destination web server.</p>
<p style="text-align: left;">If your request passes inspection, it is then passed along to the outside web site / server (through whatever port was originally specified&#8230; 80 in our google.com example)</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-200" title="http_request_blocked" src="http://www.engfers.com/wp-content/uploads/2008/08/http_request_blocked.gif" alt="" width="420" height="137" /></p>
<p style="text-align: left;">Now we come to an instance where your request is not allowed to continue. The request is <em>blocked </em>and you usually get a response back from the proxy server saying why it was blocked.</p>
<p style="text-align: left;"><strong>NOTE:</strong> <em>A majority of the time your proxy server will have some sort of authentication attached to it, so make sure you check if it needs authentication or not first.</em></p>
<p style="text-align: left;"><strong>Well then we are hosed!!! Not <em>necessarily</em>, read on.</strong>..</p>
<p style="text-align: center;"><img class="size-full wp-image-198 aligncenter" title="ssh_request_firewall" src="http://www.engfers.com/wp-content/uploads/2008/08/ssh_request_firewall.png" alt="" width="420" height="114" /></p>
<p style="text-align: left;">Now we have an <a href="http://en.wikipedia.org/wiki/Secure_shell">SSH (<span style="text-decoration: underline;">S</span>ecure <span style="text-decoration: underline;">SH</span>ell)</a> client, like <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a>, that we would like to connect to an outside server.  Now you remember that 80 was the default connection port for HTTP, well <strong>22</strong> is the default port for SSH. Now it&#8217;s all very similar to the HTTP examples.</p>
<p style="text-align: left;">Behind a proxy, you must tell your SSH cient what your proxy server, port, username, and password is and if you can make a connection that outside server, you are doing okay!!</p>
<p style="text-align: center;"><img class="size-full wp-image-203 aligncenter" title="ssh_connection_proxy" src="http://www.engfers.com/wp-content/uploads/2008/08/ssh_connection_proxy.png" alt="" width="420" height="97" /></p>
<p style="text-align: left;">Well, once you <em>establish </em>a secure shell connection to that outside server, all requests are <span style="color: #ff0000;"><em><strong>encrypted</strong></em></span>!!! So if you can connect via SSH, the firewall / content filter <em>can&#8217;t read what&#8217;s in your data packets unless it&#8217;s smart enough to decrypt the packets</em>.</p>
<p style="text-align: left;"><span style="text-decoration: underline;"><em><strong>How does this help me though?</strong></em></span></p>
<p style="text-align: left;">Luckily, many SSH clients, like PuTTY, can let you <strong>tunnel other connections through the SSH pipe that it created with the outside server</strong>.</p>
<p style="text-align: left;"><span style="text-decoration: underline;"><em><strong>What kind of connections can be tunneled?</strong></em></span></p>
<p style="text-align: left;">Any thing that supports connections to a <a href="http://en.wikipedia.org/wiki/SOCKS">SOCKS</a> proxy.  <strong>Web browsers</strong> are a good example.  <span style="color: #ff0000;"><strong><span>NOTE: <em>On Windows machines, many programs (like <span style="text-decoration: underline;">iTunes</span>, Windows Media Player, Adobe Flash Player) make their connections through Internet Exploder, so as long as IE can connect they can as well!</em></span></strong></span></p>
<p style="text-align: left;"><span style="text-decoration: underline;"><em><strong>Say what?</strong></em></span></p>
<p style="text-align: left;">Okay so check out this next diagram&#8230;</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/http_over_ssh.png"><img class="size-medium wp-image-199 aligncenter" title="http_over_ssh" src="http://www.engfers.com/wp-content/uploads/2008/08/http_over_ssh.png" alt="" width="420" height="275" /></a></p>
<p style="text-align: left;">So now you have an SSH client on your local box (like PuTTY) that you have set up SOCKS tunneling on, and you are connected through the firewall to the external desktop/server on a secure and encrypted connection. Now you take your SOCKS capable program (like Internet Exploder) and tell it to point to <strong>127.0.0.1</strong> as your SOCKS proxy and set the port to whatever port you told your SSH client.</p>
<p style="text-align: left; padding-left: 30px;"><em>Now, when you make your HTTP request, it <strong>first </strong>makes a <strong>SOCKS connection to your SSH client.</strong> The SSH client then takes the HTTP request and <strong>passes it (<span style="color: #ff0000;">encrypted</span>) through the SSH pipe (past the firewall) over to your server/desktop</strong>.  As long as that server/desktop </em><em>doesn&#8217;t have proxy server, it should make a direct connection to the endpoint web server and pass your HTTP request onto it, grab the HTTP response from the web server and pass it back along the pike until it comes back to your browser. <span style="text-decoration: underline;"><strong>Walla!!</strong></span> You have just made a successful request!!</em></p>
<p style="text-align: left;"><strong>NOTE</strong>: If your server/desktop is behind another proxy/firewall, you will have to setup more SSH+tunneling on <strong>that</strong> box to <em>another </em>server/desktop.</p>
<p style="text-align: left;"><strong>Now that we&#8217;ve explained the process, let&#8217;s go through the steps&#8230;</strong></p>
<h3 class="hrule"><span style="color: #3366ff;">Prerequisites</span></h3>
<h4><span style="color: #ff0000;">1. Putty</span></h4>
<p>Putt is an SSH/telnet client that has many other features tacked onto it like X11 forwarding and <a href="http://en.wikipedia.org/wiki/Port_forwarding"><span style="text-decoration: underline;"><strong>port tunneling</strong></span> (aka forwarding)</a>.</p>
<p><span style="text-decoration: underline;"><strong>Port </strong></span><span style="text-decoration: underline;"><strong>tunneling</strong></span> is what we care about&#8230;</p>
<h3>Download:</h3>
<ul>
<li><span style="color: #3366ff;"><a style="background: transparent url(http://www.engfers.com/wp-content/uploads/2008/08/putty.gif) scroll no-repeat left center; padding: 10px 0px 10px 40px;" title="Download putty.exe..." href="http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe">PuTTY</a></span></li>
</ul>
<h4><span style="color: #ff0000;">2. Server or Workstation Endpoint that can Accept SSH Connections</span></h4>
<p>If you don&#8217;t have this, the whole example is defunct. If you have some sort of linux machine lying around (or your hosting service uses linux =] ), it will accept SSH connections if sshd is turned on (usually on by default).</p>
<h3 class="hrule"><span style="color: #3366ff;">Tutorial</span></h3>
<h4><span style="color: #ff0000;">Step 1: Create the SSH Connection with a SOCKS Tunnel Enabled</span></h4>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/putty.png"><img class="size-medium wp-image-229 aligncenter" title="putty" src="http://www.engfers.com/wp-content/uploads/2008/08/putty-300x290.png" alt="" width="300" height="290" /></a></p>
<p><strong>Open PuTTY</strong>.</p>
<p>Enter in your server/workstation that you are going to connect to. Use an<strong> IP address</strong> or the <strong>domain name</strong>.</p>
<p>Select <strong>SSH </strong>as the Connection Type.</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/putty_tunnels.png"><img class="size-medium wp-image-231 aligncenter" title="putty_tunnels" src="http://www.engfers.com/wp-content/uploads/2008/08/putty_tunnels-300x290.png" alt="" width="300" height="290" /></a></p>
<p>On the left Category selection, choose <strong>Connection » SSH » Tunnels</strong>.</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/putty_tunnels_add.png"><img class="size-medium wp-image-232 aligncenter" title="putty_tunnels_add" src="http://www.engfers.com/wp-content/uploads/2008/08/putty_tunnels_add-300x290.png" alt="" width="300" height="290" /></a></p>
<p>In the &#8220;<em>Source port</em>&#8221; field, enter <strong>any port</strong> (7070 in our example) that you wish to use as your SOCKS port for all of your local applications to connect to.</p>
<p>Select <strong>Dynamic </strong>as the type of port.</p>
<p>Click the &#8220;<strong>Add</strong>&#8221; button.</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/putty_tunnels_add_success.png"><img class="size-medium wp-image-228 aligncenter" title="putty_tunnels_add_success" src="http://www.engfers.com/wp-content/uploads/2008/08/putty_tunnels_add_success-300x290.png" alt="" width="300" height="290" /></a></p>
<p>When successful, you should see a <em>&#8220;D&#8221; followed by whatever port you specified</em>.</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/putty_proxy_config.png"><img class="size-medium wp-image-230 aligncenter" title="putty_proxy_config" src="http://www.engfers.com/wp-content/uploads/2008/08/putty_proxy_config-300x290.png" alt="" width="300" height="290" /></a></p>
<p>Now in the left Category pane, go to<strong> Connection » Proxy</strong>.</p>
<p>Select your <strong>proxy type</strong> (usually it&#8217;s an <strong>HTTP </strong>proxy).</p>
<p>Enter your <strong>proxy&#8217;s hostname/ip-address</strong> (find this out).</p>
<p>Enter your <strong>proxy&#8217;s port</strong> (find this out).</p>
<p><em>If your proxy requres authentication</em>, enter your <strong>username </strong>and <strong>password</strong>.</p>
<p>Click &#8220;<strong>Open</strong>&#8221; to open the connection.</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/putty_connected.png"><img class="size-medium wp-image-234 aligncenter" title="putty_connected" src="http://www.engfers.com/wp-content/uploads/2008/08/putty_connected-300x188.png" alt="" width="300" height="188" /></a></p>
<p>Now you have your SOCKS server and SSH connection set up!! Now it&#8217;s time to configure your SOCKS capable apps to connect to PuTTY!!</p>
<h4><span style="color: #ff0000;">Step 2: Connect Your SOCKS-Proxy-Capable Applications to Your PuTTY Proxy</span></h4>
<p>Let&#8217;s take Internet Exploder and Firefox as examples&#8230;</p>
<p><span style="color: #999999;"><strong># Firefox&#8230;</strong></span></p>
<p>Open Firefox. Go to <strong>Tools » Options » Advanced (icon) » Network (tab) » Settings (button)</strong></p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/firefox_connection_socks.png"><img class="size-medium wp-image-236 aligncenter" title="firefox_connection_socks" src="http://www.engfers.com/wp-content/uploads/2008/08/firefox_connection_socks-286x300.png" alt="" width="286" height="300" /></a></p>
<p>Select the radio button that says &#8220;<em><strong>Manual proxy configuration</strong></em>&#8221;</p>
<p><strong>NOTE</strong>: At this point, you may have data <em>already </em>in your HTTP proxy address and ports, and all of the other server types will be <em>disabled </em>(greyed out). <span style="text-decoration: underline;">This is okay</span>; just <em>delete </em>the data in HTTP address and ports and <strong>make sure</strong> the checkbox &#8220;<strong><em>Use this proxy server for all protocols</em></strong>&#8221; is <strong>NOT checked</strong> (this will open the rest of the proxy servers for editing).</p>
<p>In the <span style="text-decoration: underline;"><strong>SOCKS Host</strong></span> proxy server line, enter in <span style="color: #ff0000;"><strong>127.0.0.1</strong></span> for the <strong>socks proxy server</strong> and set the <strong>socks proxy port</strong> to <span style="color: #ff0000;"><strong>whatever-you-set-up-in-putty-as-your-tunnel-port</strong></span> (7070 in our example).</p>
<p>Hit &#8220;OK&#8221;s until you are out of Firefox options and you are done!!!</p>
<p><span style="color: #999999;"><strong># Internet Exploder&#8230;</strong></span></p>
<p>Go to <strong>Tools » Internet Options » Connections (tab) » LAN Settings (button)</strong></p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/ie_connection_proxy.png"><img class="size-medium wp-image-237 aligncenter" title="ie_connection_proxy" src="http://www.engfers.com/wp-content/uploads/2008/08/ie_connection_proxy-297x300.png" alt="" width="297" height="300" /></a></p>
<p>Check the box under the <em>Proxy server</em> area that says &#8220;<strong>Use a proxy server for your LAN</strong>&#8221;</p>
<p><strong>NOTE:</strong> Make sure that the 2 checkboxes under <em>Automatic Configuration</em> are <strong>NOT </strong>checked.</p>
<p>Click on the &#8220;<strong>Advanced</strong>&#8221; button&#8230;</p>
<p style="text-align: center;"><a href="http://www.engfers.com/wp-content/uploads/2008/08/ie_connection_socks.png"><img class="size-medium wp-image-235 aligncenter" title="ie_connection_socks" src="http://www.engfers.com/wp-content/uploads/2008/08/ie_connection_socks-276x300.png" alt="" width="276" height="300" /></a></p>
<p><strong>NOTE</strong>: At this point, you may have data <em>already </em>in your HTTP proxy address and ports, and all of the other server types will be <em>disabled </em>(greyed out). <span style="text-decoration: underline;">This is okay</span>; just <em>delete </em>the data in HTTP address and ports and <strong>make sure</strong> the checkbox &#8220;<strong><em>Use the same proxy server for all protocols</em></strong>&#8221; is <strong>NOT checked</strong> (this will open the rest of the proxy servers for editing).</p>
<p>In the <span style="text-decoration: underline;"><strong>Socks</strong></span> proxy server line, enter in <span style="color: #ff0000;"><strong>127.0.0.1</strong></span> for the <strong>socks proxy server</strong> and set the <strong>socks proxy port</strong> to <span style="color: #ff0000;"><strong>whatever-you-set-up-in-putty-as-your-tunnel-port</strong></span> (7070 in our example).</p>
<p>Hit &#8220;OK&#8221;s until you are out of IE options and you are done!!!</p>
<h3 class="hrule"><span style="color: #3366ff;">What about Flash, iTunes radio, Windows Media Player, etc working?</span></h3>
<p><strong>After </strong>you configure <strong>Internet Exploder</strong> with your PuTTY SOCKS proxy, they will auto-magically <strong>work</strong>!!! <em>This is because they use IE to connect to the internet!!!</em></p>
<p><span style="text-decoration: underline;"><strong>Why should I care about Flash?</strong></span></p>
<p>Um&#8230; any sort of videos, and type of Flash uploader (uploading images and media in WordPress) will not work.</p>
<h3 class="hrule"><span style="color: #3366ff;">This tutorial was for Windows; what about MAC and Linux?</span></h3>
<p><span style="color: #ff0000;"><strong>If you understand the concepts and terminology laid here before you, this can easily be done in any other environment</strong></span> (maybe not with PuTTY, but there are many other SSH clients out there that support port tunnelling/forwarding)</p>
<p>Moreover, they do make a <a href="http://the.earth.li/~sgtatham/putty/latest/putty-0.60.tar.gz"><strong>unix source distribution of PuTTY that you can download</strong></a> and build&#8230;</p>
<h3>Comments, Ratings, Etc</h3>
<p>Please ping me if you think that this is wrong. <strong>Rate the article so I know how I&#8217;m doing!!!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.engfers.com/2008/08/21/how-to-use-http_radio_anything-behind-a-proxy-or-firewall/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
