<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Sex, Drugs &#38; Unix</title>
	<atom:link href="http://urandom.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://urandom.wordpress.com</link>
	<description>jsut ahnetor mroon witnrig auobt non staubisatnl sfutf</description>
	<lastBuildDate>Sun, 02 Nov 2008 17:11:41 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='urandom.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/585c319061d2745c8464110b49e6fcbe?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Sex, Drugs &#38; Unix</title>
		<link>http://urandom.wordpress.com</link>
	</image>
			<item>
		<title>SOCKS Proxy</title>
		<link>http://urandom.wordpress.com/2008/11/02/socks-proxy/</link>
		<comments>http://urandom.wordpress.com/2008/11/02/socks-proxy/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 14:44:21 +0000</pubDate>
		<dc:creator>x86hemi</dc:creator>
				<category><![CDATA[network]]></category>
		<category><![CDATA[posix]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tsocks]]></category>

		<guid isPermaLink="false">http://urandom.wordpress.com/?p=40</guid>
		<description><![CDATA[One thing which I tend to fight against on a daily basis is my company firewall. This specific firewall wants to inspect every single file over 10MiB which often break TCP connections. Since i run gentoo/arch/whatever on my research machines this quickly turns into alot of pain.
The easiest way I&#8217;ve found to solve this is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=urandom.wordpress.com&blog=5295913&post=40&subd=urandom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One thing which I tend to fight against on a daily basis is my company firewall. This specific firewall wants to inspect every single file over 10MiB which often break TCP connections. Since i run gentoo/arch/whatever on my research machines this quickly turns into alot of pain.</p>
<p>The easiest way I&#8217;ve found to solve this is through the use of &#8216;openssh&#8217; and a little script &#8216;tsocks&#8217;.</p>
<p>OpenSSH comes with a SOCKS proxy implementation which you can start as a normal user using the &#8216;-D&#8217; parameter.</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
    usr@lcl:~&gt; ssh -TxnND 12345 -C usr@rmt
</pre>
<p>This opens a quiet session to remote host &#8216;rmt&#8217; and initiates a local proxy on port 12345. This session is a non interactive session and can be further extended with &#8216;nohup&#8217; to keep the proxy running even after the shell terminates. This will look like:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
    usr@lcl:~&gt; nohup ssh -TxnND 12345 -C usr@rmt
</pre>
<p>You could even extend this with generated keys and put the command directly in the background but this is insecure.</p>
<p>&#8216;tsocks&#8217; on the other hand is a program wich intercepts socket system calls with the use of LD_PRELOAD and routes the traffic through a proxy. LD_PRELOAD is an honored environment variable in any POSIX complaint system. A sample config for tsocks looks like the following:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
server = 127.0.0.1
server_type = 5
server_port = 12345
</pre>
<p>It is important to note that all of this is done on the client machine &#8216;lcl&#8217; and that the only thing you need is an external ssh account. This config tells tsocks to connect through a SOCKS 5 proxy running at localhost 12345.</p>
<p>Anyhow, it is now possible to connect through the proxy via:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
    usr@lcl:~&gt; tsocks emerge --sync
</pre>
<p>Or any socket reliant command line program, the only limitation being that you need to stay in the same process space. </p>
<p>As a last tip I also use this in conjunction with a firefox plugin called &#8216;foxyproxy&#8217;. If you don&#8217;t run firefox then the same feature can be set up with a little shell scripting and a pac file.</p>
<p>Happy SOCKSing!</p>
Posted in network Tagged: posix, proxy, ssh, tsocks <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/urandom.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/urandom.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/urandom.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/urandom.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/urandom.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/urandom.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/urandom.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/urandom.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/urandom.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/urandom.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=urandom.wordpress.com&blog=5295913&post=40&subd=urandom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://urandom.wordpress.com/2008/11/02/socks-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0147ba17ee85f80f80bc87fea822fcca?s=96&#38;d=identicon" medium="image">
			<media:title type="html">x86hemi</media:title>
		</media:content>
	</item>
		<item>
		<title>AWK Essentials</title>
		<link>http://urandom.wordpress.com/2008/10/27/awk-essentials/</link>
		<comments>http://urandom.wordpress.com/2008/10/27/awk-essentials/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 20:33:22 +0000</pubDate>
		<dc:creator>x86hemi</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[interpreted]]></category>
		<category><![CDATA[parsing]]></category>

		<guid isPermaLink="false">http://urandom.wordpress.com/?p=7</guid>
		<description><![CDATA[AWK is a really nice programming language which is installed by default on standard *nixes. Many people do not really use AWK in the way it was meant since we have in many ways moved away from doing accounting stuff in plain text files. It does however provide you with a untyped language with a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=urandom.wordpress.com&blog=5295913&post=7&subd=urandom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>AWK is a really nice programming language which is installed by default on standard *nixes. Many people do not really use AWK in the way it was meant since we have in many ways moved away from doing accounting stuff in plain text files. It does however provide you with a untyped language with a very low memory footprint! I will keep this as simplified as possible but assume you are running a *nix with an AWK which supports variables.</p>
<p>The base of AWK is:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
    PATTERN ACTION
</pre>
<p>Or a bit more descriptive, a pattern is run for each line in the input and if the pattern is noticed execute its action.</p>
<p>PATTERN is any regexp and ACTION is a block of code. Patterns are executed from top to bottom. AWK is untyped which means that you can only use native types but you don&#8217;t need to specify exactly what a variable is. To make it concrete lets make a program which prints your user name. Fire up a terminal and run:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
    user@lcl:~&gt; awk 'BEGIN {print ENVIRON["USER"]}'
</pre>
</p>
<p>
So what is going on? Firstly we specify an inline awk script and run it directly with awk. In our script we utilize BEGIN which is the first out of two builtin patterns, the other one being END. Both BEGIN and END is run exactly once when the interpreter BEGINs and ENDs parsing. We didn&#8217;t specify any file to run awk with which means it initialized the parser, ran BEGIN which had code and then terminated, but only after checking if there was an END clause. print is a standard function in awk just like (not exhaustive), system, split, length and substr. &#8216;print&#8217; just prints text to stdout.
</p>
<p>In AWK you can make heavy use of associative arrays, in this case ENVIRON is an array containing all of the current environment variables. This array is filled by your AWK runtime and is not really a part of the language. You may of course specify own arrays at will in any pattern action. Lets look at another example!</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
#!/usr/bin/awk -f

BEGIN {
  main(ENVIRON["PATH"])
}

function main(string)
{
  split(string,paths,":")
  for(i in paths)
  {
    print paths[i]
  }
  return
}
</pre>
</p>
<p>This is an AWK script which need to be executed, suppose its name is myPaths then it will be executed as &#8216;./myPaths&#8217;. In it we specify a main function taking a string argument which splits the string on &#8216;:&#8217; and prints each of the tokens. &#8217;split&#8217; takes a string input, a target array and a list of separators which tokenizes the input.
</p>
<p>Things to notice is the &#8220;for-each&#8221; like syntax in the loop, the array &#8216;paths&#8217; which is not declared before we use it and that the pattern block cannot be written like the function block. One thing which is not stated is that the arrays index starts at 1 and not the normal 0.</p>
<p>Finally lets look at a one-liner which prints the last found active interface! This assumes the use of a program &#8216;ifconfig&#8217; giving the following output:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
eth0      Link encap:Ethernet  HWaddr 00:1E:8C:E5:E5:C2
          inet addr:xxx.xxx.x.xx  Bcast:xxx.xxx.x.xxx  Mask:255.255.255.0
          inet6 addr: xxxx::xxx:xxxx:xxxx:xxxx/xx Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:579259192 errors:0 dropped:0 overruns:0 frame:0
          TX packets:338999063 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:300177137147 (286271.2 Mb)  TX bytes:905103595491 (863174.0 Mb)
          Interrupt:18 

eth1      Link encap:Ethernet  HWaddr 00:E0:4D:4A:A2:D2
          inet addr:xx.xx.xxx.xxx  Bcast:xx.xx.xxx.xxx  Mask:255.255.255.0
          inet6 addr: xxxx::xxx:xxxx:xxxx:xxxx/xx Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:886942313 errors:1 dropped:6 overruns:1 frame:0
          TX packets:1060224372 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:599343450907 (571578.4 Mb)  TX bytes:936322147776 (892946.3 Mb)
          Interrupt:21 Base address:0xac00 

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:74323801 errors:0 dropped:0 overruns:0 frame:0
          TX packets:74323801 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16951245193 (16165.9 Mb)  TX bytes:16951245193 (16165.9 Mb)
</pre>
<p>the script, which is not kosher, is used in the following manner:</p>
<pre style="border:1px dashed #bbb;font-size:75%;color:#C4C4C4;background:#3B3B3B;overflow:auto;padding:5px;">
    user@lcl:~&gt; ifconfig | awk \
                    '/encap:Ethernet/{iface = $1} \
                     /UP.*RUNNING.*MULTICAST/{activeIface=iface} \
                     END{print activeIface}'
</pre>
<p>the AWK script has two patterns, which are as mentioned executed in order. The first registers the first field in any line containing a &#8216;encap:Ethernet&#8217;. We can see that for these lines the first field to be the iface name. The second line catches any line which states that the interface is up and if it is stashes the iface in activeIface for later printing in END.</p>
<p>Happy AWKing!</p>
Posted in programming Tagged: awk, interpreted, parsing <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/urandom.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/urandom.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/urandom.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/urandom.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/urandom.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/urandom.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/urandom.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/urandom.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/urandom.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/urandom.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=urandom.wordpress.com&blog=5295913&post=7&subd=urandom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://urandom.wordpress.com/2008/10/27/awk-essentials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0147ba17ee85f80f80bc87fea822fcca?s=96&#38;d=identicon" medium="image">
			<media:title type="html">x86hemi</media:title>
		</media:content>
	</item>
		<item>
		<title>I am not a Jedi</title>
		<link>http://urandom.wordpress.com/2008/10/25/i-am-not-a-jedi/</link>
		<comments>http://urandom.wordpress.com/2008/10/25/i-am-not-a-jedi/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 23:36:35 +0000</pubDate>
		<dc:creator>x86hemi</dc:creator>
				<category><![CDATA[urandom]]></category>
		<category><![CDATA[first post]]></category>

		<guid isPermaLink="false">http://urandom.wordpress.com/?p=3</guid>
		<description><![CDATA[There is a famous Yoda quote from Star Wars which I, since I was a little boy, have always found disturbing:
&#8220;Try not. Do, or do not. There is no try&#8221; &#8211; Yoda
The quote is of course meant as a motivator but at least for me always seemed strange since most of the time I try [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=urandom.wordpress.com&blog=5295913&post=3&subd=urandom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There is a famous Yoda quote from Star Wars which I, since I was a little boy, have always found disturbing:</p>
<blockquote><p>&#8220;Try not. Do, or do not. There is no try&#8221; &#8211; Yoda</p></blockquote>
<p>The quote is of course meant as a motivator but at least for me always seemed strange since most of the time I try to do stuff without ever really failing or succeeding. The premise that each problem is attempted only when a goal has been clearly established and the idea that success is dependant solely upon will and choice and never chance is of course moronic.</p>
Posted in urandom Tagged: first post <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/urandom.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/urandom.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/urandom.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/urandom.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/urandom.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/urandom.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/urandom.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/urandom.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/urandom.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/urandom.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=urandom.wordpress.com&blog=5295913&post=3&subd=urandom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://urandom.wordpress.com/2008/10/25/i-am-not-a-jedi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0147ba17ee85f80f80bc87fea822fcca?s=96&#38;d=identicon" medium="image">
			<media:title type="html">x86hemi</media:title>
		</media:content>
	</item>
	</channel>
</rss>