<?xml version="1.0" encoding="UTF-8"?><feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en-US"
  xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/wp-atom.php"
   >
	<title type="text">Cryptanalyst</title>
	<subtitle type="text">[mahrud@eve ~]$ cat /dev/urandom</subtitle>

	<updated>2014-10-16T01:06:20Z</updated>

	<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog" />
	<id>https://www.ocf.berkeley.edu/~mahrud/blog/feed/atom/</id>
	<link rel="self" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/feed/atom/" />

	<generator uri="http://wordpress.org/" version="4.1.5">WordPress</generator>
	<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[On Incompetence of Mafia in Academia]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2014/06/on-incompetence-of-mafia-in-academia/" />
		<id>http://algorithms.jux-foundation.org/~mahrud/blog/?p=62</id>
		<updated>2014-06-08T16:39:10Z</updated>
		<published>2014-06-08T16:37:13Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Food for Thought" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="CCC" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="IEEE" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Mafia in Academia" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Open Access" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Rant" />		<summary type="html"><![CDATA[I always disliked IEEE and other overgeneralized acronym-associations that run a frigging mafia in academia. Conference on Computational Complexity has just voted to become independent from IEEE and they&#8217;re signing a &#8220;declaration of independence&#8221;. Here is a tl;dr version of their reasons : * IEEE didn’t allow open access to the proceedings (Go! Go! Open [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2014/06/on-incompetence-of-mafia-in-academia/"><![CDATA[<p>I always disliked IEEE and other overgeneralized acronym-associations that run a frigging mafia in academia.</p>
<p><a href="http://computationalcomplexity.org/" title="Conference on Computational Complexity (CCC)">Conference on Computational Complexity</a> has just voted to become independent from IEEE and they&#8217;re signing a &#8220;declaration of independence&#8221;.<br />
Here is a tl;dr version of their reasons  <a class="simple-footnote" title="From Scott Aaronson&#8217;s blog post" id="return-note-62-1" href="#note-62-1"><sup>1</sup></a>:</p>
<p>* IEEE didn’t allow open access to the proceedings (Go! Go! Open Access Journals!)<br />
* they charged a huge overhead that wasn&#8217;t worth the benefits<br />
* Coordinating with IEEE increased rather than decreased the administrative burden on the organizers</p>
<p>Seriously, IEEE is a nonprofit organization with $330 Million in profits <a class="simple-footnote" title="Wiki" id="return-note-62-2" href="#note-62-2"><sup>2</sup></a>.</p>
<p>To sum it up, I enjoyed procrastinating by reading their letter:<br />
<a href="http://computationalcomplexity.org/forum/open-letter/" title="Open Letter (pronounce &quot;declaration of independence&quot;)">http://computationalcomplexity.org/forum/open-letter/</a></p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-62-1">From Scott Aaronson&#8217;s <a href="http://www.scottaaronson.com/blog/?p=1853" title="Shtetl-Optimized: CCC’s Declaration of Independence">blog post</a> <a href="#return-note-62-1">&#8617;</a></li><li id="note-62-2">Wiki <a href="#return-note-62-2">&#8617;</a></li></ol></div>]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2014/06/on-incompetence-of-mafia-in-academia/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2014/06/on-incompetence-of-mafia-in-academia/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Finite Fields, or Some Notes on Why I Love Math! &#8212; Part I]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/finite-fields-some-notes-on-why-i-love-math-part-i/" />
		<id>http://algorithms.ir/~mahrud/blog/?p=50</id>
		<updated>2014-10-01T02:09:39Z</updated>
		<published>2013-04-29T09:32:06Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cryptography" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Mathematics" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="(n-t)-Threshold Scheme" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Finite Fields" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Modular Arithmetic" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Quadratic Equations" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Secret Sharing" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="WP LaTeX" />		<summary type="html"><![CDATA[History In the process of applying for my research fellowship, I had a phone interview with the people there. One of the things that we talked about was about cryptographic schemes that distribute parts of data between, say, nodes, in a way that the data can only be read if at least, say, of those [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/finite-fields-some-notes-on-why-i-love-math-part-i/"><![CDATA[<h3>History</h3>
<p>In the process of applying for my research fellowship, I had a phone interview with the people there. One of the things that we talked about was about cryptographic schemes that distribute parts of data between, say, <img src='https://s0.wp.com/latex.php?latex=n%3D100&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='n=100' title='n=100' class='latex' /> nodes, in a way that the data can only be read if at least, say, <img src='https://s0.wp.com/latex.php?latex=m%3D10&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m=10' title='m=10' class='latex' /> of those <img src='https://s0.wp.com/latex.php?latex=n&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='n' title='n' class='latex' /> nodes come together; for instance, you have a bank with 10 managers and you, as the owner, don&#8217;t trust them enough to give each one of them a key to the vault, so you want to deploy a scheme that lets them open the vault only if at least 3 of them are present <a class="simple-footnote" title="By the way, this is a simple (n,m)-threshold scheme; there are many other secret sharing schemes out there as well." id="return-note-50-1" href="#note-50-1"><sup>1</sup></a>. Since long ago, I knew a trivial answer to this problem for <img src='https://s0.wp.com/latex.php?latex=m%3D2&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m=2' title='m=2' class='latex' /> <a class="simple-footnote" title="My solution was a basic secret splitting scheme:
[caption id=&quot;&quot; align=&quot;aligncenter&quot; width=&quot;239&quot;] Image from Cornell.edu[/caption]
Say, you want to split the key [latex]K[/latex], first create a random key [latex]A[/latex] with the same bitsize, then you have [latex]B=K\oplus A[/latex]. Now, give [latex]A[/latex] to Alice and [latex]B[/latex] to Bob. If they come together they can XOR their keys and calculate the original key as: [latex]K=A\oplus B[/latex]" id="return-note-50-2" href="#note-50-2"><sup>2</sup></a>, but adding to <img src='https://s0.wp.com/latex.php?latex=m&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m' title='m' class='latex' /> is not easy in my solution.</p>
<p>So I looked in my copy of Applied Cryptography book <a class="simple-footnote" title="this." id="return-note-50-3" href="#note-50-3"><sup>3</sup></a> and found a few solutions. Among the solutions two of them caught my attention, one by Karnin-Greene-Hellman that used Linear Algebra (which I&#8217;d love to write about in the future), and another one by Adi Shamir, hence its name, Shamir&#8217;s Secret Sharing scheme, that deploys polynomial equations and LaGrange&#8217;s interpolation algorithm, which I&#8217;ll explain in the next section.</p>
<h3>Introduction to the Solution:<br />
Shamir&#8217;s Secret-Sharing Scheme (aka. LaGrange&#8217;s Interpolation Polynomial Scheme)</h3>
<p>The solution was to first generate a degree <img src='https://s0.wp.com/latex.php?latex=m-1&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m-1' title='m-1' class='latex' /> polynomial equation and call it <img src='https://s0.wp.com/latex.php?latex=K&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='K' title='K' class='latex' />. Now, as those of you who remember linear equations know, if I give you 2 points in a plane, you can give me a line &#8212; a first degree equation:</p>
<div style="width: 396px" class="wp-caption aligncenter"><img alt="" src="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/ss_image04.gif" width="386" height="250" /><p class="wp-caption-text">Image from <a title="CS 513 System Security -- Secret Sharing" href="http://www.cs.cornell.edu/courses/cs513/2000sp/SecretSharing.html">Cornell.edu</a></p></div>
<p>In the picture above 6 points from the line are shown, but only two of them are enough to find the exact equation of the line. Similarly, if I give you 3 points, you can give me a quadratic equation, or a degree 2 equation:</p>
<div style="width: 387px" class="wp-caption aligncenter"><img alt="" src="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/ss_image05.gif" width="377" height="246" /><p class="wp-caption-text">Image from <a title="CS 513 System Security -- Secret Sharing" href="http://www.cs.cornell.edu/courses/cs513/2000sp/SecretSharing.html">Cornell.edu</a></p></div>
<p>To generalize, if I give you <img src='https://s0.wp.com/latex.php?latex=m&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m' title='m' class='latex' /> points, you can give me a degree <img src='https://s0.wp.com/latex.php?latex=m-1&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m-1' title='m-1' class='latex' /> polynomial equation! Got it? Each share is a point in the graph of <img src='https://s0.wp.com/latex.php?latex=K&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='K' title='K' class='latex' />, and since <img src='https://s0.wp.com/latex.php?latex=K&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='K' title='K' class='latex' /> is of degree <img src='https://s0.wp.com/latex.php?latex=m-1&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m-1' title='m-1' class='latex' />, at least <img src='https://s0.wp.com/latex.php?latex=m&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m' title='m' class='latex' /> points &#8212; one for each of the <img src='https://s0.wp.com/latex.php?latex=m&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='m' title='m' class='latex' /> key-holders &#8212; are needed to find the line <img src='https://s0.wp.com/latex.php?latex=K&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='K' title='K' class='latex' /> &#8212; aka. the key! Sounds easy, right?</p>
<h3>The Problem with the Solution</h3>
<p>The problem is that a strong polynomial equation for this scheme have integer solutions, and of course, it&#8217;s hard to work with non-integers in computers; you know, floats are a mess! So basically I ignored this solution and only worked with the Linear Algebraic one; little did I know, the idea behind using this polynomial equation solution is actually very smart!</p>
<h3>The Solution to the Problem of the Solution (!):<br />
Parallel Math Worlds (aka. Finite Fields)</h3>
<p style="color: red;"><strong>Disclaimer</strong>: the following section is intended for non-math people; I&#8217;m a math major student and when I explain this idea to a math-friend I do it right, but hey, this is just a blog post!</p>
<p>     Suppose we live in a world where the biggest number possible is 4! The ONLY numbers you can use are <img src='https://s0.wp.com/latex.php?latex=%5C%7B0%2C1%2C2%2C3%2C4%5C%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\{0,1,2,3,4\}' title='\{0,1,2,3,4\}' class='latex' />. We call that a <strong>finite field or a cyclic group of order five</strong> and denote it as <img src='https://s0.wp.com/latex.php?latex=%5Cmathbb+Z+_%7B5%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\mathbb Z _{5}' title='\mathbb Z _{5}' class='latex' /> <a class="simple-footnote" title="In math books you may also find it denoted as [latex]C_5[/latex] or [latex]\mathbb Z /5\mathbb Z[/latex]" id="return-note-50-4" href="#note-50-4"><sup>4</sup></a>. Now, let us imagine that we live in this <img src='https://s0.wp.com/latex.php?latex=%5Cmathbb+Z+_%7B5%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\mathbb Z _{5}' title='\mathbb Z _{5}' class='latex' /> world; how do you think kids learn math in such a universe? First we need to teach them a modulo or modulus operator:<br />
Let us define a simple division:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=a%3Db%5Ctimes+k+%2B+q&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a=b\times k + q' title='a=b\times k + q' class='latex' /></blockquote>
<p><img src='https://s0.wp.com/latex.php?latex=a&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a' title='a' class='latex' /> is the nominator, <img src='https://s0.wp.com/latex.php?latex=k&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='k' title='k' class='latex' /> is the denominator, <img src='https://s0.wp.com/latex.php?latex=b&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='b' title='b' class='latex' /> is the integer solution of division, and finally the one that we mostly interested in: <img src='https://s0.wp.com/latex.php?latex=q&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='q' title='q' class='latex' /> is our remainder. Now we define modulo operator <img src='https://s0.wp.com/latex.php?latex=%5Cbmod&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\bmod' title='\bmod' class='latex' /> as:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=a%5Cequiv+q+%5Cbmod+k&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a\equiv q \bmod k' title='a\equiv q \bmod k' class='latex' /></blockquote>
<p>Got it? Simple as that! So what else do they learn in school?</p>
<ul>
<li>First thing they learn is addition, of course:<br />
<blockquote><p><img src='https://s0.wp.com/latex.php?latex=a%2Bb%5Cequiv+c+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a+b\equiv c \bmod 5' title='a+b\equiv c \bmod 5' class='latex' /><br />
e.g: <img src='https://s0.wp.com/latex.php?latex=2%2B4%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='2+4\equiv 1 \bmod 5' title='2+4\equiv 1 \bmod 5' class='latex' /></p></blockquote>
</li>
<li>Then, in subtraction, in order to solve <img src='https://s0.wp.com/latex.php?latex=a-b+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a-b \bmod 5' title='a-b \bmod 5' class='latex' />, we need to find <img src='https://s0.wp.com/latex.php?latex=d&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='d' title='d' class='latex' /> such that:<br />
<blockquote><img src='https://s0.wp.com/latex.php?latex=b%2Bd%5Cequiv+0+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='b+d\equiv 0 \bmod 5' title='b+d\equiv 0 \bmod 5' class='latex' /></blockquote>
<p>Then we can say that:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=a-b%3Da%2B%28-b%29%5Cequiv+a%2Bd+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a-b=a+(-b)\equiv a+d \bmod 5' title='a-b=a+(-b)\equiv a+d \bmod 5' class='latex' /></blockquote>
<p>And since we already know addition:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=a-b%5Cequiv+a%2Bd%5Cequiv+c+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a-b\equiv a+d\equiv c \bmod 5' title='a-b\equiv a+d\equiv c \bmod 5' class='latex' /></blockquote>
<p>For instance, since:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=2%2B3%5Cequiv+0+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='2+3\equiv 0 \bmod 5' title='2+3\equiv 0 \bmod 5' class='latex' /></blockquote>
<p>We work <img src='https://s0.wp.com/latex.php?latex=1-2+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='1-2 \bmod 5' title='1-2 \bmod 5' class='latex' /> out as:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=1-2%3D1%2B%28-2%29%5Cequiv+1%2B3%5Cequiv+4+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='1-2=1+(-2)\equiv 1+3\equiv 4 \bmod 5' title='1-2=1+(-2)\equiv 1+3\equiv 4 \bmod 5' class='latex' /></blockquote>
</li>
<li>Next they learn multiplication:<br />
<blockquote><p><img src='https://s0.wp.com/latex.php?latex=a%5Ctimes+b%5Cequiv+c+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a\times b\equiv c \bmod 5' title='a\times b\equiv c \bmod 5' class='latex' /><br />
e.g: <img src='https://s0.wp.com/latex.php?latex=2%5Ctimes+4%5Cequiv+3+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='2\times 4\equiv 3 \bmod 5' title='2\times 4\equiv 3 \bmod 5' class='latex' /></p></blockquote>
</li>
<li>Similarly for division, in order to find <img src='https://s0.wp.com/latex.php?latex=a%5Cdiv+b+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a\div b \bmod 5' title='a\div b \bmod 5' class='latex' />, we need to find <img src='https://s0.wp.com/latex.php?latex=d&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='d' title='d' class='latex' /> such that:<br />
<blockquote><img src='https://s0.wp.com/latex.php?latex=b%5Ctimes+d+%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='b\times d \equiv 1 \bmod 5' title='b\times d \equiv 1 \bmod 5' class='latex' /></blockquote>
<p>Or:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=+%7B1+%5Cover+b%7D%5Cequiv+d+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=1' alt=' {1 \over b}\equiv d \bmod 5' title=' {1 \over b}\equiv d \bmod 5' class='latex' /></blockquote>
<p>This idea of calculating the reciprocal of a number in <img src='https://s0.wp.com/latex.php?latex=%5Cmathbb+Z+_%7B5%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\mathbb Z _{5}' title='\mathbb Z _{5}' class='latex' /> is quite interesting for me, you&#8217;ll see why soon. Using this idea, we can say that:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=a%5Cdiv+b%3Da%5Ctimes+b%5E%7B-1%7D%5Cequiv+a%5Ctimes+d+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a\div b=a\times b^{-1}\equiv a\times d \bmod 5' title='a\div b=a\times b^{-1}\equiv a\times d \bmod 5' class='latex' /></blockquote>
<p>Now since we already know multiplication:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=a%5Cdiv+b%5Cequiv+a%5Ctimes+d%5Cequiv+c+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='a\div b\equiv a\times d\equiv c \bmod 5' title='a\div b\equiv a\times d\equiv c \bmod 5' class='latex' /></blockquote>
<p>For instance, since:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=3%5Ctimes2%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='3\times2\equiv 1 \bmod 5' title='3\times2\equiv 1 \bmod 5' class='latex' /></blockquote>
<p>We work <img src='https://s0.wp.com/latex.php?latex=4%5Cdiv+3+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='4\div 3 \bmod 5' title='4\div 3 \bmod 5' class='latex' /> out as:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=4%5Cdiv+3%3D4%5Ctimes+3%5E%7B-1%7D%5Cequiv+4%5Ctimes+2+%5Cequiv+3+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='4\div 3=4\times 3^{-1}\equiv 4\times 2 \equiv 3 \bmod 5' title='4\div 3=4\times 3^{-1}\equiv 4\times 2 \equiv 3 \bmod 5' class='latex' /></blockquote>
<p>Note that not all numbers in a group are invertible. We&#8217;ll get to this later.</li>
<li>Next big thing is exponentiation and finding e-th root. I&#8217;ll get to e-th root for $latex 2<br />
<blockquote><p><img src='https://s0.wp.com/latex.php?latex=2%5E3%3D8%5Cequiv+3+%5Cbmod+5+%5C%5C+4%5E2%3D16%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='2^3=8\equiv 3 \bmod 5 \\ 4^2=16\equiv 1 \bmod 5' title='2^3=8\equiv 3 \bmod 5 \\ 4^2=16\equiv 1 \bmod 5' class='latex' /><br />
<img src='https://s0.wp.com/latex.php?latex=%5Csqrt%7B1%7D%5Cequiv+1%5Cbmod+5+%5C%5C+%5Csqrt%7B1%7D%5Cequiv+4%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\sqrt{1}\equiv 1\bmod 5 \\ \sqrt{1}\equiv 4\bmod 5' title='\sqrt{1}\equiv 1\bmod 5 \\ \sqrt{1}\equiv 4\bmod 5' class='latex' /> (because <img src='https://s0.wp.com/latex.php?latex=16%5Cequiv+1%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='16\equiv 1\bmod 5' title='16\equiv 1\bmod 5' class='latex' />)</p></blockquote>
</li>
</ul>
<p>I think that&#8217;s enough for now. For the record, this is what we call Modular Arithmetic in this world, of course, in the parallel world this is just normal mathematics!</p>
<p>Let us see a wonderful application of everything above, shall we? Here is the question, solve the quadratic equation below: (yes, of course I mean in <img src='https://s0.wp.com/latex.php?latex=%5Cmathbb+Z+_%7B5%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\mathbb Z _{5}' title='\mathbb Z _{5}' class='latex' />!)</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=x%5E2%2B2x-3%3D0&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x^2+2x-3=0' title='x^2+2x-3=0' class='latex' /></blockquote>
<p>Any ideas where to begin? Well, it&#8217;s actually not as hard as you think! In fact you can solve it exactly the way you would have done it in this world! Solutions of a quadratic equation are:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=+x%3D%7B-b%5Cpm+%5Csqrt%7Bb%5E2-4ac%7D+%5Cover+2a%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=2' alt=' x={-b\pm \sqrt{b^2-4ac} \over 2a}' title=' x={-b\pm \sqrt{b^2-4ac} \over 2a}' class='latex' /></blockquote>
<p>Just like this world! Except that we need to use modular arithmetic to find x. Enough talking, let&#8217;s work it out:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=+x%3D%7B-2%5Cpm+%5Csqrt%7B2%5E2-4%281%29%28-3%29%7D+%5Cover+2%281%29%7D%5Cequiv%7B%283%29%5Cpm+%5Csqrt%7B4-%28-12%29%7D+%5Cover+2%7D%5Cequiv%7B3%5Cpm+%5Csqrt%7B4%2B12%7D+%5Cover+2%7D%5Cequiv%7B3%5Cpm+%5Csqrt%7B1%7D+%5Cover+2%7D%5C%5C%5Cequiv%283%5Cpm+%5Csqrt%7B1%7D%29+%5Ctimes+2%5E%7B-1%7D%5Cequiv%283%5Cpm+%5Csqrt%7B1%7D%29+%5Ctimes+3&#038;bg=T&#038;fg=b9bdb6&#038;s=1' alt=' x={-2\pm \sqrt{2^2-4(1)(-3)} \over 2(1)}\equiv{(3)\pm \sqrt{4-(-12)} \over 2}\equiv{3\pm \sqrt{4+12} \over 2}\equiv{3\pm \sqrt{1} \over 2}\\\equiv(3\pm \sqrt{1}) \times 2^{-1}\equiv(3\pm \sqrt{1}) \times 3' title=' x={-2\pm \sqrt{2^2-4(1)(-3)} \over 2(1)}\equiv{(3)\pm \sqrt{4-(-12)} \over 2}\equiv{3\pm \sqrt{4+12} \over 2}\equiv{3\pm \sqrt{1} \over 2}\\\equiv(3\pm \sqrt{1}) \times 2^{-1}\equiv(3\pm \sqrt{1}) \times 3' class='latex' /></blockquote>
<p>At this point you may say: &#8220;Wow! We are about to have 4 solutions!! Because <img src='https://s0.wp.com/latex.php?latex=%5Csqrt%7B1%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\sqrt{1}' title='\sqrt{1}' class='latex' /> has 2 answers in <img src='https://s0.wp.com/latex.php?latex=%5Cmathbb+Z+_%7B5%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\mathbb Z _{5}' title='\mathbb Z _{5}' class='latex' /> and we have two final solutions based on each answer of the square root!&#8221; (because of the <img src='https://s0.wp.com/latex.php?latex=%5Cpm&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\pm' title='\pm' class='latex' />). I thought so in the beginning too. However, if you think about it, even when you are solving a quadratic equation in this world, the discriminant (<img src='https://s0.wp.com/latex.php?latex=b%5E2-4ac&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='b^2-4ac' title='b^2-4ac' class='latex' />) always has two square roots: <img src='https://s0.wp.com/latex.php?latex=%2B%5Csqrt%28b%5E2-4ac%29&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='+\sqrt(b^2-4ac)' title='+\sqrt(b^2-4ac)' class='latex' /> and <img src='https://s0.wp.com/latex.php?latex=-%5Csqrt%28b%5E2-4ac%29&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='-\sqrt(b^2-4ac)' title='-\sqrt(b^2-4ac)' class='latex' />; but since radical is defined to always return the positive root, we have to put a <img src='https://s0.wp.com/latex.php?latex=%5Cpm&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\pm' title='\pm' class='latex' /> to count for the negative root too. However, in our parallel universe, since we don&#8217;t like negative numbers, we add multiples of the group size to them so they become positive, and because of that, in the parallel universe, numbers can have <strong>two</strong> positive square roots! So technically we could ignore the <img src='https://s0.wp.com/latex.php?latex=%5Cpm&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\pm' title='\pm' class='latex' /> and just try both square roots and that would give us both answers; so let&#8217;s see, in our example:</p>
<ul>
<li>First let&#8217;s try adding <img src='https://s0.wp.com/latex.php?latex=%5Csqrt%7B1%7D%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\sqrt{1}\equiv 1 \bmod 5' title='\sqrt{1}\equiv 1 \bmod 5' class='latex' />:<br />
<img src='https://s0.wp.com/latex.php?latex=x_%7B1%7D%3D%283%2B1%29+%5Ctimes+3%5Cequiv+4+%5Ctimes+3%5Cequiv+2+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x_{1}=(3+1) \times 3\equiv 4 \times 3\equiv 2 \bmod 5' title='x_{1}=(3+1) \times 3\equiv 4 \times 3\equiv 2 \bmod 5' class='latex' /></li>
<li>Now let&#8217;s try subtracting <img src='https://s0.wp.com/latex.php?latex=%5Csqrt%7B1%7D%5Cequiv+4+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\sqrt{1}\equiv 4 \bmod 5' title='\sqrt{1}\equiv 4 \bmod 5' class='latex' />:<br />
<img src='https://s0.wp.com/latex.php?latex=x_%7B4%7D%3D%283-4%29+%5Ctimes+3%5Cequiv+%28-1%29+%5Ctimes+3%5Cequiv+4+%5Ctimes+3%5Cequiv+2+%5Cbmod+5%3Dx_%7B1%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x_{4}=(3-4) \times 3\equiv (-1) \times 3\equiv 4 \times 3\equiv 2 \bmod 5=x_{1}' title='x_{4}=(3-4) \times 3\equiv (-1) \times 3\equiv 4 \times 3\equiv 2 \bmod 5=x_{1}' class='latex' /></li>
<p>See? we have the same solution! Now for the other one:</p>
<li>First adding <img src='https://s0.wp.com/latex.php?latex=%5Csqrt%7B1%7D%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\sqrt{1}\equiv 1 \bmod 5' title='\sqrt{1}\equiv 1 \bmod 5' class='latex' />:<br />
<img src='https://s0.wp.com/latex.php?latex=x_%7B2%7D%3D%283-1%29+%5Ctimes+3%5Cequiv+2+%5Ctimes+3%5Cequiv+1+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x_{2}=(3-1) \times 3\equiv 2 \times 3\equiv 1 \bmod 5' title='x_{2}=(3-1) \times 3\equiv 2 \times 3\equiv 1 \bmod 5' class='latex' /></li>
<li>Then subtracting <img src='https://s0.wp.com/latex.php?latex=%5Csqrt%7B1%7D%5Cequiv+4+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\sqrt{1}\equiv 4 \bmod 5' title='\sqrt{1}\equiv 4 \bmod 5' class='latex' />:<br />
<img src='https://s0.wp.com/latex.php?latex=x_%7B3%7D%3D%283%2B4%29+%5Ctimes+3%5Cequiv+2+%5Ctimes+3%5Cequiv+1+%5Cbmod+5%3Dx_%7B2%7D&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x_{3}=(3+4) \times 3\equiv 2 \times 3\equiv 1 \bmod 5=x_{2}' title='x_{3}=(3+4) \times 3\equiv 2 \times 3\equiv 1 \bmod 5=x_{2}' class='latex' /></li>
</ul>
<p>Ta-Daah! Now that we have the two roots of the equations, we can factor it as:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=x%5E2%2B2x-3%3D%28x-1%29%28x-2%29%5Cequiv+%28x%2B4%29%28x%2B3%29+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x^2+2x-3=(x-1)(x-2)\equiv (x+4)(x+3) \bmod 5' title='x^2+2x-3=(x-1)(x-2)\equiv (x+4)(x+3) \bmod 5' class='latex' /></blockquote>
<p>Now let&#8217;s check them, just for the fun of it:</p>
<blockquote><img src='https://s0.wp.com/latex.php?latex=x_%7B1%7D%5E2%2B2x_%7B1%7D-3%3D%281%29%5E2%2B2%281%29-3%3D1%2B2-3%3D0%5Cequiv+0+%5Cbmod+5+%5C%5C+x_%7B2%7D%5E2%2B2x_%7B2%7D-3%3D%282%29%5E2%2B2%282%29-3%3D4%2B4-3%3D5%5Cequiv+0+%5Cbmod+5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='x_{1}^2+2x_{1}-3=(1)^2+2(1)-3=1+2-3=0\equiv 0 \bmod 5 \\ x_{2}^2+2x_{2}-3=(2)^2+2(2)-3=4+4-3=5\equiv 0 \bmod 5' title='x_{1}^2+2x_{1}-3=(1)^2+2(1)-3=1+2-3=0\equiv 0 \bmod 5 \\ x_{2}^2+2x_{2}-3=(2)^2+2(2)-3=4+4-3=5\equiv 0 \bmod 5' class='latex' /></blockquote>
<p><span style="color:red">For my fellow math people:</span> I found it very interesting that the proof of impossibility of a general algebraic solution to polynomial equations of degree five or higher &#8212; aka. <a href="http://en.wikipedia.org/wiki/Abel%E2%80%93Ruffini_theorem" title="Abel–Ruffini theorem">Abel–Ruffini theorem</a> &#8212; uses groups too and I finally gasped the importance of the <a href="http://en.wikipedia.org/wiki/Group_theory" title="Galois theory">Galois theory</a> and <a href="http://en.wikipedia.org/wiki/Galois_group" title="Galois group">Galois group</a>! All thanks to a friend of mine, <a href="http://barnamak.blogsky.com/" title="Barnamak">Amirali Moinfar</a>.</p>
<h3>Polynomial Equations in Parallel Math Worlds</h3>
<p>Now why did I just spend an hour writing about a parallel universe <a class="simple-footnote" title="That reminds me, maybe I can expand this later to write a math novel, like Flatland; I might call it &#8220;Finiteland&#8221; or something, I&#8217;ll see &#8230;" id="return-note-50-5" href="#note-50-5"><sup>5</sup></a>? Because this is exactly the beautiful idea that lets us use the Shamir&#8217;s scheme in computers without being forced to mess with floaties! If I define my key polynomial in a finite field of order, hmmm, say, <img src='https://s0.wp.com/latex.php?latex=2%5E%7B127%7D-1&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='2^{127}-1' title='2^{127}-1' class='latex' /> (which, by the way, just so happens to be a <a title="Wikipedia: Mersenne Primes" href="en.wikipedia.org/wiki/Mersenne_prime">Mersenne Prime</a>), then you can generate a key polynomial of any degree with points a 126-bit coordinate system <a class="simple-footnote" title="Ignore this, it&#8217;s just a reminder for me: think about how you can involve public-key cryptography with this &#8230; the polynomial is the master key which gives each person an X-coordinate that can be the private key and a Y that can be the public key &#8230; cool! I should think about it &#8230;" id="return-note-50-6" href="#note-50-6"><sup>6</sup></a>. All done without touching any floaties in the process!</p>
<p>See? This is why you need to know how to solve quadratic equations when you grow up!<br />
I think that&#8217;s pretty much enough for this part &#8230;. In the next part I&#8217;ll talk about more applications of Finite Fields.</p>
<hr />
<p>So,<br />
<strong>Dear all-friends-who-think-I-should-have-been-a-Computer-Science-major-instead-of-a-Math-major,</strong></p>
<p>I chose Mathematics because at most (but not all) universities, the Computer Science major is designed to create computer *engineers* &#8212; yes, even in the ones that have two different majors one for engineering one for science, the courses are almost identical &#8211;, but I don&#8217;t want to be an engineer! We created computers, but for many people they are slowly becoming a new specie that we have to adapt ourselves with it rather than changing it the way we want. I want to learn about the algorithms and mathematical ideas behind them, potentially change them, not just learn Java and C++! And as a Math major I can do so!</p>
<p>Last thing I want to do now is to rant about how poor our education system is &#8230; because it actually turned out to be useful for me! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":-D" class="wp-smiley" /> It&#8217;s a hard thing to debate about; you see, I learned a lot of things that I know in the library of my high school. On one hand, I still find what I learned in school to be useful. On the other hand, I don&#8217;t remember a single exam that I didn&#8217;t spend the time I was supposed to be studying for it on reading some random book that I borrowed from the library!</p>
<p>One thing that I&#8217;m sure of is that I don&#8217;t rely on the formal education, but I don&#8217;t underestimate it either. For instance, why do you think Calculus is the first major math course in college? Because it&#8217;s [arguably] the easiest one! There is much much more [interesting] stuff in Mathematics than many people think there is and it&#8217;s sad to know that even many college students don&#8217;t have any clue about it!</p>
<p><strong>Sincerely,<br />
M</strong></p>
<p>P.S: Again, thanks to <a href="http://barnamak.blogsky.com/" title="Barnamak">Amirali Moinfar</a> for proofreading this post. Also it&#8217;s worth mentioning that I used the WP <img src='https://s0.wp.com/latex.php?latex=%5CLaTeX&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\LaTeX' title='\LaTeX' class='latex' /> plugin to generate the formulas. I also enjoyed <a title="Wikipedia: Help:Displaying a formula" href="http://en.wikipedia.org/wiki/Help:Displaying_a_formula">this life saver</a> a lot!</p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-50-1">By the way, this is a simple <strong>(n,m)-threshold scheme</strong>; there are many other secret sharing schemes out there as well. <a href="#return-note-50-1">&#8617;</a></li><li id="note-50-2">My solution was a basic secret splitting scheme:</p>
<div style="width: 249px" class="wp-caption aligncenter"><img alt="Secret: 1011, S1: 0110, S2: 1101" src="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/ss_image01.gif" width="239" height="109" /><p class="wp-caption-text">Image from <a title="CS 513 System Security -- Secret Sharing" href="http://www.cs.cornell.edu/courses/cs513/2000sp/SecretSharing.html">Cornell.edu</a></p></div>
<p>Say, you want to split the key <img src='https://s0.wp.com/latex.php?latex=K&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='K' title='K' class='latex' />, first create a random key <img src='https://s0.wp.com/latex.php?latex=A&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='A' title='A' class='latex' /> with the same bitsize, then you have <img src='https://s0.wp.com/latex.php?latex=B%3DK%5Coplus+A&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='B=K\oplus A' title='B=K\oplus A' class='latex' />. Now, give <img src='https://s0.wp.com/latex.php?latex=A&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='A' title='A' class='latex' /> to Alice and <img src='https://s0.wp.com/latex.php?latex=B&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='B' title='B' class='latex' /> to Bob. If they come together they can XOR their keys and calculate the original key as: <img src='https://s0.wp.com/latex.php?latex=K%3DA%5Coplus+B&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='K=A\oplus B' title='K=A\oplus B' class='latex' /> <a href="#return-note-50-2">&#8617;</a></li><li id="note-50-3"><a title="Applied Cryptography by Bruce Schneier " href="http://www.schneier.com/book-applied.html">this</a>. <a href="#return-note-50-3">&#8617;</a></li><li id="note-50-4">In math books you may also find it denoted as <img src='https://s0.wp.com/latex.php?latex=C_5&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='C_5' title='C_5' class='latex' /> or <img src='https://s0.wp.com/latex.php?latex=%5Cmathbb+Z+%2F5%5Cmathbb+Z&#038;bg=T&#038;fg=b9bdb6&#038;s=0' alt='\mathbb Z /5\mathbb Z' title='\mathbb Z /5\mathbb Z' class='latex' /> <a href="#return-note-50-4">&#8617;</a></li><li id="note-50-5">That reminds me, maybe I can expand this later to write a math novel, like Flatland; I might call it &#8220;Finiteland&#8221; or something, I&#8217;ll see &#8230; <a href="#return-note-50-5">&#8617;</a></li><li id="note-50-6">Ignore this, it&#8217;s just a reminder for me: think about how you can involve public-key cryptography with this &#8230; the polynomial is the master key which gives each person an X-coordinate that can be the private key and a Y that can be the public key &#8230; cool! I should think about it &#8230; <a href="#return-note-50-6">&#8617;</a></li></ol></div>]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/finite-fields-some-notes-on-why-i-love-math-part-i/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/finite-fields-some-notes-on-why-i-love-math-part-i/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[State of Affairs: SURF@Caltech]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/state-of-affairs-surf-at-caltech/" />
		<id>http://algorithms.ir/~mahrud/blog/?p=42</id>
		<updated>2013-04-08T07:11:26Z</updated>
		<published>2013-04-08T06:59:46Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cryptography" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="SURF@Caltech" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Caltech" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cool" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Coursera" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Crypto" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Dan Boneh" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Jux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="SELinux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="SURF" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="TOR" />		<summary type="html"><![CDATA[TL;DR: things are surprisingly going good for once. In philosophy, a state of affairs, or (also known as) a situation, is a way the actual world must be in order to make some given proposition about the actual world true; in other words, a state of affairs (situation) is a truth-maker, whereas a proposition is [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/state-of-affairs-surf-at-caltech/"><![CDATA[<p>TL;DR: things are surprisingly going good for once.</p>
<blockquote><p>In philosophy, a state of affairs, or (also known as) a situation, is a way the actual world must be in order to make some given proposition about the actual world true; in other words, a state of affairs (situation) is a truth-maker, whereas a proposition is a truth-bearer. <a class="simple-footnote" title="Wikipedia, what else were you expecting? Stanford Encyclopedia of Philosophy?! Psht!" id="return-note-42-1" href="#note-42-1"><sup>1</sup></a></p></blockquote>
<p>Now that you&#8217;ve proved to be patient enough &#8230; I got accepted for the very cool <a href="http://www.surf.caltech.edu/" title="Summer Undergraduate Research Fellowships, California Institute of Technology">Summer Undergraduate Research Fellowship</a> at <a href="http://www.caltech.edu/" title="California Institute of Technology">Caltech</a> <a class="simple-footnote" title="COOL! Right?!" id="return-note-42-2" href="#note-42-2"><sup>2</sup></a> which is very cool!!</p>
<p>As of now I&#8217;m buried under a ton of paperwork (agreements &#8216;n stuff) that I have to sign and submit soon. Then &#8230; I have to wait for two months or so before the program starts. <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_neutral.gif" alt=":-|" class="wp-smiley" /></p>
<p>There, I&#8217;ll be working on a very cool project that involves a variety of things that I have experience [playing!] with, from pure Cryptography (Public Key Cryptography, secret sharing, etc.) to Onion Routing (like TOR), and Linux network and security features such as OpenSSL, SELinux, etc! A friend of mine said it sounds super cool and honestly, I think it is, so much that I may [or may not] be a little worried about how effective I will be there; but, as I said to my friend, it was just a hobby in the beginning, until it got serious!</p>
<p>Those who know me closely know that Jux (formerly HelliJudge) is more than just a project for me; it&#8217;s a hobby, even more, it&#8217;s like a pet! <a class="simple-footnote" title="Have you seen Frankenweenie? Yeah, Frankenstein&#8217;s pet! More like that kind of pet! :-D" id="return-note-42-3" href="#note-42-3"><sup>3</sup></a> I go back and play with it whenever I get bored! I tweak it, test features, add features, or at the very least, try to engage in an endless theoretic discussion with Hamed about how to implement new crazy features &#8212; needless to say, it never ends!<br />
Anyway, my point is, I started and [almost] completely ended a [quite] successful project &#8212; that I knew almost nothing about &#8212; in half a summer, by getting to school everyday, eating lunch behind my laptop while discussing the project with Hamed, and going home right before getting dark while still discussing the project in the bus!</p>
<p>Of course I can manage a summer research fellowship that I know so much about already! So, the more challenging it is, the more I&#8217;ll gain from it.</p>
<p>On a related note, since late January I took an online <a href="https://www.coursera.org/course/crypto" title="Cryptography I">Cryptography</a> course on Coursera taught by <a href="http://crypto.stanford.edu/~dabo/" title="Dan Boneh @ Stanford Crypto Group">Dan Boneh</a>, who I came to realize to be a pretty famous Cryptography professor at Stanford. It covered a wide variety of subjects from symmetric encryption, data integrity, and public-key encryption, to key exchange. The class ended about a month ago, but it&#8217;s been restarted since less than two weeks ago, so if you&#8217;re fast enough you can easily catch up without missing any deadlines. The best part was programming assignments that often even included breaking real-life cryptograms!</p>
<p>Last note: until now this blog was merely named Cryptanalyst and maybe a little OpenSSL or other security related stuff was mentioned. The main reason being that I simply couldn&#8217;t say anything new about cryptography; not yet! But starting from now I want to engage more seriously with cryptography, maybe write about my ideas or just topics that I&#8217;m working on.</p>
<p>So, to future!<br />
M</p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-42-1"><a href="http://en.wikipedia.org/wiki/State_of_affairs_(philosophy)" title="State of affairs (philosophy)">Wikipedia</a>, what else were you expecting? <a href="http://plato.stanford.edu/entries/states-of-affairs/" title="States of Affairs">Stanford Encyclopedia of Philosophy</a>?! Psht! <a href="#return-note-42-1">&#8617;</a></li><li id="note-42-2">COOL! Right?! <a href="#return-note-42-2">&#8617;</a></li><li id="note-42-3">Have you seen Frankenweenie? Yeah, Frankenstein&#8217;s pet! More like that kind of pet! :-D <a href="#return-note-42-3">&#8617;</a></li></ol></div>]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/state-of-affairs-surf-at-caltech/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/04/state-of-affairs-surf-at-caltech/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Google Chromebook: Chrome OS, Chromium, or Fedora Linux? Whatever &#8230;]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/03/google-chromebook-chrome-os-chromium-or-fedora-linux-whatever/" />
		<id>http://algorithms.ir/~mahrud/blog/?p=38</id>
		<updated>2013-05-05T04:23:57Z</updated>
		<published>2013-03-19T11:50:20Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="The Inner Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Chrome OS" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Chromium" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="crosh" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Dena" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Fedora" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Google" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Samsung ARM Chromebook" />		<summary type="html"><![CDATA[Dear Sister, Remember that Chromebook that you bought for your birthday a while back? Just thought I&#8217;d let you know that I switched to the developer mode and booted up Fedora Linux off of a SD card. No harm done! Here&#8217;s a short story of what I think about this whole bizarre [almost] fairy tale. [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2013/03/google-chromebook-chrome-os-chromium-or-fedora-linux-whatever/"><![CDATA[<p>Dear Sister,</p>
<blockquote><p>Remember that Chromebook that you bought for your birthday a while back? Just thought I&#8217;d let you know that I switched to the developer mode and booted up Fedora Linux off of a SD card. No harm done! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_razz.gif" alt=":-P" class="wp-smiley" /><br />
Here&#8217;s a short story of what I think about this whole bizarre [almost] fairy tale.</p></blockquote>
<hr />
So, Google, being the <a href="http://www.schneier.com/blog/archives/2012/12/feudal_sec.html" title="Schneier on Security: Feudal Security">feudal lord</a> that it is, starts this ambitious project of starting their own Operating System  <a class="simple-footnote" title="although I refuse to believe that they haven&#8217;t silently worked on any such projects before!" id="return-note-38-1" href="#note-38-1"><sup>1</sup></a> called Chrome OS. Now, call me biased, but I think good programmers <strong>MUST</strong> have two backgrounds: 1- algorithm and data structure, 2- Unix or Gnu/Linux philosophy; and Google, being the &#8230; well, Google(!), has collected all the good ones.  <a class="simple-footnote" title="and that&#8217;s probably why most other companies suck!" id="return-note-38-2" href="#note-38-2"><sup>2</sup></a> So, no wonder why Chromium, the underlying core of Chrome OS, is actually a legit Linux distribution with a kernel and Gnu software and everything!</p>
<p>One thing though, Google&#8217;s idea of keeping it&#8217;s product both safe (secure boot &#8216;n stuff) and developer friendly is this: you get to choose between security and freedom! <a class="simple-footnote" title="Matthew Garrett believes nobody should be forced to make that choice, and I ought to agree." id="return-note-38-3" href="#note-38-3"><sup>3</sup></a> &#8220;Bizarre&#8221;, is the only word that I could think of to describe this idea. However, I think it&#8217;s a very good place to start for a better future. Chromium developers have written <a href="http://www.chromium.org/chromium-os/chromiumos-design-docs/developer-mode" title="Developer Mode - The Chromium Projects">a truly lovely page</a> on the challenges and possible vulnerabilities of an ideal combination of security and freedom.</p>
<p>Long story short, <a href="http://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/samsung-arm-chromebook" title="Samsung ARM Chromebook -- The Chromium Projects">this page</a> from the Chromium developers helped me to switch your laptop to the developer mode. At this point you have a built-in shell called `crosh` with root access waiting for you; just push <strong>Ctrl+Alt+t</strong> after you logged in and you&#8217;ll see a new tab open up with a prompt that reads:</p>
<pre class="brush: plain; title: ; notranslate">Welcome to crosh, type 'help' for a list of commands.
crosh&gt; </pre>
<p>Pretty cool, huh? As I&#8217;ve thought you before, just type `help` to get help:  <a class="simple-footnote" title="Again, as I&#8217;ve told you before, one out of many superpowers of hackers is that they know WHEN and HOW to get help when they need it, that&#8217;s why they can get what they want from any kind of shell. Anyway &#8230;" id="return-note-38-4" href="#note-38-4"><sup>4</sup></a></p>
<pre class="brush: plain; title: ; notranslate">crosh&gt; help

 exit
  Exit crosh.

 help
  Display this help.

 help_advanced
  Display the help for more advanced commands, mainly used for debugging.

 ping [-c count] [-i interval] [-n] [-s packetsize] [-W waittime] &lt;destination&gt;
  Send ICMP ECHO_REQUEST packets to a network host.  If &lt;destination&gt; is &quot;gw&quot;
  then the next hop gateway for the default route is used.
 ssh [optional args...]
  Starts the ssh subsystem if invoked without any arguments.
  &quot;ssh &lt;user&gt; &lt;host&gt;&quot;, &quot;ssh &lt;user&gt; &lt;host&gt; &lt;port&gt;&quot;, &quot;ssh &lt;user&gt;@&lt;host&gt;&quot;,
  or &quot;ssh &lt;user&gt;@&lt;host&gt; &lt;port&gt;&quot; connect without entering the subsystem.
 ssh_forget_host
  Remove a host from the list of known ssh hosts.  This command displays
  a menu of known hosts and prompts for the host to forget.
 top
  Run top.
 shell
  Open a command line shell.
 systrace [&lt;start | stop | status&gt;]
  Start/stop system tracing.  Turning tracing off will generate a trace
  log file in the Downloads directory with all the events collected
  since the last time tracing was enabled.  One can control the events
  collected by specifying categories after &quot;start&quot;; e.g. &quot;start gfx&quot;
  will collect only graphics-related system events.  &quot;systrace status&quot;
  (or just &quot;systrace&quot;) will display the current state of tracing, including
  the set of events being traced.</pre>
<p>In the Normal Mode you have almost all of these options, except for the latter two. Well, go on then:</p>
<pre class="brush: plain; title: ; notranslate">crosh&gt; shell
chronos@localhost / $ id
uid=1000(chronos) gid=1000(chronos)
chronos@localhost / $ uname -a
Linux localhost 3.4.0 #1 SMP Wed Mar 13 11:38:55 PDT 2013 armv7l ARMv7 Processor rev 4 (v7l) SAMSUNG EXYNOS5 (Flattened Device Tree) GNU/Linux</pre>
<p>Ta Dah! And that&#8217;s not all of it:</p>
<pre class="brush: plain; title: ; notranslate">chronos@localhost / $ sudo -i
localhost ~ # id
uid=0(root) gid=0(root)</pre>
<p>I know, right? A beautiful laptop with Linux pre-installed and no hardware issues! <a class="simple-footnote" title="Now, don&#8217;t tell me that you don&#8217;t like this distro, a true Linuxer can manage through any distro what so ever!" id="return-note-38-5" href="#note-38-5"><sup>5</sup></a> Love you Google! Keep up the good work!<br />
<a href="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/Screenshot-2013-03-19-at-3.58.18-AM.png"><img src="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/Screenshot-2013-03-19-at-3.58.18-AM-625x351.png" alt="Screenshot 2013-03-19 at 3.58.18 AM" width="625" height="351" class="aligncenter size-medium wp-image-39" /></a><br />
Now, when did Fedora come in? About a week after all that, I saw <a href="https://www.berrange.com/posts/2012/11/30/installing-fedora-17-arm-on-a-samsung-google-chromebook/" title="Installing Fedora 17 ARM on a Samsung Google Chromebook">this</a> and <a href="http://mcpierce.blogspot.com/2013/02/loading-fedora-on-samsung-chromebook.html" title="Loading Fedora On A Samsung Chromebook">this</a> post on Google Reader <a class="simple-footnote" title="At the time I&#8217;m drafting this post, Google has decided that they will murder Google Reader by the end of July :&#039;( Pray to WWW Gods that they change their mind!" id="return-note-38-6" href="#note-38-6"><sup>6</sup></a>. They are pretty self-explanatory. May I stop here? I&#8217;m very tired an it&#8217;s 3:29AM! Oh, one more thing, I know that you are learning Python programming on a Raspberry Pi, Fedora on Chromebook is like a Raspberry Pi with almost four times more RAM, more than twice CPU speed, and, of course, attached monitor, Wireless adapter, keyboard and touch-pad, 16GB SSD, and last but not least, battery! How cool is that? <a class="simple-footnote" title="It just lacks the GPIO pins, so as long as you are mainly into software (algorithms, etc.) and not hardware (robotics, etc.), it just works perfectly!" id="return-note-38-7" href="#note-38-7"><sup>7</sup></a> <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":-D" class="wp-smiley" /> Oh, by the way, Fedoraians also have <a href="http://fedoraproject.org/wiki/Architectures/ARM/Samsung_Chromebook_2012" title="Architectures/ARM/Samsung Chromebook 2012 - Fedora Project">this page</a> in their wiki about Chromebook.<br />
<a href="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/Screenshot-03192013-073859-AM.png"><img src="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/Screenshot-03192013-073859-AM-625x351.png" alt="Fedora 18 on the ARM Chromebook" width="625" height="351" class="aligncenter size-medium wp-image-40" /></a><br />
I&#8217;ll try getting Gnome-Shell on it. There shouldn&#8217;t be any problems: the ARM package is available, we have enough RAM, what else do we need?</p>
<p>Okay, I think that&#8217;s pretty much it. <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
<p>hope you are well,<br />
Love,<br />
M</p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-38-1">although I refuse to believe that they haven&#8217;t silently worked on any such projects before! <a href="#return-note-38-1">&#8617;</a></li><li id="note-38-2">and that&#8217;s probably why most other companies suck! <a href="#return-note-38-2">&#8617;</a></li><li id="note-38-3"><a href="http://mjg59.dreamwidth.org/22465.html" title="Don't like Secure Boot? Don't buy a Chromebook">Matthew Garrett</a> believes nobody should be forced to make that choice, and I ought to agree. <a href="#return-note-38-3">&#8617;</a></li><li id="note-38-4">Again, as I&#8217;ve told you before, one out of many superpowers of hackers is that they know WHEN and HOW to get help when they need it, that&#8217;s why they can get what they want from any kind of shell. Anyway &#8230; <a href="#return-note-38-4">&#8617;</a></li><li id="note-38-5">Now, don&#8217;t tell me that you don&#8217;t like this distro, a true Linuxer can manage through any distro what so ever! <a href="#return-note-38-5">&#8617;</a></li><li id="note-38-6">At the time I&#8217;m drafting this post, Google has decided that they will murder Google Reader by the end of July :'( Pray to WWW Gods that they change their mind! <a href="#return-note-38-6">&#8617;</a></li><li id="note-38-7">It just lacks the GPIO pins, so as long as you are mainly into software (algorithms, etc.) and not hardware (robotics, etc.), it just works perfectly! <a href="#return-note-38-7">&#8617;</a></li></ol></div>]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/03/google-chromebook-chrome-os-chromium-or-fedora-linux-whatever/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2013/03/google-chromebook-chrome-os-chromium-or-fedora-linux-whatever/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Restarting GNOME Shell using Terminal, or How to use SIGHUP]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/restarting-gnome-shell-terminal-or-sighup/" />
		<id>http://algorithms.ir/~mahrud/blog/?p=27</id>
		<updated>2013-01-21T03:49:10Z</updated>
		<published>2012-12-22T14:09:09Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="gnome-shell" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="kill" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="SIGHUP" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="terminal" />		<summary type="html"><![CDATA[Recently I&#8217;ve been using my laptop for some heavy processing and as a result of that GNOME Shell started to freeze every now and then. Normally when something goes wrong I try &#8220;alt+f2&#8221; and then &#8220;r&#8221; which is a shortcut to restart the GNOME Shell, but when it freezes you can only use your mouse [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/restarting-gnome-shell-terminal-or-sighup/"><![CDATA[<p>Recently I&#8217;ve been using my laptop for some heavy processing and as a result of that GNOME Shell started to freeze every now and then.<br />
Normally when something goes wrong I try &#8220;<strong>alt+f2</strong>&#8221; and then &#8220;<strong>r</strong>&#8221; which is a shortcut to restart the GNOME Shell, but when it freezes you can only use your mouse &#8230; and go to other terminals!</p>
<p>I&#8217;m talking about TTYs, one of the most wonderful features of Unix based operating systems, IMO. It is simply fascinating that you can use one set of mouse/keyboard/monitor to login with more than one user at the same time.</p>
<p>Back to the GNOME Shell problem. The solution is simple: send a signal to whatever process that is causing the problem. If it&#8217;s flash player or a game just kill it with <strong>SIGKILL</strong> or pause it with <strong>SIGSTOP</strong>, but as far as I know, many Linux services recognize the <strong>SIGHUP</strong> (signal code=1), including GNOME Shell. You can use `kill` or `killall` command to send this signal to programs like this:</p>
<pre class="brush: plain; title: ; notranslate"># kill -s SIGHUP [pid]
# killall -s SIGHUP [process name]</pre>
<p>Here is the description of the signal according to the manual page of signal in section 7:</p>
<pre>       Signal     Value     Action   Comment
       ──────────────────────────────────────────────────────────────────────
       SIGHUP        1       Term    Hangup detected on controlling terminal
                                     or death of controlling process</pre>
<p>Basically this signal is just poking the process and giving the information with no predefined action (whereas SIGKILL kills the program no matter what), so it&#8217;s up to the programmer to define a procedure to be executed in case of receiving that signal.</p>
<p>Fortunately for me, GNOME developers have been kind enough to implement such a procedure that just reboots GNOME Shell without closing child processes (which include all graphical programs!), just as &#8220;alt+f2&#8243; &#8220;r&#8221; does.</p>
<p>That&#8217;s it, just don&#8217;t kill Linux services, poke them with SIGHUP! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /></p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/restarting-gnome-shell-terminal-or-sighup/#comments" thr:count="3"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/restarting-gnome-shell-terminal-or-sighup/feed/atom/" thr:count="3"/>
		<thr:total>3</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Android Lockdown, or How to Find the Inner Linux!]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/android-lockdown-or-how-to-find-the-inner-linux/" />
		<id>http://algorithms.ir/~mahrud/blog/?p=26</id>
		<updated>2013-01-21T03:54:22Z</updated>
		<published>2012-12-21T11:12:00Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Android" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="The Inner Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="/efs" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Android Debug Bridge (adb)" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="ip route" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="iptables" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="iw" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="wpa_supplicant" />		<summary type="html"><![CDATA[What a year! After more than one year, this blog is still alive! &#8220;They besought him of how canst one become so fullsome [as him] in the midst of rude men; `Dost as they dost not!`, he sweren&#8221; That&#8217;s it for now &#8230; [to all the people who are reading this directly, through a feed, [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/android-lockdown-or-how-to-find-the-inner-linux/"><![CDATA[<p>What a year! After more than one year, this blog is still alive!</p>
<p>&#8220;They besought him of how canst one become so fullsome [as him] in the midst of rude men; `Dost as they dost not!`, he sweren&#8221;</p>
<p>That&#8217;s it for now &#8230;</p>
<hr />
<p><strong>[to all the people who are reading this directly, through a feed, through Fedora Planet, through Fedora Planed feed, etc.]</strong><br />
&#8211; Hellow! How do you do?</p>
<p><strong>[to anybody who is listening out there!]</strong><br />
&#8211; Greetings from planet earth!</p>
<p>When I first bought my Android Samsung Exhibit II smartphone I was mostly interested in working with Android as an embedded Linux operation system and perhaps doing some projects on it; but the Android Debugging Bridge (<strong>ADB</strong>) shell wasn&#8217;t really comfortable and more or less convinced me that it&#8217;s not really meant to be used that way. Plus I really don&#8217;t like Java so I just forgot about the Linux inside.</p>
<p>[Almost] Everything was going smoothly until a few days ago  <a class="simple-footnote" title="well, actually 6 months ago when I drafted this post!" id="return-note-21-1" href="#note-21-1"><sup>1</sup></a> I got locked out of my phone. Android asks for the connected Google account credentials if someone forgot the gesture code or if someone entered too many wrong codes. The problem is that I had disabled data connection since I don&#8217;t have data service, and moreover, I had turned off wifi in order to to preserve battery that morning; so there is no internet access and thus Android could not verify my username and password with Google! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_sad.gif" alt=":(" class="wp-smiley" />  <a class="simple-footnote" title="Do I really need to mention that I couldn&#8217;t enable any of those while in lockout? Give me some credit, man!" id="return-note-21-2" href="#note-21-2"><sup>2</sup></a></p>
<p><a href="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/android-lockdown.png"><img src="http://www.ocf.berkeley.edu/~mahrud/blog/wp-content/uploads/android-lockdown-375x625.png" alt="Android Lockdown" width="375" height="625" class="aligncenter size-medium wp-image-25" /></a></p>
<p>My first reaction was to try some special codes such as blank password or 0000, but soon I realized that nothing could be done from outside and the only way was to hack into my phone! Luckily for me, I had left the USB debugging option enabled since I initially tried adb, so getting a shell was as easy as connecting to my phone and running adb.</p>
<p>Since my knowledge of Android internals wasn&#8217;t any further than the fact that it&#8217;s Linux based, I had no idea of the security methods, controlling the device, etc.. I&#8217;m not complaining because I believe that is exactly what makes hacking fun  <a class="simple-footnote" title="just to clarify: hacking equals curiosity, IMO." id="return-note-21-3" href="#note-21-3"><sup>3</sup></a></p>
<p>These are my main ideas on how to work around the problem:</p>
<h3>1- Enable the wireless (`iw`, `wpa_supplicant`, etc.)</h3>
<p>[Too long, didn&#8217;t write!] Didn&#8217;t work! I had used `<strong>iw</strong>` and `<strong>wpa_supplicant</strong>` to connect a WRT54GL Linksys wireless router (with <strong>OpenWRT</strong> installed on it) to another wireless network (yes, client mode!) before, but Android doesn&#8217;t have `iw` on it and apparently `wpa_supplicant` couldn&#8217;t initiate the connection appropriately.<br />
For more information about `iw` (even though Android doesn&#8217;t have it, almost all distros do) and `wpa_supplicant` <strong>R</strong>efer to <strong>T</strong>he <strong>R</strong>espective <strong>M</strong>anuals.  <a class="simple-footnote" title="aka. RTRM :-p I&#8217;m gonna start a &#8220;respect the manual&#8221; movement someday &#8230; ya&#8217;ll see &#8230;" id="return-note-21-4" href="#note-21-4"><sup>4</sup></a><br />
In short, the cool thing about `iw` is that you can perform network level AND hardware level operations with it, kinda like `<strong>ip</strong>` but for wireless devices. A few of useful commands that I use sometimes are:</p>
<pre class="brush: plain; title: ; notranslate">$ iw list	# list physical devices
# iw dev &lt;devname&gt; scan [-u] [freq &lt;freq&gt;*] [ies &lt;hex as 00:11:..&gt;] [ssid &lt;ssid&gt;*|passive]	# scan for wireless networks, just look at all those data! Ain't it fascinating? <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" />
# iw dev &lt;devname&gt; connect [-w] &lt;SSID&gt; [&lt;freq in MHz&gt;] [&lt;bssid&gt;] [key 0:abcde d:1:6162636465]
# iw dev &lt;devname&gt; disconnect</pre>
<h3>2- Connect my phone to internet using my laptop as a gateway (`iptables`, `ip route`, etc.)</h3>
<p>The idea is simple, I&#8217;m sure lot&#8217;s of you have tried to share internet between two systems at one point before; could be a virtual machine, an embedded system, a PC without wifi card, or getting internet from your 3G phone! As a matter of fact I did succeed to do so with my Android phone, but for some reason the lock didn&#8217;t let me in; I could ping Google from the shell, but perhaps the applications can only access internet through predefined ways (wifi and 3G)</p>
<p>For more information refer to `iptables` and `ip` manual pages. I found <a href="http://interlockroc.org/2012/12/06/raspberry-pi-macgyver/" title="Interlock Rochester -- Raspberry Pi-ing, MacGyver Style">this link</a> <a class="simple-footnote" title="I&#8217;ve just bought a Raspberry Pi and I did pretty much the same thing, in terminal! I&#8217;ll write about it soon" id="return-note-21-5" href="#note-21-5"><sup>5</sup></a> to be very informative, even though the purpose is different and it&#8217;s mainly graphical, it&#8217;s for the same cause. `ip` and `iptables` are two network related commands that you must know how to work with! Some basic examples:</p>
<pre class="brush: plain; title: ; notranslate"># iptables -L -n	# shows current firewall setting
# iptables -L -t nat -n	# shows current NAT setting

$ ip route	# or `ip r`, same thing. shows the routing table.
# ip r del default
# ip r add default via [gateway] dev [devname]</pre>
<h3>3- Break the lock (resetting the lock, etc.)</h3>
<p>Honestly, I didn&#8217;t expect this one to work! I mean, seriously, it shouldn&#8217;t be so easy to break the lock! But it worked!</p>
<pre class="brush: plain; title: ; notranslate">[root@eve ~]# adb shell
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
# id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),3001(net_bt_admin),3002(net_bt),3003(inet)
# ls
efs
...
# ls /efs
cryptprop_FailedAttempts
cryptprop_persist.sys.timezone
cryptprop_onetimeboot
cryptprop_securewipedata
cryptprop_lock_pattern_autolock
cryptprop_lock_pattern_tactile_feedback_enabled
dmp
cryptprop_lockscreen.password_type
cryptprop_persist.sys.language
cryptprop_rebootMode
cryptprop_lockscreen.lockoutattemptdeadline
edk_p
lost+found
cryptprop_lock_pattern_visible_pattern
cryptprop_essiv
cryptprop_lockscreen.patterneverchosen
cryptprop_applied_result
cryptprop_efs
# mount
...
/dev/block/mmcblk0p27 /efs ext4 rw,relatime,barrier=1,data=writeback 0 0
...
# umount /efs
# </pre>
<p><strong>DONE</strong>! The lock is gone! And I wasn&#8217;t even root! Apparently /efs is where Android stores many of it&#8217;s important properties files, many of which are readable only by root, but anybody can unmount it! This is certainly a security flaw that I&#8217;m sure it fixed in the newer versions of Android (mine is Gingerbread 2.3).</p>
<p><strong>
<p><span style="color:red">Conclusion:</span> But the point of this post wasn&#8217;t just to reveal a security flaw after 6 months! The point was to show you that at the end of the day, Linux does as Linux does, no matter what the distribution is or what kind of cpu architecture is running it. I learned things from my phone that became useful later while working with servers! Again, Linux does as Linux does; just find the inner shell, and you&#8217;re all set. Maybe you&#8217;ll only need to enable usb debugging on Android, or perhaps you&#8217;ll have to open up your Amazon Kindle and connect a serial port to a secret port, but in the end, you will feel as if you&#8217;re working with your own system, you&#8217;ll feel like home. <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /></p>
<p></strong></p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-21-1">well, actually 6 months ago when I drafted this post! <a href="#return-note-21-1">&#8617;</a></li><li id="note-21-2">Do I really need to mention that I couldn&#8217;t enable any of those while in lockout? Give me some credit, man! <a href="#return-note-21-2">&#8617;</a></li><li id="note-21-3">just to clarify: hacking equals curiosity, IMO. <a href="#return-note-21-3">&#8617;</a></li><li id="note-21-4">aka. <strong>RTRM</strong> :-p I&#8217;m gonna start a &#8220;respect the manual&#8221; movement someday &#8230; ya&#8217;ll see &#8230; <a href="#return-note-21-4">&#8617;</a></li><li id="note-21-5">I&#8217;ve just bought a Raspberry Pi and I did pretty much the same thing, in terminal! I&#8217;ll write about it soon <a href="#return-note-21-5">&#8617;</a></li></ol></div>]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/android-lockdown-or-how-to-find-the-inner-linux/#comments" thr:count="7"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/12/android-lockdown-or-how-to-find-the-inner-linux/feed/atom/" thr:count="7"/>
		<thr:total>7</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[John Nash’s Letter to the NSA]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/02/john-nashs-letter-to-the-nsa/" />
		<id>/~mahrud/blog/?p=19</id>
		<updated>2012-08-12T10:40:35Z</updated>
		<published>2012-02-23T19:48:35Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cryptography" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="History" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="John Nash" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="NSA" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Ron Rivest" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="The Beautiful Mind" />		<summary type="html"><![CDATA[If you have watched A Beautiful Mind you probably remember John Nash, the genius mathematics professor at Princeton University. Recently a series of quite interesting letters from him to NSA has been declassified, although the letters might not be very interesting for many of you (plus, his handwriting is really bad!), but here is a [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2012/02/john-nashs-letter-to-the-nsa/"><![CDATA[<p>If you have watched <a href="http://en.wikipedia.org/wiki/A_Beautiful_Mind_(film)">A Beautiful Mind</a> you probably remember John Nash, the genius mathematics professor at Princeton University. Recently a series of quite interesting letters from him to NSA has been declassified, although the letters might not be very interesting for many of you (plus, his handwriting is really bad!), but here is a short overview of the subject is you find it interesting.</p>
<p>Respectfully re-blogged from <a href="http://agtb.wordpress.com/2012/02/17/john-nashs-letter-to-the-nsa/">Noam Nisan&#8217;s post</a>:</p>
<p>The <a href="http://en.wikipedia.org/wiki/National_Security_Agency"><strong>National Security Agency</strong> (<strong>NSA</strong>)</a> has recently <a href="http://www.nsa.gov/public_info/press_room/2012/nash_exhibit.shtml">declassified</a> an <a href="http://www.nsa.gov/public_info/_files/nash_letters/nash_letters1.pdf">amazing letter</a> that <a href="http://en.wikipedia.org/wiki/John_Forbes_Nash,_Jr.">John Nash</a> sent to it in 1955.  It seems that around the year 1950 Nash tried to interest some US security organs (the NSA itself was only formally formed only in 1952) in an encryption machine of his design, but they did not seem to be interested.  It is not clear whether some of his material was lost, whether they ignored him as a theoretical professor, or — who knows — used some of his stuff but did not tell him.  In this hand-written letter sent by John Nash to the NSA in 1955, he tries to give a higher-level point of view supporting his design:</p>
<blockquote><p>In this letter I make some remarks on a general principle relevant to enciphering in general and to my machine in particular.</p></blockquote>
<p>He tries to make sure that he will be taken seriously:</p>
<blockquote><p>I hope my handwriting, etc. do not give the impression I am just a crank or circle-squarer.  My position here is Assist. Prof. of Math.  My best known work is in game theory (reprint sent separately).</p></blockquote>
<p>He then goes on to put forward an amazingly prescient analysis anticipating computational complexity theory as well as modern cryptography.  In the letter, Nash takes a step beyond <a href="http://en.wikipedia.org/wiki/Communication_Theory_of_Secrecy_Systems">Shannon’s information-theoretic formalization of cryptography</a> (without mentioning it) and proposes that security of encryption be based on computational hardness — this is exactly the transformation to <a href="http://en.wikipedia.org/wiki/History_of_cryptography#Modern_cryptography">modern cryptography</a> made two decades later by the rest of the world (at least publicly…).  He then goes on to explicitly focus on the distinction between polynomial time and exponential time computation, a crucial distinction which is the basis of <a href="http://en.wikipedia.org/wiki/Computational_complexity_theory">computational complexity theory</a>, but made only <a href="http://people.cs.uchicago.edu/~fortnow/papers/history.pdf">about a decade later</a> by the rest of the world:</p>
<blockquote><p>So a logical way to classify enciphering processes is by t he way in which the computation length for the computation of the key increases with increasing length of the key. This is at best exponential and at worst probably at most a relatively small power of r, <img title="ar^2" src="http://s0.wp.com/latex.php?latex=ar%5E2&amp;bg=000000&amp;fg=B9BDB6&amp;s=0" alt="ar^2" /> or <img title="ar^3" src="http://s0.wp.com/latex.php?latex=ar%5E3&amp;bg=000000&amp;fg=B9BDB6&amp;s=0" alt="ar^3" />, as in substitution ciphers.</p></blockquote>
<p>He conjectures the security of a family of encryption schemes.  While not totally specific here, in today’s words he is probably conjecturing that almost all cipher functions (from some — not totally clear — class) are <a href="http://en.wikipedia.org/wiki/One-way_function">one-way</a>:</p>
<blockquote><p>Now my general conjecture is as follows: for almost all sufficiently complex types of enciphering, especially where the instructions given by different portions of the key interact complexly with each other in the determination of their ultimate effects on the enciphering, the mean key computation length increases exponentially with the length of the key, or in other words, the information content of the key.</p></blockquote>
<p>He is very well aware of the importance of this “conjecture” and that it implies an end to the game played between code-designers and code-breakers throughout history.  Indeed, this is exactly the point of view of modern cryptography.</p>
<blockquote><p>The significance of this general conjecture, assuming its truth, is easy to see.  It means that it is quite feasible to design ciphers that are effectively unbreakable.  As ciphers become more sophisticated the game of cipher breaking by skilled teams, etc., should become a thing of the past.</p></blockquote>
<p>He is very well aware that this is a conjecture and that he cannot prove it.  Surprisingly, for a mathematician, he does not even expect it to be solved.  Even more surprisingly he seems quite comfortable designing his encryption system based on this unproven conjecture.  This is quite eerily what modern cryptography does to this day: conjecture that some problem is computationally hard; not expect anyone to prove it; and yet base their cryptography on this unproven assumption.</p>
<blockquote><p>The nature of this conjecture is such that I cannot prove it, even for a special type of ciphers.  Nor do I expect it to be proven.</p></blockquote>
<p>All in all, the letter anticipates computational complexity theory by a decade and modern cryptography by two decades.  Not bad for someone whose “best known work is in game theory”.  It is hard not to compare this letter to <a href="http://rjlipton.wordpress.com/the-gdel-letter/">Goedel’s famous 1956 letter to von Neumann</a> also anticipating complexity theory (but not cryptography).  That both Nash and Goedel passed through Princeton may imply that these ideas were somehow “in the air” there.</p>
<p>ht: this declassified letter seems to have been picked up by <a href="http://en.wikipedia.org/wiki/Ron_Rivest">Ron Rivest</a> who posted it on his <a href="http://courses.csail.mit.edu/6.857/2012/">course’s web-site</a>, and was then blogged about (and G+ed) by <a href="http://aaronsadventures.blogspot.com/2012/02/amazing-new-declassified-document.html">Aaron Roth</a>.</p>
<p>Edit: Ron Rivest has <a href="http://courses.csail.mit.edu/6.857/2012/files/nash.py">implemented Nash’s cryptosystem in Python</a>.  I wonder whether modern cryptanalysis would be able to break it.</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/02/john-nashs-letter-to-the-nsa/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2012/02/john-nashs-letter-to-the-nsa/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[The Genius Who Made it Simple]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/10/the-genius-who-made-it-simple/" />
		<id>/~mahrud/blog/?p=17</id>
		<updated>2012-08-12T11:04:24Z</updated>
		<published>2011-10-13T18:43:34Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Uncategorized" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="C Programming Language" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Dennis Ritchie" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="RIP" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Unix" />		<summary type="html"><![CDATA[Today marks the passing of the pioneer of C and Unix, Dennis Ritchie, the R in K&#38;R. I personally compare his innovation to language. Because both of them gave us the ability to communicate with another creature: humans, and computers. Without him and his partner, programming would be as hard as Electrical Engineering. He is [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2011/10/the-genius-who-made-it-simple/"><![CDATA[<div style="width: 365px" class="wp-caption alignleft"><img title="Dennis MacAlistair Ritchie" src="http://www.adeptis.ru/vinci/dennis_ritchie6.jpg" alt="Dennis MacAlistair Ritchie" width="355" height="342" /><p class="wp-caption-text">Dennis M. Ritchie</p></div>
<p>Today marks the passing of the pioneer of C and Unix, Dennis Ritchie, the R in K&amp;R. I personally compare his innovation to language. Because both of them gave us the ability to communicate with another creature: humans, and computers. Without him and his partner, programming would be as hard as Electrical Engineering. He is a prophet among computer scientists <a class="simple-footnote" title="if not a God, of course!" id="return-note-17-1" href="#note-17-1"><sup>1</sup></a>.</p>
<p style="text-align: center;"><strong>Rest in Peace, Dennis Ritchie<br />
1941 &#8211; 2011</strong></p>
<pre class="brush: cpp; title: ; notranslate">// A farewell to Dennis Ritchie, in his own language
#include &lt;stdio.h&gt;

int main()
{
	printf(&quot;Goodbye, World!\n&quot;);
	return 0;
}</pre>
<p>P.S: one of my favourite quotes about computers and specially Unix, is this: &#8220;UNIX is very simple, it just needs a genius to understand its simplicity.&#8221;. I believe in it, it&#8217;s so simple.</p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-17-1">if not a God, of course! <a href="#return-note-17-1">&#8617;</a></li></ol></div>]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/10/the-genius-who-made-it-simple/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/10/the-genius-who-made-it-simple/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Introduction to Systemd]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/introduction-systemd/" />
		<id>/~mahrud/blog/?p=16</id>
		<updated>2012-08-09T18:41:31Z</updated>
		<published>2011-08-31T18:40:07Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Uncategorized" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="autologin to console" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Fedora 15" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Fedora Project" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="infrastructure team" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="systemd" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="tty" />		<summary type="html"><![CDATA[Two weeks ago I was curious about how can I participate in Fedora project, and now, this is my first post on Planet Fedora! Yay! There are few ways to participate in fedora, like release engineering, packaging, infrastructure, documentation, etc., and I started with infrastructure! The Infrastructure team consists of dedicated volunteers and professionals managing [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/introduction-systemd/"><![CDATA[<p>Two weeks ago I was curious about how can I participate in Fedora project, and now, this is my first post on Planet Fedora! Yay! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /> There are <a title="Fedora Sub-Projects For Contributors" href="https://fedoraproject.org/wiki/Fedora_Project_Wiki#Fedora_Sub-Projects_For_Contributors">few ways</a> to participate in fedora, like release engineering, packaging, infrastructure, documentation, etc., and I started with <a title="Infrastructure - FedoraProject" href="https://fedoraproject.org/wiki/Infrastructure">infrastructure</a>!</p>
<blockquote><p>The Infrastructure team consists of dedicated volunteers and professionals managing the servers, building the tools and utilities, and creating new applications to make Fedora development a smoother process. We&#8217;re located all over the globe and communicate primarily by IRC and e-mail.</p></blockquote>
<p>In simple worlds, &#8220;We run the servers that run fedora!&#8221;. Currently I&#8217;m in fedora infrastructure apprentices group, with non-root access on many fedora servers around world, but the best part, is to be in a professional community <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /></p>
<hr />
<p>ok, that&#8217;s enough. This post is about systemd. Why am I interested in it? because I use fedora15 which is the first distribution with systemd feature enabled by default. First of all, what is systemd?</p>
<blockquote><p>systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux cgroups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. It can work as a drop-in replacement for sysvinit. (From <a title="systemd, Beyond init by Lennart Poetteing - FOSDEM 2011" href="http://www.youtube.com/watch?v=TyMLi8QF6sw">this</a> presentation)</p></blockquote>
<p>For myself, first time I saw it&#8217;s name it was in <code>/etc/inittab</code> file:</p>
<pre class="brush: plain; title: ; notranslate"># inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To set a default target, run:
# ln -s /lib/systemd/system/&amp;amp;lt;target name&amp;amp;gt;.target /etc/systemd/system/default.target</pre>
<p>sysvinit looks the <code>/etc/inittab</code> file for runlevel and virtual console configurations, but in systemd, as you can see in the code above, we have targets and virtual consoles (ttys) are considered as services, just like other service and daemons. Each service is a file located in <code>/lib/systemd/system</code> or <code>/etc/systemd/system</code>. To get in touch with systemd, try <code>systemctl</code> and read <code>systemd*</code> manuals.</p>
<p>I think there are enough information and manuals on the net, like <a title="systemd Documentation" href="http://0pointer.de/blog/projects/systemd-docs.html">these</a>, <a title="systemd Tips &amp; Tricks" href="http://www.freedesktop.org/wiki/Software/systemd/TipsAndTricks">this</a> or <a title="systemd @ FedoraProject.org wiki" href="http://fedoraproject.org/wiki/Systemd">this</a>, but one thing is missing in all of them &#8230; how to setup autologin on a virtual console with systemd? Here it comes as an example for systemd services:</p>
<h3>Autologin to virtual console terminals (tty) at startup</h3>
<p>In sysvinit structure, setting autologin was as easy as editing one line of inittab file, but now we need to add a service, so we can have more control:</p>
<pre class="brush: plain; title: ; notranslate"># cp /lib/systemd/system/getty@.service \
     /etc/systemd/system/autologin@.service
# ln -s /etc/systemd/system/autologin@.service \
        /etc/systemd/system/getty.target.wants/getty@tty8.service</pre>
<p>then edit ExecStart, Restart and Alias values, like this:</p>
<pre class="brush: plain; title: ; notranslate">...
ExecStart=-/sbin/mingetty --autologin USERNAME %I
Restart=no
...
Alias=getty.target.wants/getty@tty8.service</pre>
<p>and then:</p>
<pre class="brush: plain; title: ; notranslate"># systemctl daemon-reload
# systemctl start getty@tty8.service</pre>
<p>Now press <code>Ctrl-Alt-F8</code>, and you should see the console waiting for you commands ;-). Note that if you exit tty8 session, you wont be able to use it until next reboot or manual start by <code>systemctl</code>, except if you leave Restart as &#8216;always&#8217;, but I highly recommend to avoid this according to security reasons.</p>
<p><strong><span style="color: #ff0000;">UPDATE</span></strong>: I was wondering what&#8217;s difference between /etc/systemd/system and /lib/systemd/system and hbt said &#8220;Everything in /lib is yum-territorium whereas /etc is admin-stuff&#8221;, so I&#8217;ve changed the commands above (autologin@.service moved from /lib to /etc, and getty@tty8.service must be updated).</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/introduction-systemd/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/introduction-systemd/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Project: HelliJudge]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/project-hellijudge/" />
		<id>/~mahrud/blog/?p=15</id>
		<updated>2014-10-16T01:06:20Z</updated>
		<published>2011-08-13T18:36:57Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Projects" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="chroot" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="jail" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Judge" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="PAM" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="pam_chroot" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="pam_limits" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="prevent fork bomb" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="prevent zombie process" />		<summary type="html"><![CDATA[About two months ago Hamed Saleh and I have started a project to write a judge system named HelliJudge: The system can compile and execute codes, and test them with pre-constructed data. Submitted code may be run with restrictions, including time limit, memory limit, security restriction and so on. The output of the code will [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/project-hellijudge/"><![CDATA[<p>About two months ago Hamed Saleh and I have started a project to write a judge system named <a title="Git reposetory of HelliJudge project" href="http://hellicode.allamehelli.ir/git/?p=hellijudge.git">HelliJudge</a>:</p>
<blockquote><p>The system can compile and execute codes, and test them with pre-constructed data. Submitted code may be run with restrictions, including time limit, memory limit, security restriction and so on. The output of the code will be captured by the system, and compared with the standard output. The system will then return the result. (from <a title="Online judge - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Online_judge">Wikipedia</a>)</p></blockquote>
<p>In this project I faced many problems, and learned much more things like <a title="Coprocesses - Bash Reference Manual" href="http://www.gnu.org/s/bash/manual/html_node/Coprocesses.html">co-process,</a> <a title="Linux PAM - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Linux_PAM">PAM</a>, some <a title="Network address translation - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Network_address_translation">NAT</a> solutions, jailing (and some jailbreak techniques), many bash techniques, git and few other things.</p>
<p>Our system is based on the <a title="Principle of least privilege - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Principle_of_least_privilege">principle of least privilege</a>. In simple words, we compile the code in a jailed environment with minimum needed libraries available for compiler, then run it in the same environment with hard limits on memory and number of threads with no write access &#8212; except for stdout and stderr. FYI, monitoring total time, memory and return code of user binary is what <strong>time </strong>does (note that gnu time is different from bash time, the gnu one only can be accessed with absolute path: <strong>/usr/bin/time</strong>).</p>
<p>The jailed area, which is available on <a title="Git reposetory of our jail" href="http://hellicode.allamehelli.ir/git/?p=hellijudge-jail.git">its git repository</a>, contains only gcc, gcc-c++, cpp, some needed libraries, bash and their requirements. Compile scripts (like <a href="http://hellicode.allamehelli.ir/git/?p=hellijudge-jail.git;a=blob;f=bin/compilers/cpp.sh;h=9cfb77f135b650906c960780386154256b9930c9;hb=HEAD">this</a>) are also included in the jail (actually this is the reason we need bash in the jailed zone).</p>
<p>Jail system used to be based on <strong>chroot</strong>, but for some issues we switched to <strong>pam_chroot</strong> (which is in PAM package in fedora). This module makes it easy to set a root directory for users and groups by editing <strong>/etc/security/chroot.conf</strong>. This is an example of the file:</p>
<pre class="brush: plain; title: ; notranslate"># /etc/security/chroot.conf
# format:
# username_regex    chroot_dir
#matthew        /home

judge        /mnt/jail</pre>
<p>PAM is also used as limit system! We used <strong>pam_limits</strong> module to limit maximum thread count (in order to prevent <a title="Fork bomb - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Fork_bomb">fork bomb</a> and <a title="Zombie process - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Zombie_process">zombie process</a> attack) and limit maximum memory by editing <strong>/etc/security/limits.conf</strong>. Here is an example of the file:</p>
<pre class="brush: plain; title: ; notranslate"># /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#
#
#Where:
# can be:
#        - an user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
# can have the two values:
#        - &quot;soft&quot; for enforcing the soft limits
#        - &quot;hard&quot; for enforcing hard limits
#
# can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

judge            hard    core            0
judge            hard    nproc           1
judge            hard    as              524288

# End of file</pre>
<p>We limited total time using <strong>timeout</strong> command.</p>
<p>In order to apply the limitations described below, we made a &#8220;judge&#8221; user, added him to <strong>chroot.conf</strong> and <strong>limits.conf</strong> (as you can see in the examples above, yes, they are really being used in our server), and then added these lines to <strong>/etc/pam.d/su</strong>:</p>
<pre class="brush: plain; title: ; notranslate">session     required    pam_limits.so
session     required    pam_chroot.so</pre>
<p><strong><span style="color: #ff0000;">Note</span><span style="color: #ff0000;">:</span></strong> the order of lines in PAM configuration files is important. <strong>pam_chroot.so</strong> should come at the end.</p>
<p>Now if you use &#8220;<strong>su</strong>&#8221; to run a command as user &#8220;judge&#8221;, these limits will be applied to session. For example the following command will run a.out with these limits (note that a.out is in root folder of jailed area):</p>
<pre class="brush: plain; title: ; notranslate"># su judge --session-command /a.out</pre>
<p>Currently <del>just</del> <a title="HelliCode: Allamehelli highschool online contester" href="http://hellicode.allamehelli.ir">HelliCode</a> (see the update) uses our system, which is actually another project of Mohammad Reza Maleki and us <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /> We would be glad if you test our system&#8217;s security at HelliCode.</p>
<p>P.S: As there isn&#8217;t much documentation available for co-processes, I&#8217;ll mention it asap.</p>
<p><span style="color: #ff0000;"><strong>UPDATE:</strong></span> Yay! A new server is going to use our judge! <a title="Algorithms.ir" href="http://algorithms.ir">Algorithms.ir</a> is a computer algorithm education and contest website by Mr. Andjedani in Algorithms and Problem Solving Laboratory in Department of Computer Science at Sharif University of Technology.</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/project-hellijudge/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/08/project-hellijudge/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[To Kill or Not to Kill, this is the answer!]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/to-kill-or-not-to-kill-this-is-the-answer/" />
		<id>/~mahrud/blog/?p=14</id>
		<updated>2012-08-09T11:35:02Z</updated>
		<published>2011-02-25T12:34:06Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Inter-process communication" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="kill" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="POSIX" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="RTFM" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Signal" />		<summary type="html"><![CDATA[Kill! Is it just a command to terminate a process? I don&#8217;t think so &#8230; . Actually the word &#8220;kill&#8221; is a real misnomer for this command, as it&#8217;s main job is to send signals to processes. then, what the hell is signal? A signal is a limited form of inter-process communication used in Unix, [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/to-kill-or-not-to-kill-this-is-the-answer/"><![CDATA[<p><strong>Kill!</strong> Is it just a command to terminate a process? I don&#8217;t think so &#8230; . Actually the word &#8220;kill&#8221; is a real misnomer for this command, as it&#8217;s main job is to send signals to processes. then, what the hell is signal?</p>
<blockquote><p>A signal is a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. Essentially it is an asynchronous notification sent to a process in order to notify it of an event that occurred. [&#8230;] If the process has previously registered a signal handler, that routine is executed. Otherwise the default signal handler is executed. (from <a title="Signal (computing) - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Signal_%28computing%29">Wikipedia</a>)</p></blockquote>
<p>I&#8217;m going to mention few things about the kill command and few useful signals in this post.</p>
<h4>KILL</h4>
<p>In POSIX-compliant operating systems (such as Linux, *BSD, Solaris, etc.) kill command is used to send a signal to one or more processes. If no signal is specified in command line, the default signal is send, which is SIGTERM. This signal terminates the process but it can do some backup operations such as saving log or writing final changes to an open file, according to the signal handler in the process; If no handler is specified, then the default routine will be executed and the process terminates.<br />
<strong>Note added later</strong>: Did you ever seen a process that you want to terminate it, but it doesn&#8217;t? Maybe the process has a kind of signal handler that is taking time to finish. You can force it using SIGQUIT.</p>
<p>But this was only one of 64 signals available (at least on my system! I&#8217;m sure that not all Unix-based operating systems are as same as mine!). Let&#8217;s take a look at list of signals:</p>
<pre class="brush: plain; title: ; notranslate">[mahrud@eve ~]$ kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8‌) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX</pre>
<p>Note: I&#8217;m sure that there is enough information on each of them at Linux manuals, etc. so <a title="RTFM - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/RTFM">RTFM</a> <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /> . But there are few useful signals in which I&#8217;m interested:</p>
<ul>
<li><strong>SIGSTOP + SIGCONT</strong>: It had happened many times for me that a heavy/buggy process slows down the system, but I don&#8217;t want to interrupt it; These two signals are used to stop a process&#8217;s job and then continue it.</li>
<li><strong>SIGQUIT</strong>: This signal is useful when you want to interrupt the process immediately and to dump memory state, aka <strong><a title="Core dump - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Core_dump">core dump</a></strong> (I&#8217;m interested in how to use &#8216;core dumps&#8217; in debugging, etc., just leave it for later!)<br />
<strong>Note added later</strong>: This signal can be manually sent using <strong>^\</strong> short key (<strong>^</strong> means <strong>Ctrl</strong>! So <strong>^\</strong> is equal to <strong>Ctrl + \</strong>)</li>
<li><strong>Information Signals</strong>: Signals such as: <strong>SIGALRM</strong>, <strong>SIGIO</strong> (<strong>SIGPOLL</strong> for Linux), <strong>SIGTTIN</strong>, <strong>SIGTTOU</strong>, <strong>SIGURG</strong> (at least I think) are used to inform the process about a non-fatal event.</li>
<li><strong>Error Signals</strong>: Signals such as: <strong>SIGHUP</strong>, <strong>SIGILL</strong>, <strong>SIGTRAP</strong>, <strong>SIGBUS</strong>, <strong>SIGFPE</strong>, <strong>SIGSEGV</strong>, <strong>SIGXCPU</strong>, <strong>SIGXFSZ</strong>, <strong>SIGPWR</strong>, <strong>SIGSYS</strong> are all used to terminate the process in case of a fatal error, like <strong>F</strong>loating <strong>P</strong>oint <strong>E</strong>xception (<strong>SIGFPE</strong>), <strong>Seg</strong>mentation <strong>V</strong>iolation (<strong>SIGSEGV</strong>), Power Failure (<strong>SIGPWR</strong>), etc. . look at this example for <strong>SIGFPE</strong>: (there are two terminals, and 7547 is PID of a.out)
<pre class="brush: plain; title: ; notranslate">[mahrud@eve ~]$ kill -s SIGFPE 7547</pre>
<pre class="brush: plain; title: ; notranslate">[mahrud@eve C-CPP]$ ./a.out
Floating point exception (core dumped)
[mahrud@eve C-CPP]$ </pre>
</li>
<li><strong>Reserved Signals</strong>: <strong>SIGUSR1</strong> and <strong>SIGUSR2</strong> are reserved for programmers in order to call/indicate a user-defined routine/event in their program. This is a good idea to communicate between threads of a process or dependent processes (Look at <a title="SIGUSR1 and SIGUSR2 - Wikipedia, the free encyclopedia: Usage" href="http://en.wikipedia.org/wiki/SIGUSR1_and_SIGUSR2#Usage">this</a> for few examples of these user-defined signal handlers).</li>
</ul>
<p><strong>WOW! Isn&#8217;t it great?! Linux kernel (or in general, a Unix-based kernel) is a wonderful and dreamy code that you can do anything in it! I love it! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /></strong></p>
<p>I&#8217;m working on using signal handlers in C++.</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/to-kill-or-not-to-kill-this-is-the-answer/#comments" thr:count="1"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/to-kill-or-not-to-kill-this-is-the-answer/feed/atom/" thr:count="1"/>
		<thr:total>1</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Multiple X Terminals on Multiple X.org Servers]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/multiple-x-terminals-on-multiple-x-org-servers/" />
		<id>/~mahrud/blog/?p=12</id>
		<updated>2012-08-09T11:31:04Z</updated>
		<published>2011-02-04T12:28:56Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="multiple gnome-sessions" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="tty" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="X.org" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="xterm" />		<summary type="html"><![CDATA[Have you ever tried to run multiple gnome sessions or to run multiple GUIs (GNOME, KDE, Xfce, etc.) simultaneously? I&#8217;ve googled many keywords about it, but everywhere people said that the main problem in running multiple X servers simultaneously; But there is an argument to select display in xinit, startx, X, etc. . So there [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/multiple-x-terminals-on-multiple-x-org-servers/"><![CDATA[<p>Have you ever tried to run multiple gnome sessions or to run multiple GUIs (<a title="GNOME Project Homepage - Graphical User Interface" href="http://www.gnome.org/">GNOME</a>, <a title="KDE Project Homepage - Graphical User Interface" href="http://www.kde.org/">KDE</a>, <a title="Xfce Project Homepage - Graphical User Interface" href="http://www.xfce.org/">Xfce</a>, etc.) simultaneously?</p>
<p>I&#8217;ve googled many keywords about it, but everywhere people said that the main problem in running multiple <a title="X.Org Project Homepage - X Window System" href="http://www.x.org/">X servers</a> simultaneously; But there is an argument to select display in xinit, startx, X, etc. . So there must be a way to run multiple X servers, or to use one running X server for multiple GUIs. Finally I found this command on manual page of xinit:</p>
<blockquote><p>$ X :1</p></blockquote>
<p>which runs X server on display #1 (actually I think maybe it creates display #1!). Anyway, this is the first step! Now we have two X servers, not two GUIs!</p>
<p>Next step is to run another gnome-session and force it to use display #1. My first attempt to do so was executing this command:</p>
<blockquote><p>$ X :1 &amp; gnome-session</p></blockquote>
<p>But it didn&#8217;t work :(. I&#8217;ve tried many commands, but none of them worked. After all, I tried this command and it worked:</p>
<blockquote><p>$ startx −− :1</p></blockquote>
<p>also to open a <a title="XTERM Project Homepage - Terminal Emulator for the X Window System" href="http://invisible-island.net/xterm/">X Terminal</a> (xterm) you can use the following command:</p>
<blockquote><p>$ xinit −− :1</p></blockquote>
<p><strong><span style="color: #ff0000;">Note:</span> As you know default GUI is at terminal #1 (tty1) in Fedora Linux and #7 (I&#8217;m not sure) in Ubuntu; So you cannot run these commands in current tty! Use [Ctrl + Alt + F1-n] in order to switch between terminals. Also keep in mind that (at least in Fedora Linux) when you run X server in tty2, you can actually use it in tty7! (I don&#8217;t know exactly why at this time).</strong></p>
<p><strong><span style="color: #ff0000;">UPD: </span>startx runs a gnome-session by default (you can change it from ~/.xinitrc) but it&#8217;s easier to run Xfce or KDE using startxfce4 or startkde.<br />
</strong></p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/multiple-x-terminals-on-multiple-x-org-servers/#comments" thr:count="7"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/02/multiple-x-terminals-on-multiple-x-org-servers/feed/atom/" thr:count="7"/>
		<thr:total>7</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[OpenWrt Experience on WRT54GL]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/01/openwrt-experience-on-wrt54gl/" />
		<id>/~mahrud/blog/?p=11</id>
		<updated>2013-01-11T21:16:03Z</updated>
		<published>2011-01-19T12:24:52Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Network" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Projects" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="The Inner Linux" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cisco" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Linksys" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="OpenWrt" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="WRT54GL" />		<summary type="html"><![CDATA[This week I&#8217;ve got a gift : A Linksys WRT54GL wireless router, which is Linux base! Hooray! First of all, I thought it&#8217;s possible to access the router using ssh or at least telnet; but sadly the only way was web-gui! So I had to use an alternative firmware: OpenWrt. OpenWrt is described as a [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2011/01/openwrt-experience-on-wrt54gl/"><![CDATA[<p>This week I&#8217;ve got a gift <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /> : A Linksys <a title="WRT54GL: Linux base Wireless Router" href="http://www.linksysbycisco.com/EU/en/products/WRT54GL">WRT54GL</a> wireless router, which is Linux base! Hooray!</p>
<p>First of all, I thought it&#8217;s possible to access the router using ssh or at least telnet; but sadly the only way was web-gui! So I had to use an alternative firmware: <a title="OpenWrt: Linux base &amp; Opensource Firmware for Wireless Routers" href="http://www.openwrt.org/">OpenWrt</a>.</p>
<blockquote><p>OpenWrt is described as a Linux distribution for embedded devices.<br />
Instead of trying to create a single, static firmware, OpenWrt provides a fully writable filesystem with package management. This frees you from the application selection and configuration provided by the vendor and allows you to customize the device through the use of packages to suit any application. For developer, OpenWrt is the framework to build an application without having to build a complete firmware around it; for users this means the ability for full customization, to use the device in ways never envisioned. (from OpenWrt homepage)</p></blockquote>
<p>First I read <a title="OpenWrt manual for Linksys WRT54G/L/S" href="http://wiki.openwrt.org/toh/linksys/wrt54gl">this manual</a> for firmware versions and installation guide. I&#8217;ve downloaded and installed <a href="http://downloads.openwrt.org/backfire/10.03.1-rc4/brcm47xx/openwrt-wrt54g-squashfs.bin">openwrt-wrt54g-squashfs.bin</a> firmware image on router using the web-gui firmware upgrade page, and it worked (I don&#8217;t believe it even now!). After reboot, I scanned the router using nmap, only http, dns and telnet ports were open; So I connected to it using telnet (it didn&#8217;t asked for username or password). This is its banner (I really want to know what they mean by lines 17-19 <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /> ) :</p>
<pre class="brush: plain; title: ; notranslate">-[mahrud@eve ~]$ telnet 192.168.1.1
-Trying 192.168.1.1...
-Connected to 192.168.1.1.
-Escape character is '^]'.
- === IMPORTANT ============================
-  Use 'passwd' to set your login password
-  this will disable telnet and enable SSH
- ------------------------------------------
-BusyBox v1.15.3 (2010-11-12 00:01:06 PST) built-in shell (ash)
-Enter 'help' for a list of built-in commands.
-  _______                     ________        __
- |       |.-----.-----.-----.|  |  |  |.----.|  |_
- |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
- |_______||   __|_____|__|__||________||__|  |____|
-          |__| W I R E L E S S   F R E E D O M
- Backfire (10.03.1-rc4, r24045) --------------------
-root@OpenWrt:/# </pre>
<p>So I setted a password for root, exited from telnet and connected using ssh (ssh banner is the same as telnet except first six lines).</p>
<p>Well, I can type hundreds of lines about different parts of system, such as firewall, network &amp; wireless setting, etc. but let me work on them in a better time (maybe two weeks later or something like that!).</p>
<p><strong>TO DO:</strong></p>
<ol>
<li>Extend flash memory of router using an nfs-server</li>
<li>Connect to all types of wireless networks as a client (!) (open, wep and wpa)</li>
<li>Change wlan interface into monitor mode and install aircrack-ng</li>
<li>Work on Serial port (and if possible, connect a MMC/SD card in order to expand internal memory)</li>
<li>Add more stuff to this list <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /></li>
</ol>
<p><strong>P.S:</strong> If I failed to do these things on OpenWrt, I&#8217;ll use <a title="DD-WRT: Linux base &amp; Opensource Firmware for Wireless Routers" href="http://www.dd-wrt.com/site/index">DD-WRT</a> as an alternative way. <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /></p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/01/openwrt-experience-on-wrt54gl/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2011/01/openwrt-experience-on-wrt54gl/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[MTN, Irancell or Huawei? (II)]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/10/mtn-irancell-or-huawei-ii/" />
		<id>/~mahrud/blog/?p=10</id>
		<updated>2012-08-12T10:24:22Z</updated>
		<published>2010-10-29T11:12:19Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Net of Lies" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Network" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Huawei" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="MTN Irancell" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Wimax Network" />		<summary type="html"><![CDATA[So, we are still at the hotspot. Let&#8217;s know more about it! First of all I&#8217;ve checked the HTTP server header on port 80; here it is: According to 7th line, this is a Apache Tomcat server. At 11th line, the browser redirects to this address: https://172.23.130.41:8443. So I went there too but it was [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2010/10/mtn-irancell-or-huawei-ii/"><![CDATA[<p>So, we are still at the hotspot. Let&#8217;s know more about it! First of all I&#8217;ve checked the HTTP server header on port 80; here it is:</p>
<pre class="brush: plain; title: ; notranslate">[mahrud@eve ~]$ nc -vv 172.23.130.41 80
Connection to 172.23.130.41 80 port [tcp/www] succeeded!
GET / HTTP/1.1
HOST: 172.23.130.41
HTTP/1.1 302 Moved Temporarily
Server: &lt;strong&gt;Apache-Coyote&lt;/strong&gt;/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 08:00:00 CST
Location: https://172.23.130.41:8443/
Content-Length: 0
Date: Tue, 24 Aug 2010 05:37:16 GMT</pre>
<p>According to 7th line, this is a Apache Tomcat server. At 11th line, the browser redirects to this address: https://172.23.130.41:8443. So I went there too <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /> but it was just like connecting on port 80, except, first it redirected me to /portal/ then it gave me a JSESSIONID, and then to /portal/default.portal.</p>
<p>There is still few things to look at; Is there any administration panel on the portal? I think it doesn&#8217;t need one, but it has one! <a href="https://172.23.130.41:8443/admin/login.jsp">Here it is</a>!</p>
<div style="width: 410px" class="wp-caption aligncenter"><a href="/~mahrud/blog/wp-content/uploads/Screenshot-iSAP-Admin-Console.png"><img class="size-medium" style="border: 0pt none;" src="/~mahrud/blog/wp-content/uploads/Screenshot-iSAP-Admin-Console.png" width=400" height="300" border="0" /></a><p class="wp-caption-text">iSAP Admin Console (click to enlarge)</p></div>
<p>The strange thing is that <del>the default password works</del>! (see update) They didn&#8217;t even change the default password! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":-D" class="wp-smiley" /> (we&#8217;ll see this problem many times in future posts! ;-)) Do you know what the hell iSAP is? Perhaps Integrated Server Application Platform, but I&#8217;m not sure.</p>
<p>Let&#8217;s google <a title="Google result: &quot;iSAP+admin+console&quot;" href="http://www.google.com/search?q=&quot;iSAP+admin+console&quot;">&#8220;iSAP admin console&#8221;</a>; the only result is <a title="Again an iSAP server!" href="http://mtngroupconnect.com/isapadmin/login.jsp">this</a>, and again with default password! This server belongs to MTN Conference Call service.</p>
<p>This is what I say, a `Net of Lies`! They don&#8217;t secure your net, you should do it yourself! You can go across the net through the routers to find other lies. Anyway &#8230; <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /></p>
<p>Before logging in the panel, just take a deeper look at the login page &#8230; there is the copyright info at the footer, but the time had been passed before Irancell&#8217;s WiMAX service even began! Also we can see the Huawei&#8217;s logo but no sign of Irancell. The point that I want to focus on, is that small button that changes the language! Click on it and you&#8217;ll see that in addition to the language, the URL is changed:</p>
<pre class="brush: plain; light: true; title: ; notranslate">https://172.23.130.41:8443/admin/changelanguage.do?language=zh</pre>
<p>So, what if we change &#8216;zh&#8217; to &#8216;abcd&#8217;? Hmm &#8230; Nothing appears <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_sad.gif" alt=":-(" class="wp-smiley" /> but wait! Take a deeper look at the HTML source! there are 2 changes in the source, one in line 9:</p>
<pre class="brush: plain; light: true; title: ; notranslate">&lt;html lang=&quot;abcd&quot;&gt;</pre>
<p>and the other one, in line 74:</p>
<pre class="brush: plain; light: true; title: ; notranslate">&lt;a href=&quot;changelanguage.do?language=abcd&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;images/chinese.gif&quot;&gt;&lt;/a&gt;</pre>
<p>Do you think it is vulnerable against XSS or not? Let me check it &#8230; <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_biggrin.gif" alt=":-D" class="wp-smiley" /> that&#8217;s vulnerable! here is the PoC:</p>
<pre class="brush: plain; light: true; title: ; notranslate">https://172.23.130.41:8443/admin/changelanguage.do?language=a%22%3E%3C/a%3E%3Cscript%3Ealert%280%29%3C/script%3E</pre>
<p>But how can we use it? we have the default password! Laugh out load! <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /><br />
TODO: inside of the admin panel, and then, work on the internal network!<br />
<strong><span style="color: #ff0000;">UPD</span></strong>: A friend of mine (who also uses WiMax) has changed the default password. Perhaps I should have done this to prevent damage. If you are a representative from Irancell you can contact me using the email provided in the sidebar.</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/10/mtn-irancell-or-huawei-ii/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/10/mtn-irancell-or-huawei-ii/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[MTN, Irancell or Huawei?]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/mtn-irancell-or-huawei/" />
		<id>/~mahrud/blog/?p=9</id>
		<updated>2012-08-12T11:09:54Z</updated>
		<published>2010-08-23T11:03:15Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cryptography" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Net of Lies" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Huawei" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="MTN Irancell" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Wimax Network" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="X.509 Certificate" />		<summary type="html"><![CDATA[What&#8217;s going on in MTN-Irancell&#8217;s WiMAX network? Where does it come from? Whose is it? and finally, is it secure? Actually these are my questions too! But I&#8217;ve found few things that made me feel insecure while working on the Irancell&#8217;s network! So, where to start? Just plug in the power cable, then connect the [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/mtn-irancell-or-huawei/"><![CDATA[<p>What&#8217;s going on in MTN-Irancell&#8217;s WiMAX network? Where does it come from? Whose is it? and finally, is it secure?</p>
<p>Actually these are my questions too! But I&#8217;ve found few things that made me feel insecure while working on the Irancell&#8217;s network!</p>
<p>So, where to start? Just plug in the power cable, then connect the Ethernet cable to a computer, and surf the Internet &#8230; NO! first we have to login to a Portal like this:</p>
<div style="width: 410px" class="wp-caption aligncenter"><a href="/~mahrud/blog/wp-content/uploads/Screenshot-Wimax-Portal.png"><img class="size-medium" style="border: 0pt none;" src="/~mahrud/blog/wp-content/uploads/Screenshot-Wimax-Portal.png" width=400" height="300" border="0" /></a><p class="wp-caption-text">Hotspot Portal (click to enlarge)</p></div>
<p>But let&#8217;s check it again &#8230; the page is using https, cool! But wait a second, after checking the SSL Certificate I noticed the first problem; <a title="The hotspot's SSL certificate" href="/~mahrud/blog/wp-content/uploads/172.23.130.41_X.509-cert.tar.gz">this is the certificate</a>, and this is the output of OpenSSL X.509 utility:</p>
<pre class="brush: plain; title: ; notranslate">mahrud@eve:~/$ openssl x509 -in 172.23.130.41.pem -noout -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 1249623964 (0x4a7bbf9c)
        Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=CN, ST=Jiangsu, L=Nanjing, O=Huawei, OU=RM9000, CN=Huawei
        Validity
            Not Before: Aug  7 05:46:04 2009 GMT
            Not After : Mar  1 05:46:04 2108 GMT
        Subject: C=CN, ST=Jiangsu, L=Nanjing, O=Huawei, OU=RM9000, CN=Huawei
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (1024 bit)
                Modulus:
                    00:bc:97:64:7a:70:1d:00:5c:10:83:d8:35:8e:63:
                    9c:dd:4d:4c:7d:5d:f3:f0:e2:64:d1:d7:d2:7e:96:
                    70:69:54:d3:32:9e:90:df:1a:b7:3d:2c:04:ad:ac:
                    10:6f:b5:c4:a2:a4:04:06:60:1f:23:97:56:70:38:
                    ab:62:5d:5f:b2:78:24:4f:42:ff:00:94:64:bf:c7:
                    75:74:29:3e:0c:47:00:56:a9:41:3e:db:9c:85:ac:
                    ca:89:0d:22:6d:00:54:b3:c4:65:2c:d8:23:01:ec:
                    3b:1d:96:48:e8:4a:a0:60:aa:fe:c9:b7:a0:15:8a:
                    c2:48:af:38:0f:1b:a3:65:c5
                Exponent: 65537 (0x10001)
    Signature Algorithm: sha1WithRSAEncryption
        5c:fb:5b:46:60:06:77:7e:90:86:59:0d:ae:c6:7d:da:e6:14:
        b6:c8:6d:cf:76:ea:8a:cb:db:8e:63:aa:80:7b:b2:aa:8a:81:
        04:fd:50:58:f1:20:98:f2:b1:52:66:95:04:8d:e0:45:7e:b6:
        32:bc:98:59:45:1e:e0:0d:cb:f2:ca:5b:9c:5f:83:6e:cc:5d:
        97:6e:21:e3:5d:e5:cf:9b:08:08:72:d6:e7:58:b2:71:46:0e:
        ba:ea:1c:7a:ce:ae:00:d4:07:25:cf:fc:bb:4c:2b:70:1c:60:
        6b:59:1e:9b:08:2c:c9:fa:b2:6c:3a:11:01:a8:60:4d:b6:3c:
        5b:11</pre>
<p>THIS IS A <strong>SELF-SIGNED</strong> X.509 CERTIFICATE THAT ISSUES <strong>HUAWEI</strong>! Even the <a title="Google Maps: CN, Jiangsu, Nanjing" href="http://maps.google.com/maps?q=CN+Jiangsu+Nanjing">Country and City</a> is located at China! So does it mean that they just copied the Huawei&#8217;s certificate? I don&#8217;t think so. Take a look at the time of validity of certificate: it starts from Aug, 7 05:46:04 2009. I&#8217;m not sure, perhaps this is when they configured the system. Now look at OU (Organization Unit): RM9000; Where is there? What does it mean? I don&#8217;t know!</p>
<h3>Conclusion</h3>
<p>I really don&#8217;t know what can I say! After all these things, I have nothing but more questions: Why did they use Huawei&#8217;s information in that self-signed certificate? It could be a simple cert generator script, but what worries me is the possibility that this is not the only thing that our engineers&#8217; eyes didn&#8217;t catch; this might look like a simple mistake from either parties in a business contract, but it can give Chinese hackers or even their government an easy opportunity for organized espionage.</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/mtn-irancell-or-huawei/#comments" thr:count="2"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/mtn-irancell-or-huawei/feed/atom/" thr:count="2"/>
		<thr:total>2</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Generating arbitrary packets using hping]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/generating-arbitrary-packets-using-hping/" />
		<id>/~mahrud/blog/?p=8</id>
		<updated>2012-08-12T10:19:15Z</updated>
		<published>2010-08-06T10:43:55Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Network" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Hping" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="ICMP" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Packet Spoofing" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Python" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="TCP/IP" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="UDP" />		<summary type="html"><![CDATA[Hi all, Recently a friend of mine asked me &#8220;Is there any program that lets us to change packet flags, sequence number or even working with experimental protocols?&#8221;. Actually I&#8217;ve asked this question last summer &#8230; but I&#8217;ve found the answer in socket programming! So, it took me a week to learn socket programming with [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/generating-arbitrary-packets-using-hping/"><![CDATA[<p>Hi all,<br />
Recently a friend of mine asked me &#8220;Is there any program that lets us to change packet flags, sequence number or even working with experimental protocols?&#8221;.<br />
Actually I&#8217;ve asked this question last summer &#8230; but I&#8217;ve found the answer in socket programming! So, it took me a week to learn socket programming with Ruby. But after few months I found a better way: Hping.<br />
According to the manual page and <a href="http://www.hping.org/">its website</a>:</p>
<blockquote><p>
Hping is a command-line oriented TCP/IP packet assembler/analyzer. The interface is inspired to the ping(8) unix command, but hping isn&#8217;t only able to send ICMP echo requests. It supports TCP, UDP, ICMP and RAW-IP protocols, has a traceroute mode, the ability to send files between a covered channel, and many other features.
</p></blockquote>
<p>A subset of the stuff you can do using hping:</p>
<blockquote>
<ul>
<li>Firewall testing</li>
<li>Advanced port scanning</li>
<li>Network testing, using different protocols, TOS, fragmentation</li>
<li>Manual path MTU discovery</li>
<li>Advanced traceroute, under all the supported protocols</li>
<li>Remote OS fingerprinting</li>
<li>Remote uptime guessing</li>
<li>TCP/IP stacks auditing</li>
<li>IP spoofing</li>
<li>hping can also be useful to students that are learning TCP/IP.</li>
</ul>
</blockquote>
<p>I don&#8217;t want to just explain the usage (as you can learn it from man page or Google!) but there are few options in the manual page that were very useful for me:</p>
<pre class="brush: plain; title: ; notranslate">  -I  --interface interface name (otherwise default routing interface)
  -9  --listen     listen mode
  -a  --spoof      spoof source address
  --rand-dest      random destionation address mode. see the man.
  -t  --ttl        ttl (default 64)
  -N  --id         id (default random)
  -f  --frag       split packets in more frag.  (may pass weak acl)
  -Q  --seqnum     shows only tcp sequence number
  -M  --setseq     set TCP sequence number
  -L  --setack     set TCP ack
  -F  --fin        set FIN flag
  -S  --syn        set SYN flag
  -R  --rst        set RST flag
  -P  --push       set PUSH flag
  -A  --ack        set ACK flag</pre>
<p>Enjoy the full power of your network interface in network <img src="https://www.ocf.berkeley.edu/~mahrud/blog/wp-includes/images/smilies/icon_wink.gif" alt=";-)" class="wp-smiley" /></p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/generating-arbitrary-packets-using-hping/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/08/generating-arbitrary-packets-using-hping/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Protocol assignments reference: RFC or IANA?]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/07/protocol-assignments-reference-rfc-or-iana/" />
		<id>/~mahrud/blog/?p=7</id>
		<updated>2012-08-09T11:18:31Z</updated>
		<published>2010-07-16T10:19:22Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Uncategorized" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="IANA" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="IETF" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="protocol assignments" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="RFC" />		<summary type="html"><![CDATA[Months ago I was wondering if there is any organization or reference that contains all of the protocol assignments, like flags in header of a TCP packet. The best answer is RFC archives. Each RFC or Request for Comments is a paper that contains many details about the subject, for example for anything about HTTP/1.1 [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2010/07/protocol-assignments-reference-rfc-or-iana/"><![CDATA[<p>Months ago I was wondering if there is any organization or reference that contains all of the protocol assignments, like flags in header of a TCP packet. The best answer is RFC archives.<br />
Each RFC or Request for Comments is a paper that contains many details about the subject, for example for anything about HTTP/1.1 we can explore<a title="Hypertext Transfer Protocol -- HTTP/1.1" href="http://tools.ietf.org/html/rfc2616"> RFC 2616</a>. But that&#8217;s not a legal entity, so I kept looking and I found The Internet Assigned Numbers Authority (IANA). Here is a part of <a title="About IANA" href="http://www.iana.org/about">IANA about page</a>:</p>
<blockquote><p>The Internet Assigned Numbers Authority (IANA) is the body responsible for coordinating some of the key elements that keep the Internet running smoothly. While the Internet is renowned for being a worldwide network free from central coordination, there is a technical need for some key parts of the Internet to be globally coordinated – and this coordination role is undertaken by IANA.</p>
<p>Specifically, IANA allocates and maintains unique codes and numbering systems that are used in the technical standards (“protocols”) that drive the Internet.</p></blockquote>
<p>The list of Protocol Registries can be located <a title="IANA Protocol Reference" href="http://www.iana.org/protocols/">here</a>. As you can see most of them are referencing to RFCs, but I think reading <a title="Control and Provisioning of Wireless Access Points (CAPWAP) Protocol Binding for IEEE 802.11" href="http://tools.ietf.org/html/rfc5416">this RFC</a> or even looking for something in it gets more time than just taking a look at <a title="IEEE 802.11 Encryption Capabilities Table" href="http://www.iana.org/assignments/capwap-parameters/capwap-parameters.xhtml#capwap-parameters-36">this table</a> for information about IEEE 802.11 encryption capabilities!</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/07/protocol-assignments-reference-rfc-or-iana/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/07/protocol-assignments-reference-rfc-or-iana/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[SSH server ciphersuites, or How to learn to speak with the Daemons!]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/ssh-ciphers-or-speak-with-daemons/" />
		<id>/~mahrud/blog/?p=6</id>
		<updated>2012-12-26T12:09:22Z</updated>
		<published>2010-03-27T22:56:35Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Cryptography" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Network" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="netcat" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="secure socket shell" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="speak with the daemons" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="ssh" />		<summary type="html"><![CDATA[Yesterday I was capturing my network traffic while connecting to an ssh server and I found out about various steps of connecting to server: the server sends sshd version and protocol (server hello); ssh client sends its protocol and [sometimes?] version (client hello); then sshd sends it&#8217;s supported ciphers to client; ssh client chooses one [&#8230;]]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/ssh-ciphers-or-speak-with-daemons/"><![CDATA[<p>Yesterday I was capturing my network traffic while connecting to an ssh server and I found out about various steps of connecting to server:</p>
<ol>
<li>the server sends sshd version and protocol (server hello);</li>
<li>ssh client sends its protocol and [sometimes?] version (client hello);</li>
<li>then sshd sends it&#8217;s supported ciphers to client;</li>
<li>ssh client chooses one of them; and they follow steps to use that ciphersuite.</li>
</ol>
<p>Capturing network traffic is a very good way to understand how a network protocol works. But in order to see a simple demonstration of these steps, I think it&#8217;s easier to connect to the server with NetCat; just connect to ssh port, wait for server to introduce itself, and then send a fake ssh-client version to server; for instance look at this: (<a href="/~mahrud/blog/wp-content/uploads/nc_allamehelli.ir_sshd.txt">text file</a> is also available)<br />
<a href="/~mahrud/blog/wp-content/uploads/nc_allamehelli.ir_sshd.png"><img src="/~mahrud/blog/wp-content/uploads/nc_allamehelli.ir_sshd.png" /></a><br />
<span style="color: #ff0000;"><strong>UPDATE</strong></span>: Yeah, I know, you can get this info by <code>ssh HOSTNAME -v</code>. This is an old post, I was just experimenting.</p>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/ssh-ciphers-or-speak-with-daemons/#comments" thr:count="3"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/ssh-ciphers-or-speak-with-daemons/feed/atom/" thr:count="3"/>
		<thr:total>3</thr:total>
	</entry>
		<entry>
		<author>
			<name>mahrud</name>
					</author>
		<title type="html"><![CDATA[Hello world!]]></title>
		<link rel="alternate" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/hello-world/" />
		<id>/~mahrud/blog/?p=1</id>
		<updated>2012-08-08T12:52:19Z</updated>
		<published>2010-03-20T16:23:17Z</published>
		<category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="Uncategorized" /><category scheme="https://www.ocf.berkeley.edu/~mahrud/blog" term="intro.c" />		<summary type="html"><![CDATA[]]></summary>
		<content type="html" xml:base="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/hello-world/"><![CDATA[<pre class="brush: cpp; title: ; notranslate">
/*	Hello, World!
 *	Welcome to Cryptanalyst. This is my first post.
 *	Read or ignore it, then continue reading!

 *	Just another wordpress blog! Focused on linux, network, [amateur]
 *	cryptography, and hopefully algorithms or electronics in the future!

 *	Copyright (C) 2010-`date +%Y`  Mahrud Sayrafi
 *	Permission is granted to copy, distribute and/or modify this document
 *	under the terms of the GNU Free Documentation License, Version 1.3
 *	or any later version published by the Free Software Foundation.

 *	You should have received a copy of the GNU Free Documentation License
 *	along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;.
 */

#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;algorithms.h&gt;
#include &lt;openssl/rand.h&gt;
#include &lt;openssl/crypto.h&gt;

#define BUF 1048576	// 2^20
#define NOP 0x90	// nop padding

char sc[] =	/* linux/i386 shellcode */
&quot;\x31\xc0\x50\x68//sh\x68/bin\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80&quot;;

int main(int argc, char *argv[])
{
	printf(&quot;Hello, World!&quot;);
	// TO BE COMPLETED IN THE FUTURE!
	return 0;
}
~
~
&quot;intro.c&quot;								1,1	Top
</pre>
<pre class="brush: plain; class-name: console; title: ; notranslate">
[mahrud@eve ~]# iptables --list --line-numbers
Chain INPUT (policy REJECT)
num	target	prot	opt	source		destination
1	ACCEPT	tcp	--	Hacker		localhost
2	LOG	tcp	--	Hacker		localhost    hat color:black, gray
4	DROP	tcp	--	Cracker		localhost
</pre>
]]></content>
			<link rel="replies" type="text/html" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/hello-world/#comments" thr:count="0"/>
		<link rel="replies" type="application/atom+xml" href="https://www.ocf.berkeley.edu/~mahrud/blog/2010/03/hello-world/feed/atom/" thr:count="0"/>
		<thr:total>0</thr:total>
	</entry>
	</feed>
