<?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>Inspirated</title>
	<atom:link href="https://inspirated.com/feed" rel="self" type="application/rss+xml" />
	<link>https://inspirated.com</link>
	<description>An archived (and possibly radioactive) blog</description>
	<lastBuildDate>Sun, 03 Jul 2022 21:04:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>The best of us</title>
		<link>https://inspirated.com/2022/07/03/the-best-of-us</link>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Sun, 03 Jul 2022 21:04:34 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://inspirated.com/?p=643</guid>

					<description><![CDATA[<p>Maybe someday I will find words to capture the impact you had on your friends&#8217; lives, the wisdom that you shared so graciously, and the warmth you brought into a cynical world. For now, all I can think of is how you deserved so much more. It was one of the great privileges of my [&#8230;]</p>
The post <a href="https://inspirated.com/2022/07/03/the-best-of-us">The best of us</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>Maybe someday I will find words to capture the impact you had on your friends&#8217; lives, the wisdom that you shared so graciously, and the warmth you brought into a cynical world.<br />
For now, all I can think of is how you <em>deserved so much more</em>.<br />
It was one of the great privileges of my life to be able to call you a friend.<br />
Life will never be the same without you.<br />
I love you brother.</p>
<p style="text-align: center"><img decoding="async" src="https://inspirated.com/uploads/gola-jee.jpg"></p>The post <a href="https://inspirated.com/2022/07/03/the-best-of-us">The best of us</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>So Long, and Thanks for All the Fish</title>
		<link>https://inspirated.com/2018/08/05/so-long-and-thanks-for-all-the-fish</link>
					<comments>https://inspirated.com/2018/08/05/so-long-and-thanks-for-all-the-fish#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Sun, 05 Aug 2018 17:00:31 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://inspirated.com/?p=576</guid>

					<description><![CDATA[<p>This blog is old. Really, really old. All of the posts were written ages ago (with some being more than a decade past their expiry dates) when I was quite young and utterly full of myself. A significant portion of what I wrote here over the years is naïve, brash; or worse, just wrong. In [&#8230;]</p>
The post <a href="https://inspirated.com/2018/08/05/so-long-and-thanks-for-all-the-fish">So Long, and Thanks for All the Fish</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>This blog is old. Really, really old. All of the posts were written ages ago (with some being more than a decade past their expiry dates) when I was quite young and utterly full of myself. A significant portion of what I wrote here over the years is naïve, brash; or worse, just wrong.</p>
<p>In the age of the Internet, there&#8217;s no point in deleting embarrassing content from past. For better or worse it will live on forever. Therefore, instead of deleting all the posts I&#8217;m just gonna keep them around for purely nostalgic reasons along with this disclaimer.</p>
<p>I do not blog anymore. I still write occasionally on <a href="https://www.quora.com/profile/Kamran-Khan-92/answers">Quora</a> but I gradually have much lesser stuff to say and much fewer things to feel strongly about.</p>
<p>To those who I have offended in the past with my crass words or behavior, I apologize.</p>
<div style="text-align: center"><iframe title="The Doors   The End" width="500" height="281" src="https://www.youtube.com/embed/ZeMlQEWEg2Q?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<p><em>Expirated</em></p>
</div>The post <a href="https://inspirated.com/2018/08/05/so-long-and-thanks-for-all-the-fish">So Long, and Thanks for All the Fish</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2018/08/05/so-long-and-thanks-for-all-the-fish/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>bucket_list.pop(&#8220;marathon&#8221;)</title>
		<link>https://inspirated.com/2016/11/30/bucket_list-popmarathon</link>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Wed, 30 Nov 2016 00:16:48 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Marathon]]></category>
		<category><![CDATA[Personal]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=510</guid>

					<description><![CDATA[<p>Somehow, my busted knee, still-recovering-from-a-tear quad muscle and I all managed to crawl across the line at 26.2 miles. &#8220;The marathon can humble you&#8221;. — Bill Rodgers</p>
The post <a href="https://inspirated.com/2016/11/30/bucket_list-popmarathon">bucket_list.pop(“marathon”)</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p style="text-align: center;"><a href="https://inspirated.com/uploads/2016-marathon-finish.png"><img decoding="async" src="https://inspirated.com/uploads/2016-marathon-finish-thumb.png" alt="2016 Seattle Marathon Finish"></a></p>
<p>Somehow, my busted knee, still-recovering-from-a-tear quad muscle and I all managed to crawl across the line at 26.2 miles.</p>
<blockquote><p>&#8220;The marathon can humble you&#8221;. — Bill Rodgers</p></blockquote>The post <a href="https://inspirated.com/2016/11/30/bucket_list-popmarathon">bucket_list.pop(“marathon”)</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Release: Bro 2.3.1-2 on OpenWRT</title>
		<link>https://inspirated.com/2015/06/08/release-bro-2-3-1-2-on-openwrt</link>
					<comments>https://inspirated.com/2015/06/08/release-bro-2-3-1-2-on-openwrt#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Sun, 07 Jun 2015 19:08:45 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bro IDS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Flag 42]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shrimp]]></category>
		<category><![CDATA[SysNet]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=461</guid>

					<description><![CDATA[<p>As I promised in the comments section of previous post, I set out on the adventure of recompiling Bro for Lantiq routers. As a result of the exercise I have new-found respect for open-source package maintainers. Holy waffles if troubleshooting build errors in a large Autotools mess isn&#8217;t the most hemorrhage-inducing activity known to mankind. [&#8230;]</p>
The post <a href="https://inspirated.com/2015/06/08/release-bro-2-3-1-2-on-openwrt">Release: Bro 2.3.1-2 on OpenWRT</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>As I promised in the comments section of <a href="https://inspirated.com/2015/04/29/bro-2-3-on-openwrt">previous post</a>, I set out on the adventure of recompiling Bro for Lantiq routers. As a result of the exercise I have new-found respect for open-source package maintainers. Holy waffles if troubleshooting build errors in a large Autotools mess isn&#8217;t the most hemorrhage-inducing activity known to mankind.</p>
<p>Anyways, this time I&#8217;ve tried to keep track of the changes I&#8217;ve been making along the way. The full set of updated Makefiles and patches is maintained in the <a href="https://github.com/krkhan/openwrt-bro">openwrt-bro</a> repo. Also, the compiled ipk packages for Atheros and Lantiq routers are available on the <a href="https://github.com/krkhan/openwrt-bro/releases/tag/v2.3.1-2">release page</a>.</p>
<p>Now that I have a reasonably updated Buildroot on my system and an organized set of patches, feel free to request an ipk package for your router. While I can&#8217;t guarantee that the clusterfuck of patches will compile smoothly for your platform, I&#8217;ll still give it a try.</p>The post <a href="https://inspirated.com/2015/06/08/release-bro-2-3-1-2-on-openwrt">Release: Bro 2.3.1-2 on OpenWRT</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2015/06/08/release-bro-2-3-1-2-on-openwrt/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Bro 2.3 on OpenWRT</title>
		<link>https://inspirated.com/2015/04/29/bro-2-3-on-openwrt</link>
					<comments>https://inspirated.com/2015/04/29/bro-2-3-on-openwrt#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Wed, 29 Apr 2015 18:32:49 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bro IDS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shrimp]]></category>
		<category><![CDATA[SysNet]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=457</guid>

					<description><![CDATA[<p>After posting the Bro port for OpenWRT on my blog roughly two years ago, I didn&#8217;t realize some people were already actually using it on their routers. I had created an updated version of the port which I hadn&#8217;t posted on the blog. Digging in my archived files I finally found it today along with [&#8230;]</p>
The post <a href="https://inspirated.com/2015/04/29/bro-2-3-on-openwrt">Bro 2.3 on OpenWRT</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>After posting the <a href="https://inspirated.com/2012/12/10/bro-ids-on-openwrt">Bro port for OpenWRT</a> on my blog roughly two years ago, I didn&#8217;t realize some people were already actually using it on their routers.</p>
<p>I had created an updated version of the port which I hadn&#8217;t posted on the blog. Digging in my archived files I finally found it today along with its sources:</p>
<ul>
<li><a href="https://inspirated.com/uploads/openwrt-bro-2.3.1.tar.gz">openwrt-bro-2.3.1.tar.gz</a></li>
<li><a href="https://inspirated.com/uploads/bro_2.3.1-1_ar71xx.ipk">bro_2.3.1-1_ar71xx.ipk</a></li>
</ul>
<p>Word of caution though, my notes indicate that one of the default scripts was leaking memory and I never got around to figuring out which one. The workaround was to launch Bro in barebone mode with <code>-b</code> switch, which would prevent loading of default scripts.</p>
<pre lang="bash"># cat test.bro</pre>
<blockquote>
<pre>event bro_init()
{
	print "Hello World!";
}

event new_connection(c: connection)
{
	print "New connection created";
}
</pre>
</blockquote>
<pre lang="bash"># bro test.bro</pre>
<blockquote>
<pre>Hello World!</pre>
</blockquote>
<pre lang="bash"># bro -C -b -i br-lan test.bro</pre>
<blockquote>
<pre>Hello World!
New connection created
New connection created</pre>
</blockquote>
<p>If someone has cycles to spend and figure out which default script is leaking memory we can update the package to address the bug.</p>The post <a href="https://inspirated.com/2015/04/29/bro-2-3-on-openwrt">Bro 2.3 on OpenWRT</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2015/04/29/bro-2-3-on-openwrt/feed</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>Bro IDS on OpenWRT Part II &#8212; The Paper</title>
		<link>https://inspirated.com/2014/07/31/bro-ids-on-openwrt-part-ii-the-paper</link>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Thu, 31 Jul 2014 18:40:21 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ACM]]></category>
		<category><![CDATA[Bro IDS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Flag 42]]></category>
		<category><![CDATA[IEEE]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[Publication]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shrimp]]></category>
		<category><![CDATA[SysNet]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=425</guid>

					<description><![CDATA[<p>The paper chronicling our adventures with Bro IDS on home routers just got published in the latest issue of SIGCOMM CCR. Here&#8217;re the details: Title: Rapid and Scalable ISP Service Delivery through a Programmable MiddleBox Abstract: With only access billing no longer ensuring profits, an ISP&#8217;s growth now relies on rolling out new and differentiated [&#8230;]</p>
The post <a href="https://inspirated.com/2014/07/31/bro-ids-on-openwrt-part-ii-the-paper">Bro IDS on OpenWRT Part II — The Paper</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>The paper chronicling our adventures with Bro IDS on home routers just got published in the latest issue of SIGCOMM CCR. Here&#8217;re the details:</p>
<blockquote><p>Title: <a href="https://dl.acm.org/citation.cfm?id=2656882&#038;CFID=395719606&#038;CFTOKEN=70062475">Rapid and Scalable ISP Service Delivery through a Programmable MiddleBox</a></p>
<p>Abstract: With only access billing no longer ensuring profits, an ISP&#8217;s growth now relies on rolling out new and differentiated services. However, ISPs currently do not have a well-defined architecture for rapid, cost-effective, and scalable dissemination of new services. We present iSDF, a new SDN-enabled framework that can meet an ISP&#8217;s service delivery constraints concerning cost, scalability, deployment flexibility, and operational ease. We show that meeting these constraints necessitates an SDN philosophy for a centralized management plane, a decoupled (from data) control plane, and a programmable data plane at customer premises. We present an ISP service delivery framework (iSDF) that provides ISPs a domain-specific API for network function virtualization by leveraging a programmable middlebox built from commodity home-routers. It also includes an application server to disseminate, configure, and update ISP services. We develop and report results for three diverse ISP applications that demonstrate the practicality and flexibility of iSDF, namely distributed VPN (control plane decisions), pay-per-site (rapid deployment), and BitTorrent blocking (data plane processing).</p>
<p>Published in: ACM SIGCOMM Computer Communication Review (Volume 44 Issue 3, July 2014)</p></blockquote>
<p>Combined with the paper in IEEE COMST about <a href="https://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6616686">botnet detection</a> that was published last year, this yields a grand-total of 2 publications more than I thought would ever bear my name. In any case, my former colleagues are continuing their excellent work on the project which can be tracked at the <a href="https://sysnet.org.pk/w/ISDF">iSDF wiki-page</a>.</p>The post <a href="https://inspirated.com/2014/07/31/bro-ids-on-openwrt-part-ii-the-paper">Bro IDS on OpenWRT Part II — The Paper</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>cl-ecc: A prototype implementation of ECC in Common Lisp</title>
		<link>https://inspirated.com/2014/06/19/cl-ecc-a-prototype-implementation-of-ecc-in-common-lisp</link>
					<comments>https://inspirated.com/2014/06/19/cl-ecc-a-prototype-implementation-of-ecc-in-common-lisp#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Thu, 19 Jun 2014 18:20:41 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cl-ecc]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Common Lisp]]></category>
		<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[ECC]]></category>
		<category><![CDATA[Elliptic Curve Cryptography]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=417</guid>

					<description><![CDATA[<p>Recently I&#8217;ve been reading through these excellent books in my spare time: Understanding Cryptography by Christof Paar Practical Common Lisp by Peter Seibel (also available as a free eBook) To ramp-up on both subjects with one shot I wrote an implementation of Elliptic Curve Crypto in Lisp. So far, it does EC versions of Diffie-Hellman, [&#8230;]</p>
The post <a href="https://inspirated.com/2014/06/19/cl-ecc-a-prototype-implementation-of-ecc-in-common-lisp">cl-ecc: A prototype implementation of ECC in Common Lisp</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>Recently I&#8217;ve been reading through these excellent books in my spare time:</p>
<ul>
<li><a href="https://www.amazon.com/Understanding-Cryptography-Textbook-Students-Practitioners/dp/3642041000/ref=sr_1_1?ie=UTF8&#038;qid=1403199667&#038;sr=8-1&#038;keywords=understanding+cryptography">Understanding Cryptography</a> by Christof Paar</li>
<li><a href="https://www.amazon.com/Practical-Common-Lisp-Peter-Seibel/dp/1590592395/ref=sr_1_1?ie=UTF8&#038;qid=1403199794&#038;sr=8-1&#038;keywords=practical+common+lisp">Practical Common Lisp</a> by Peter Seibel (also available as a free <a href="https://www.gigamonkeys.com/book/">eBook</a>)</li>
</ul>
<p>To ramp-up on both subjects with one shot I wrote an implementation of Elliptic Curve Crypto in Lisp. So far, it does EC versions of Diffie-Hellman, ElGamal and DSA. Some rudimentary testing was performed using the <a href="https://csrc.nist.gov/groups/ST/toolkit/documents/dss/NISTReCur.pdf">NIST-P192 curve</a> and its corresponding <a href="https://csrc.nist.gov/groups/STM/cavp/">ECDSA test vectors</a>.</p>
<p>The package is available at GitHub in the <a href="https://github.com/krkhan/cl-ecc">krkhan/cl-ecc</a> repository. Here&#8217;s a quick snippet of what the code looks like:</p>
<pre lang="lisp">(defconstant *p17-curve*
  (make-instance
    'Curve
    :a 2
    :b 2
    :p 17
    :g (make-instance
         'Point
         :x 5
         :y 1)
    :n 19))</pre>
<p>And an ECDSA with this curve:</p>
<pre lang="lisp">(def-positive-test test-ecdsa ()
  (let* ((c *p17-curve*)
         (bob-priv 3)
         (bob-pub (ecdh-gen-pub c bob-priv))
         (msghash 8)
         (k 7)
         (sig (ecdsa-gen-sig c msghash bob-priv k)))
    (assert (sig-equalp sig (make-instance 'ECDSASig :r 0 :s 12)))
    (ecdsa-verify-sig c msghash sig bob-pub)))</pre>
<p>As a disclaimer &#8212; even though I know no one would be stupid enough to do so &#8212; <strong>please </strong> do not use this code in a production environment. It was written for recreational purposes by a hobbyist who is bad with cryptography and even worse with Lisp. On the other hand, if you have any suggestions/patches, feel free to create an issue/pull-request on GitHub.</p>The post <a href="https://inspirated.com/2014/06/19/cl-ecc-a-prototype-implementation-of-ecc-in-common-lisp">cl-ecc: A prototype implementation of ECC in Common Lisp</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2014/06/19/cl-ecc-a-prototype-implementation-of-ecc-in-common-lisp/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Blocking traffic flows selectively with a timeout from Bro IDS</title>
		<link>https://inspirated.com/2013/07/01/blocking-traffic-flows-selectively-with-a-timeout-from-bro-ids</link>
					<comments>https://inspirated.com/2013/07/01/blocking-traffic-flows-selectively-with-a-timeout-from-bro-ids#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Sun, 30 Jun 2013 21:55:22 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bro IDS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Flag 42]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SysNet]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=389</guid>

					<description><![CDATA[<p>I needed to block some flows on OpenWRT from the Bro IDS. One option was to install the recent module for expiring iptables rules which sounded like an overkill. After some tinkering around I landed on using bash and at to expire the firewall rules after timeouts (luckily the at daemon was available on OpenWRT [&#8230;]</p>
The post <a href="https://inspirated.com/2013/07/01/blocking-traffic-flows-selectively-with-a-timeout-from-bro-ids">Blocking traffic flows selectively with a timeout from Bro IDS</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>I needed to block some flows on OpenWRT from the Bro IDS. One option was to install the <code>recent</code> module for expiring <code>iptables</code> rules which sounded like an overkill. After some tinkering around I landed on using <code>bash</code> and <code>at</code> to expire the firewall rules after timeouts (luckily the at daemon was available on OpenWRT which made my job easier).</p>
<p>There are three parts to the process:</p>
<h3>The <code>bash</code> script</h3>
<p>First, a script which:</p>
<ol>
<li>Constructs and adds the <code>iptables</code> rule to the <code>FORWARD</code> chain.</li>
<li>Constructs the corresponding deletion rule.</li>
<li>Creates a temporary <code>bash</code> script, writes the rule to it, makes the new script self-deleting.</li>
<li>Schedules a launch of the temporary script with <code>at</code> command.</li>
</ol>
<p>Here&#8217;s the script:</p>
<div style="text-align: center"><a href="https://inspirated.com/uploads/blockflow.sh">blockflow.sh</a></div>
<pre lang="bash">#!/bin/sh

if [ $# -le 5 ] ; then
  echo "usage: $0 proto src sport dst dport timeout"
  exit 1
fi

proto=$1
src=$2
sport=$3
dest=$4
dport=$5
timeout=$6

echo "  proto: $1"
echo "    src: $2"
echo "  sport: $3"
echo "   dest: $4"
echo "  dport: $5"
echo "timeout: $6"

rule=""

if [ "$proto" != "any" ]; then
  rule="$rule --protocol $proto"
fi

if [ "$src" != "0.0.0.0" ]; then
  rule="$rule --source $src"
fi

if [ "$sport" != "0" ]; then
  rule="$rule --sport $sport"
fi

if [ "$dest" != "0.0.0.0" ]; then
  rule="$rule --destination $dest"
fi

if [ "$dport" != "0" ]; then
  rule="$rule --dport $dport"
fi

rule="$rule -j DROP"

echo "rule: $rule"

addcmd="iptables -I FORWARD $rule"
delcmd="iptables -D FORWARD $rule"

delscript=`mktemp`
echo "delscript: $delscript"

echo "#!/bin/sh" &gt;&gt;$delscript
echo $delcmd &gt;&gt;$delscript
echo "rm \"${delscript}\"" &gt;&gt;$delscript
chmod 755 $delscript

echo "adding iptable rule:"
echo $addcmd
`$addcmd`

atcmd="at -M -f $delscript now + $timeout min"
echo "creating at job for deletion:"
echo $atcmd
`$atcmd`
</pre>
<p>Given below is an example run. First, let&#8217;s print the default <code>FORWARD</code> chain:</p>
<pre lang="bash"># iptables -nL FORWARD</pre>
<blockquote>
<pre>Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             10.42.0.0/24         state RELATED,ESTABLISHED
ACCEPT     all  --  10.42.0.0/24         anywhere            
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
</pre>
</blockquote>
<p>Block a flow for 2 minutes:</p>
<pre lang="bash"># sh blockflow.sh tcp 50.50.50.50 50 60.60.60.60 60 2</pre>
<blockquote>
<pre>  proto: tcp
    src: 50.50.50.50
  sport: 50
   dest: 60.60.60.60
  dport: 60
timeout: 2
rule:  --protocol tcp --source 50.50.50.50 --sport 50 --destination 60.60.60.60 --dport 60 -j DROP
delscript: /tmp/tmp.SAREJvtsK0
adding iptable rule:
iptables -I FORWARD --protocol tcp --source 50.50.50.50 --sport 50 --destination 60.60.60.60 --dport 60 -j DROP
creating at job for deletion:
at -M -f /tmp/tmp.SAREJvtsK0 now + 2 min
job 79 at Sun Jun 30 14:37:00 2013</pre>
</blockquote>
<p>Let&#8217;s check if the new rule was added:</p>
<pre lang="bash"># iptables -nL FORWARD</pre>
<blockquote>
<pre>Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DROP       tcp  --  50.50.50.50          60.60.60.60          tcp spt:50 dpt:60
ACCEPT     all  --  anywhere             10.42.0.0/24         state RELATED,ESTABLISHED
ACCEPT     all  --  10.42.0.0/24         anywhere            
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
</pre>
</blockquote>
<p>After 2 minutes, the temporary bash script shall remove the rule and then delete itself. To confirm:</p>
<pre lang="bash"># iptables -nL FORWARD</pre>
<blockquote>
<pre>Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             10.42.0.0/24         state RELATED,ESTABLISHED
ACCEPT     all  --  10.42.0.0/24         anywhere            
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
</pre>
</blockquote>
<h3>The Bro module</h3>
<p>A simple module which exports just one function, i.e., <code>BlockFlow::block</code> which takes a <code>conn_id</code> and a <code>count</code> and calls the <code>bash</code> script with appropriate parameters:</p>
<div style="text-align: center"><a href="https://inspirated.com/uploads/blockflow.bro">blockflow.bro</a></div>
<pre lang="text">module BlockFlow;

export {
  global block: function(id: conn_id, t: count);
}

function block(id: conn_id, t: count)
{
  print fmt("blocking %s:%d -&gt; %s:%d for %d minutes", id$orig_h, id$orig_p, id$resp_h, id$resp_p, t);

  local protocol = get_port_transport_proto(id$resp_p);
  print fmt("protocol is: %s", protocol);

  local cmd: string = fmt("sh blockflow.sh %s %s %d %s %d %d", protocol
                                                             , id$orig_h, id$orig_p
                                                             , id$resp_h, id$resp_p, t);
  print fmt("executing: %s", cmd);
  system(cmd);
}
</pre>
<h3>Bro module usage</h3>
<p>And finally, using the module from a Bro script:</p>
<div style="text-align: center"><a href="https://inspirated.com/uploads/blockflow-test.bro">blockflow-test.bro</a></div>
<pre lang="text">@load ./blockflow

event bro_init()
  {
    local id: conn_id;
    id$orig_h = 10.10.10.10;
    id$orig_p = 10/tcp;
    id$resp_h = 20.20.20.20;
    id$resp_p = 20/tcp;
    BlockFlow::block(id, 2);
  }
</pre>
<p>And the flow will be blocked for 2 minutes. Unfortunately, due to the way <code>at</code> command works the granularity of timeouts is limited to minutes. If you really want to block flows for only a few seconds a quick solution would be to use <code>sleep</code> in place of <code>at</code> before expiring the rule.</p>The post <a href="https://inspirated.com/2013/07/01/blocking-traffic-flows-selectively-with-a-timeout-from-bro-ids">Blocking traffic flows selectively with a timeout from Bro IDS</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2013/07/01/blocking-traffic-flows-selectively-with-a-timeout-from-bro-ids/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Bro IDS on OpenWRT</title>
		<link>https://inspirated.com/2012/12/10/bro-ids-on-openwrt</link>
					<comments>https://inspirated.com/2012/12/10/bro-ids-on-openwrt#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Mon, 10 Dec 2012 07:59:52 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bro IDS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Flag 42]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shrimp]]></category>
		<category><![CDATA[SysNet]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=381</guid>

					<description><![CDATA[<p>While I was at SysNet, we had been working on a project we called &#8220;Shrimp&#8221; &#8212; Software-defined Home Router Intelligent Monitoring Point. The goal of the project was to provide a framework for easy programmatic access to network monitoring on low-cost, commodity, home router devices. One of the requirements was to have an IDS on [&#8230;]</p>
The post <a href="https://inspirated.com/2012/12/10/bro-ids-on-openwrt">Bro IDS on OpenWRT</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>While I was at <a href="https://sysnet.org.pk/">SysNet</a>, we had been working on a project we called &#8220;Shrimp&#8221; &#8212; <em>Software-defined Home Router Intelligent Monitoring Point</em>. The goal of the project was to provide a framework for easy programmatic access to network monitoring on low-cost, commodity, home router devices. One of the requirements was to have an IDS on the home routers for which we chose Bro &#8212; the leading framework for semantic analysis of network traffic.</p>
<p>The OpenWRT OS was chosen as the target platform. Its SDK contained a cross-compile toolchain for CMake projects. However, during the compilation Bro tried to run the <code>binpac</code> and <code>bifcl</code> executables for processing intermediate files. The executables refused to run on the build platform if the target platform architecture was different (mostly the case, e.g., we were building on <code>x86-64</code> and target was <code>arm</code>).</p>
<p>The (not-so-pretty <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />) workaround we used was to build Bro twice. Once for the host, and once for the target. The CMake files were then patched to first generate <code>binpac</code> and <code>bifcl</code> binaries if they weren&#8217;t provided and then use the provided binaries if they were defined at make time. The first compile generated the binaries on <code>x86-64</code> and the second compile (for <code>arm</code>) used the earlier binaries to process the <code>bif</code> files.</p>
<p>The Makefile and patches are available in this tarball: <a href="https://inspirated.com/uploads/openwrt-bro.tar.gz">openwrt-bro.tar.gz</a>, while the compiled <a href="https://inspirated.com/uploads/bro_2.0-1_ar71xx.ipk"><code>ipk</code> package</a> is also available for installation. Here is a test execution of Bro on OpenWRT:</p>
<pre lang="bash"># bro –v</pre>
<blockquote>
<pre>bro version 2.0</pre>
</blockquote>
<pre lang="bash"># cat test.bro</pre>
<blockquote>
<pre>event bro_init()
{
	print "Hello World!";
}

event new_connection(c: connection)
{
	print "New connection created";
}
</pre>
</blockquote>
<pre lang="bash"># bro test.bro</pre>
<blockquote>
<pre>Hello World!</pre>
</blockquote>
<pre lang="bash"># bro -i br-lan test.bro</pre>
<blockquote>
<pre>Hello World!
New connection created
New connection created</pre>
</blockquote>
<pre lang="bash"># ls</pre>
<blockquote>
<pre>conn.log           notice_policy.log  reporter.log       weird.log
dns.log            packet_filter.log  test.bro</pre>
</blockquote>
<p>A heap of thanks to <a href="https://sysnet.org.pk/w/User:Zaafar">Zaafar</a> for dealing with my messy code and providing the links to hosted files :) !</p>The post <a href="https://inspirated.com/2012/12/10/bro-ids-on-openwrt">Bro IDS on OpenWRT</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2012/12/10/bro-ids-on-openwrt/feed</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>Workflow sharing with Synergy</title>
		<link>https://inspirated.com/2012/11/14/workflow-sharing-with-synergy</link>
					<comments>https://inspirated.com/2012/11/14/workflow-sharing-with-synergy#comments</comments>
		
		<dc:creator><![CDATA[krkhan]]></dc:creator>
		<pubDate>Tue, 13 Nov 2012 23:33:11 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Cross-platform]]></category>
		<category><![CDATA[Dual-Head]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Synergy]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://inspirated.com/?p=379</guid>

					<description><![CDATA[<p>It has been a while since I&#8217;ve posted around here and the reasons have been entirely mundane &#8212; got a job, moved to a different country and lost track of everything open-source during the transition. However, open-source is out there and every once a while you&#8217;re bound to stumble across gems that make life easier [&#8230;]</p>
The post <a href="https://inspirated.com/2012/11/14/workflow-sharing-with-synergy">Workflow sharing with Synergy</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></description>
										<content:encoded><![CDATA[<p>It has been a while since I&#8217;ve posted around here and the reasons have been entirely mundane &#8212; got a job, moved to a different country and lost track of everything open-source during the transition.</p>
<p>However, open-source is out there and every once a while you&#8217;re bound to stumble across gems that make life easier (and fun) no matter which line of work you are in and that&#8217;s exactly what happened to me today. Let me admit first, I have a fetish for multiple screens. If it was up to me I would have a circle of screens and sit inside them all day long, just to make revolving chairs lot more exciting. Take that, 3D!</p>
<p>Anyways, the issue with multiple screens is not only having enough video outputs on your graphic card(s), but also the sharing of resources. I want three different machines with different processors, hard-disks, heck even different operating systems to share their I/O devices. One option would be the KVM switches, but that would restrict me to only one &#8220;active&#8221; machine at a time, plus the switching button is too much of a hindrance in the work flow. Aristotle famously claimed that the whole is greater than the sum of its parts, then cometh <a href="https://synergy-foss.org/">Synergy</a>:</p>
<p style="text-align: center; font-size: x-small"><a href="https://inspirated.com/uploads/synergy.png"><img decoding="async" src="https://inspirated.com/uploads/synergy-thumb.png" alt="Synergy in action" /></a><br />
(Click on the thumbnail for larger version.)</p>
<p>Three different machines sharing the keyboard, mouse and clipboard across five different screens and it even works across different platforms! Granted, there are some issues with the configuration which you have to take care about (especially on Windows 7+ platforms with UAC) but once it gets going it becomes one of those cute <em>plus</em> practical toys that make you wonder how you ever lived without them.</p>The post <a href="https://inspirated.com/2012/11/14/workflow-sharing-with-synergy">Workflow sharing with Synergy</a> first appeared on <a href="https://inspirated.com">Inspirated</a>.]]></content:encoded>
					
					<wfw:commentRss>https://inspirated.com/2012/11/14/workflow-sharing-with-synergy/feed</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
