<?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>Geek Style &#187; Babak Farrokhi</title>
	<atom:link href="http://farrokhi.net/blog/index.php/archives/author/farrokhi/feed" rel="self" type="application/rss+xml" />
	<link>http://farrokhi.net/blog</link>
	<description>UNIX, InfoSec, Networking</description>
	<lastBuildDate>Mon, 18 Jul 2011 09:47:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>FreeBSD dotfiles</title>
		<link>http://farrokhi.net/blog/index.php/archives/580</link>
		<comments>http://farrokhi.net/blog/index.php/archives/580#comments</comments>
		<pubDate>Mon, 18 Jul 2011 09:28:34 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=580</guid>
		<description><![CDATA[<p>Unix system administrators develop their own customizations and configuration file templates over time. These customizations could be either personal customizations or system-wide customizations. Personal customizations live under each users home directory and the files name usually starts with a dot (which is why these files are usually called dot-files). And the system-wide customizations can be [...]]]></description>
			<content:encoded><![CDATA[<p>Unix system administrators develop their own customizations and configuration file templates over time. These customizations could be either personal customizations or system-wide customizations. Personal customizations live under each users home directory and the files name usually starts with a dot (which is why these files are usually called dot-files). And the system-wide customizations can be usually found under /etc hierarchy.</p>
<p>I also developed my own set of configuration templates that I use on almost every system I log into. They are usually kept on my private subversion server so I can update them from time to time and keep track of the changes as well.</p>
<p>So I am uploading a selection of my configuration files on my website so everyone can <a href="http://farrokhi.net/dotfiles/">grab</a> a copy and make his own modifications and use them. I use these files on FreeBSD and Mac OS X, but most of the parts can be used on Linux, Solaris, etc as well. I would also be glad to have your suggestions and feedback.</p>
<p><a href="http://farrokhi.net/dotfiles/">http://farrokhi.net/dotfiles/</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/580/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on Cyber Weapons</title>
		<link>http://farrokhi.net/blog/index.php/archives/574</link>
		<comments>http://farrokhi.net/blog/index.php/archives/574#comments</comments>
		<pubDate>Sun, 17 Jul 2011 11:30:12 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[InfoSec]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Cyberwar]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=574</guid>
		<description><![CDATA[<p>I was following the story of stuxnet from the very early days when it was just discovered and recently came across Wired&#8217;s very thorough <a title="How Digital Detectives Deciphered Stuxnet, the Most Menacing Malware in History " href="http://www.wired.com/threatlevel/2011/07/how-digital-detectives-deciphered-stuxnet/all/1">story</a> on stuxnet. Now everyone knows it was not yet another ordinary computer worm. While it might not [...]]]></description>
			<content:encoded><![CDATA[<p>I was following the story of stuxnet from the very early days when it was just discovered and recently came across Wired&#8217;s very thorough <a title="How Digital Detectives Deciphered Stuxnet, the Most Menacing Malware in History " href="http://www.wired.com/threatlevel/2011/07/how-digital-detectives-deciphered-stuxnet/all/1">story</a> on stuxnet. Now everyone knows it was not yet another ordinary computer worm. While it might not be the first of it kind, but it actually is the most sophisticated cyber weapon to date.</p>
<p>Obviously we would see more and more of such cyber weapons in future and governments will invest in creating such weapons as they invest in making other type of weaponry. But there are some major differences between a cyber weapon and legacy weaponry and major risks involved in using them.</p>
<p>A cyber weapon is sent to the target and should hide itself for unspecified amount of time until it makes sure it reached the target so it activates (or in some cases, can be triggered remotely or on a specific date), and the weapon payload does whatever it is supposed to do (steal information, destroy information and systems, etc). Cyber Weapons usually act slower due to their nature. They need to hide themselves, and replicate until they reach the ultimate target and they would traverse thousands of systems in their path before they reach their targets. And what if the weapon gets into the wrong hands (e.g. discovered buy the security researchers or by the target itself) before being able to deliver the payload or triggered?</p>
<p>Governments invest a huge amount of money into creating cyber weapons, like any other form of weaponry . So its like a modern fighter plane to crash behind the enemy lines or a spy to be captured. Then it would turn into a source of information for the target and they will figure out the technologies their enemies are using against them, so they can use the same techniques, or find a way to counter them.</p>
<p>In such cases there is something like a self-destructive system in weapons or special instructions that spies have to follow when they are captured. But how would such a system be available in cyber weapons? How a cyber weapon can identify if it is discovered? Or how can it self-destruct (which might be impossible due to the distributed nature of such threats)?</p>
<p>So there is a high risk of being discovered before being able to payload. And once discovered they can be rendered ineffective.</p>
<p>The risk of using cyber weapons seems to be higher than other types of weaponry when it comes to exposure of techniques and methods used in creating the weapon and consequently increases the risk of early detection of the threat and defending against it.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/574/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From Linux to FreeBSD &#8211; Part 1</title>
		<link>http://farrokhi.net/blog/index.php/archives/568</link>
		<comments>http://farrokhi.net/blog/index.php/archives/568#comments</comments>
		<pubDate>Fri, 31 Dec 2010 18:34:38 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=568</guid>
		<description><![CDATA[<p>I heard this so many times from different people that CLI in FreeBSD is much less user-friendly than CLI in Linux. But is it true?</p> <p>Unlike Linux that uses Bash shell, the default shell in FreeBSD is csh or tcsh. Linux users are used to tab completion, which is not the default behavior of C [...]]]></description>
			<content:encoded><![CDATA[<p>I heard this so many times from different people that CLI in FreeBSD is much less user-friendly than CLI in Linux. But is it true?</p>
<p>Unlike Linux that uses Bash shell, the default shell in FreeBSD is csh or tcsh. Linux users are used to tab completion, which is not the default behavior of C Shell. If you need to have tab completion, all you need to do is to add one line to your C shell configuration file (~/.cshrc) :</p>
<p><code>set autolist</code></p>
<p>And you will have your good old tab completion in C Shell.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/568/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The rise and fall of perfect security</title>
		<link>http://farrokhi.net/blog/index.php/archives/558</link>
		<comments>http://farrokhi.net/blog/index.php/archives/558#comments</comments>
		<pubDate>Sun, 19 Sep 2010 05:38:49 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[InfoSec]]></category>
		<category><![CDATA[Quotes]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=558</guid>
		<description><![CDATA[<p>When it comes to the online existence, our attitudes seem drastically different, though: we only joke about the idea of using the evil bit &#8211; and yet, we are perfectly comfortable that the locks on our doors can be opened with a safety pin. We scorn web developers who can&#8217;t seem to be able to [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>When it comes to the online existence, our attitudes seem drastically different, though: we only joke about the idea of using the evil bit &#8211; and yet, we are perfectly comfortable that the locks on our doors can be opened with a safety pin. We scorn web developers who can&#8217;t seem to be able to get input validation right &#8211; even though we certainly don&#8217;t test our morning coffee for laxatives or LSD. We are being irrational &#8211; but why?</p></blockquote>
<p>- <a href="http://lcamtuf.blogspot.com/2010/09/rise-and-fall-of-perfect-security.html">lcamtuf: The rise and fall of perfect security</a></p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/558/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixed: OS X 10.5.7 and Bluetooth</title>
		<link>http://farrokhi.net/blog/index.php/archives/545</link>
		<comments>http://farrokhi.net/blog/index.php/archives/545#comments</comments>
		<pubDate>Sat, 30 May 2009 10:35:26 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=545</guid>
		<description><![CDATA[<p>If you are running Mac OS X and upgraded to the recent 10.5.7 and you are using a bluetooth mouse or keyboard, then you are most likely suffering from the same problem that I do: Bluetooth device loses connection to your mac after a few hours of working. and its a real PITA.</p> <p>I have [...]]]></description>
			<content:encoded><![CDATA[<p>If you are running Mac OS X and upgraded to the recent 10.5.7 and you are using a bluetooth mouse or keyboard, then you are most likely suffering from the same problem that I do: Bluetooth device loses connection to your mac after a few hours of working. and its a real PITA.</p>
<p>I have been struggling with this since I upgraded to 10.5.7 and haven&#8217;t found a working solution, until I recently tried this and it worked like a magic:</p>
<p><code>sudo killall -HUP blued</code></p>
<p>You only need to open up a Terminal.app window and run this command. This command sends a HUP (hangup) signal to bluetooth daemon, that actually is a soft-reset command. It causes <a href="http://en.wikipedia.org/wiki/Blued">blued</a> to reload the configuration and brings your bluetooth device back to life.</p>
<p>Update 1: The latest bluetooth firmware update from Apple didn&#8217;t solve the problem. It still happens (less frequently tough) and needs to kick blued to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/545/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Multi-threaded gzip</title>
		<link>http://farrokhi.net/blog/index.php/archives/535</link>
		<comments>http://farrokhi.net/blog/index.php/archives/535#comments</comments>
		<pubDate>Tue, 14 Apr 2009 08:22:45 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=535</guid>
		<description><![CDATA[<p>The traditional (yet very popular) <a href="http://www.gzip.org/">gzip</a> is a single-threaded application from the single-processor/single-core hardware era. Its just fine if you are compressing a few files occasionally, but it become a great pain when you are compressing 32,000 files on an 8-processor server and you suddenly figure out that you are using only 1/8 of [...]]]></description>
			<content:encoded><![CDATA[<p>The traditional (yet very popular) <a href="http://www.gzip.org/">gzip</a> is a single-threaded application from the single-processor/single-core hardware era. Its just fine if you are compressing a few files occasionally, but it become a great pain when you are compressing 32,000 files on an 8-processor server and you suddenly figure out that you are using only 1/8 of your total processor power. Which means you should wait 8 times longer than if you could use all processing power on your machine. I encountered such case in which I should wait about 40 minutes to compress hundreds of gigabytes of a few thousand files, using traditional gzip, while I had one processor doing the whole job and 7 other processors were sitting idle.</p>
<p>So I thought there should be a way to speed-up the process. The most simple method I could use was to open up multiple terminal windows and run parallel copies of gzip, each of them to compress a specific set of files. While this method worked for me, but I was wondering why the gzip itself doesn&#8217;t support multi-threading.</p>
<h4>The solution: pigz</h4>
<p>I came across <a href="http://www.zlib.net/pigz/">pigz</a> after searching the internet for a multi-threaded gzip replacement. pigz is a drop-in replacement for gzip that supports parallel compression/decompression when multiple files are involved.</p>
<p style="text-align: center; "><img class="aligncenter size-full wp-image-536" title="pigz-running" src="http://farrokhi.net/blog/wp-content/uploads/2009/04/pigz-running.png" alt="pigz-running" width="623" height="334" /><em>Figure 1: Running &#8220;<code>systat -iostat 1</code>&#8221; on a FreeBSD 7.2 machine running pigz</em></p>
<p style="text-align: center; ">
<p style="text-align: left;">Using pigz, I could exploit more than 70% of my processing power. pigz also maintains compatibility with standard gzip command line parameter and supports all switches while adding &#8220;<code>-p</code>&#8221; command to specify maximum number of compression threads.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/535/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>make.conf in FreeBSD</title>
		<link>http://farrokhi.net/blog/index.php/archives/522</link>
		<comments>http://farrokhi.net/blog/index.php/archives/522#comments</comments>
		<pubDate>Thu, 05 Feb 2009 19:20:53 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=522</guid>
		<description><![CDATA[<p>I am type of person who likes to build everything from source code in FreeBSD to get better performance and other customizations. It has become a habit to play with ports tree and system source code and now I believe I have my own template for various server platforms.</p> <p>One of the most important parts [...]]]></description>
			<content:encoded><![CDATA[<p>I am type of person who likes to build everything from source code in FreeBSD to get better performance and other customizations. It has become a habit to play with ports tree and system source code and now I believe I have my own template for various server platforms.</p>
<p>One of the most important parts of each configuration template is the <code>/etc/make.conf</code> file. This is were you can change general behavior of the build system. This file is where you actually say which compiler optimizations should be used or what options has to be considered as defaults. Good news is that ports collection as well as the operating system itself honor these configuration.</p>
<p>Here is how a typical make.conf on one of my boxes look like:<br />
<code>CPUTYPE?=nocona</p>
<p>CFLAGS=         -O2 -pipe -fno-strict-aliasing<br />
COPTFLAGS=      -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing</p>
<p>KERNCONF=       SERVER GENERIC</p>
<p>OPTIMIZED_CFLAGS=       YES<br />
WITHOUT_X11=            YES<br />
BUILD_OPTIMIZED=        YES<br />
WITH_CPUFLAGS=          YES<br />
WITHOUT_DEBUG=          YES<br />
WITH_OPTIMIZED_CFLAGS=  YES<br />
NO_PROFILE=             YES<br />
BUILD_STATIC=           YES</code><br />
<br />
The <code>CPUTYPE</code> variable tells <code>gcc</code> to optimize generated binary code for specified processor. In this case I am using 64bit Xeon processor architecture and &#8220;<code>nocona</code>&#8221; is the correct <code>CPUTYPE</code> to use. You may want to use &#8220;<code>pentium4</code>&#8221; on a typical Intel P4 CPU. A list of possible <code>CPUTYPE</code> values can be found in the sample <code>make.conf</code> file located at <code>/usr/share/examples/etc/make.conf</code>.</p>
<p><span id="more-522"></span>The <code>CFLAGS</code> variable indicates what parameters should be passed to gcc compiler when compiling typical programs such as ports or when building the whole operating system (i.e. <a href="http://www.freebsd.org/doc/en/books/handbook/makeworld.html">buildworld</a> process). I have been using this for a few years now and I haven&#8217;t experienced any issues in generated binaries.</p>
<p>The <code>COPTFLAGS</code> variables only applies to kernel builds. So if you need special compiler optimization for kernel, this is the variable you should consider using.</p>
<p>The <code>KERNCONF</code> tells system to compile one or more kernels based on the existing configuration files. In this example I have two kernels, first is GENERIC which is the default kernel file and exists in all systems by default and the other is the customized kernel configuration file called SERVER that I use on my typical servers. Both kernels will be built when running &#8220;<a href="http://www.freebsd.org/doc/en/books/handbook/kernelconfig-building.html"><code>make kernel</code></a>&#8220;. The first will be installed and used as the default kernel.</p>
<p>Everything else here is some defaults to be used mostly for ports. They can be found by looking into ports Makefile or the default make.conf file at <code>/usr/share/examples/etc/make.conf</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/522/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Mac Experience (updated for 2008)</title>
		<link>http://farrokhi.net/blog/index.php/archives/519</link>
		<comments>http://farrokhi.net/blog/index.php/archives/519#comments</comments>
		<pubDate>Sun, 28 Sep 2008 09:58:36 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=519</guid>
		<description><![CDATA[<p>I suddenly came across <a href="http://farrokhi.net/blog/index.php/archives/295">this old post</a> from 2004 in which I explained my early experiments in OS X. Now after being a hardcore OS X user for more than a year, I found how much the world has changed since. The Firefox is a really usable browser now and IM clients are up [...]]]></description>
			<content:encoded><![CDATA[<p>I suddenly came across <a href="http://farrokhi.net/blog/index.php/archives/295">this old post</a> from 2004 in which I explained my early experiments in OS X. Now after being a hardcore OS X user for more than a year, I found how much the world has changed since. The Firefox is a really usable browser now and IM clients are up to date. I still hate iChat for no good reason. Maybe because I hate IM on the whole.<br />
And guess what. My favorite OS X app is Terminal.<br />
In fact OS X offers an intuitive interface that is very usable and hassle-free. I would call it a real productivity booster. Beside the interface, the OS itself is based on a <a href="http://www.apple.com/macosx/technology/unix.html">mature BSD skeleton</a>, and as a Unix fanatic and really enjoy poking around OS X.</p>
<p>I seriously urge you to switch to Mac if you care about your productivity and performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/519/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Syncing clock in FreeBSD</title>
		<link>http://farrokhi.net/blog/index.php/archives/506</link>
		<comments>http://farrokhi.net/blog/index.php/archives/506#comments</comments>
		<pubDate>Sat, 27 Sep 2008 19:51:27 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=506</guid>
		<description><![CDATA[<p>Keeping accurate time on a host (either a server or a workstation) is important because:</p> <p>1- You need to know accurately when you should go for lunch or back home<br /> 2- You need accurate time in your event log files for further analysis<br /> 3- Many programs need to have the correct date and [...]]]></description>
			<content:encoded><![CDATA[<p>Keeping accurate time on a host (either a server or a workstation) is important because:</p>
<p>1- You need to know accurately when you should go for lunch or back home<br />
2- You need accurate time in your event log files for further analysis<br />
3- Many programs need to have the correct date and time to function (e.g. MTA)<br />
4- You need correct timestamps on your files</p>
<p>Given above facts, you will need to enable <a href="http://en.wikipedia.org/wiki/Network_Time_Protocol">NTP</a> on your hosts and keep your system clock in sync with public time servers.</p>
<p>First you should make sure that your timezone setting is correct. The latest timezone information can be updated by installing &#8220;<code>zoneinfo</code>&#8221; port from <code>/usr/ports/misc/zoneinfo</code>:</p>
<p><code><br />
# cd /usr/ports/misc/zoneinfo/<br />
# make install clean<br />
</code></p>
<p>and run <code>tzsetup(8)</code> to make sure you have selected the correct timezone.</p>
<p>Now, to enable automatic time sync during system startup, you need to add a few lines to your <code>/etc/rc.conf</code> file:<br />
<code><br />
ntpdate_enable="YES"<br />
ntpdate_flags="-b pool.ntp.org"<br />
</code></p>
<p>This will make your system to sync the clock upon startup. I use NTP pool at &#8220;<code>pool.ntp.org</code>&#8221; that suggests a NTP server from a large pool of available time servers. However you may use your favorite/local NTP server.</p>
<p>You can also synchronize your time manually by invoking <code>ntpdate(8)</code> from command line, passing an NTP server address to it:<br />
<code><br />
# ntpdate time.nist.gov<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/506/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weblog changes</title>
		<link>http://farrokhi.net/blog/index.php/archives/501</link>
		<comments>http://farrokhi.net/blog/index.php/archives/501#comments</comments>
		<pubDate>Tue, 23 Sep 2008 08:51:49 +0000</pubDate>
		<dc:creator>Babak Farrokhi</dc:creator>
				<category><![CDATA[Just Blogging]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://farrokhi.net/blog/?p=501</guid>
		<description><![CDATA[<p>I managed to migrate my blog to WordPress after more than 5 years. I had a bad feeling about the old MT and perhaps that was the reason I was not posting too often.</p> <p>I redirected the old feed URLs to the new one, but I suggest you update your links and let me know [...]]]></description>
			<content:encoded><![CDATA[<p>I managed to migrate my blog to WordPress after more than 5 years. I had a bad feeling about the old MT and perhaps that was the reason I was not posting too often.</p>
<p>I redirected the old feed URLs to the new one, but I suggest you update your links and let me know if you are having difficulties accessing content on this website.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrokhi.net/blog/index.php/archives/501/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

