<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Debian or not to be ? 2.0 &#187; Code</title> <atom:link href="http://www.crashdump.fr/coding/feed/" rel="self" type="application/rss+xml" /><link>http://www.crashdump.fr</link> <description>that is the question</description> <lastBuildDate>Mon, 23 Jan 2012 13:14:39 +0000</lastBuildDate> <language>fr</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item><title>Tips: Serveur web d&#8217;urgence avec Netcat</title><link>http://www.crashdump.fr/reseaux/tips-serveur-web-durgence-avec-netcat-832/</link> <comments>http://www.crashdump.fr/reseaux/tips-serveur-web-durgence-avec-netcat-832/#comments</comments> <pubDate>Mon, 03 May 2010 12:57:44 +0000</pubDate> <dc:creator>Crashdump</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Réseaux]]></category><guid isPermaLink="false">https://www.crashdump.fr/?p=832</guid> <description><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2010/05/nc.jpg" class="attachment-featured-image wp-post-image" alt="nc" title="nc" /></p><br />Il peut arriver que l&#8217;on ait ponctuellement besoin de publier un fichier html/txt en http sur une machine.. Pour ça inutile d&#8217;installer un serveur web lourd comme apache. Je vous avais déjà parlé du serveur web en python en une ligne, cette fois on remet ça, mais avec NC: 1$ while true; do nc -l [...]]]></description> <content:encoded><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2010/05/nc.jpg" class="attachment-featured-image wp-post-image" alt="nc" title="nc" /></p><br /><p><em>Il peut arriver que l&#8217;on ait ponctuellement besoin de publier un fichier html/txt en http sur une machine.. Pour ça inutile d&#8217;installer un serveur web lourd comme apache. Je vous avais déjà parlé du <a href="http://www.crashdump.fr/reseaux/serveur-http-python-en-une-ligne-649/">serveur web en python en une ligne</a>, cette fois on remet ça, mais avec NC:</em></p><div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span> nc <span style="color: #660033;">-l</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">8080</span> <span style="color: #000000; font-weight: bold;">&lt;</span> index.html; <span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div><p>(attention, la version BSD de Netcat diffère au niveau des arguments, pour la même chose il faut supprimer le &laquo;&nbsp;-p&nbsp;&raquo;):</p><p>Les requêtes de votre navigateur seront renvoyées vers le stdout:</p><div class="codecolorer-container http default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="http codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">GET</span> <span style="color: #000000; font-weight: bold;">/</span> HTTP<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span><br /> <span style="color: #000000; font-weight: bold;">Host:</span> 127.0.0.1:<span style="color: #000000;">8080</span><br /> <span style="color: #000000; font-weight: bold;">Connection:</span> keep-alive<br /> <span style="color: #000000; font-weight: bold;">User-Agent:</span> Mozilla<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5.0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Macintosh; U; Intel Mac OS X <span style="color: #000000;">10</span>_5_2; en-US<span style="color: #7a0874; font-weight: bold;">&#41;</span> AppleWebKit<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">533.2</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>KHTML, like Gecko<span style="color: #7a0874; font-weight: bold;">&#41;</span> Chrome<span style="color: #000000; font-weight: bold;">/</span>5.0.342.5 Safari<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">533.2</span><br /> <span style="color: #000000; font-weight: bold;">Accept:</span> application<span style="color: #000000; font-weight: bold;">/</span>xml,application<span style="color: #000000; font-weight: bold;">/</span>xhtml+xml,text<span style="color: #000000; font-weight: bold;">/</span>html;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.9</span>,text<span style="color: #000000; font-weight: bold;">/</span>plain;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.8</span>,image<span style="color: #000000; font-weight: bold;">/</span>png,<span style="color: #000000; font-weight: bold;">*/*</span>;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.5</span><br /> <span style="color: #000000; font-weight: bold;">Accept-Encoding:</span> gzip,deflate,sdch<br /> <span style="color: #000000; font-weight: bold;">Accept-Language:</span> fr-FR,fr;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.8</span>,en-US;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.6</span>,en;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.4</span><br /> <span style="color: #000000; font-weight: bold;">Accept-Charset:</span> ISO-<span style="color: #000000;">8859</span>-<span style="color: #000000;">1</span>,utf-<span style="color: #000000;">8</span>;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.7</span>,<span style="color: #000000; font-weight: bold;">*</span>;<span style="color: #007800;">q</span>=<span style="color: #000000;">0.3</span></div></td></tr></tbody></table></div><p>On peut ensuite faire ce que l&#8217;on veut avec &#8211; comme simple limite &#8211; son imagination ! Exemple:</p><div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt; pre&gt;<span style="color: #007800;">$(ps aux)</span>&lt; /pre&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> nc <span style="color: #660033;">-l</span> <span style="color: #000000;">8080</span>; <span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div> ]]></content:encoded> <wfw:commentRss>http://www.crashdump.fr/reseaux/tips-serveur-web-durgence-avec-netcat-832/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Serveur HTTP Python en une ligne..</title><link>http://www.crashdump.fr/reseaux/serveur-http-python-en-une-ligne-649/</link> <comments>http://www.crashdump.fr/reseaux/serveur-http-python-en-une-ligne-649/#comments</comments> <pubDate>Fri, 24 Apr 2009 22:21:29 +0000</pubDate> <dc:creator>Crashdump</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Réseaux]]></category> <category><![CDATA[http]]></category> <category><![CDATA[python]]></category> <category><![CDATA[serveur]]></category> <category><![CDATA[serveur web]]></category> <category><![CDATA[SimpleHTTPServer]]></category><guid isPermaLink="false">http://www.crashdump.fr/?p=649</guid> <description><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2009/04/python_at_http.jpg" class="attachment-featured-image wp-post-image" alt="python_at_http" title="python_at_http" /></p><br />Un &#171;&#160;irc friend&#160;&#187; &#8211; fo0 en l&#8217;occurrence &#8211; m&#8217;as demandé récemment comment comment créer un petit serveur web en python, rapidement pour pouvoir partager ponctuellement des fichiers &#038; tester du dev. Et bien c&#8217;est faisable en une courte ligne: 1python -c 'import SimpleHTTPServer;SimpleHTTPServer.test()' Ca lance un petit serveur http sur le port 8000, partageant les [...]]]></description> <content:encoded><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2009/04/python_at_http.jpg" class="attachment-featured-image wp-post-image" alt="python_at_http" title="python_at_http" /></p><br /><p><em>Un &laquo;&nbsp;irc friend&nbsp;&raquo; &#8211; <a rel="nofollow" href="irc://irc.europnet.org/informatique">fo0</a> en l&#8217;occurrence &#8211; m&#8217;as demandé récemment comment comment créer un petit serveur web en python, rapidement pour pouvoir partager ponctuellement des fichiers &#038; tester du dev. Et bien c&#8217;est  faisable en une courte ligne:</em></p><div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python -c <span style="color: #483d8b;">'import SimpleHTTPServer;SimpleHTTPServer.test()'</span></div></td></tr></tbody></table></div><p>Ca lance un petit serveur http sur le port 8000, partageant les fichiers du répertoire courant. Pointez vôtre navigateur sur http://127.0.0.1:8000/ et vous servira le fichier index.html si il existe, sinon il listera le répertoire courant. Et il bavera toutes les infos sur le stdout, exemple:</p><div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ python -c <span style="color: #483d8b;">'import SimpleHTTPServer;SimpleHTTPServer.test()'</span><br /> Serving HTTP on 0.0.0.0 port <span style="color: #ff4500;">8000</span> ...<br /> <span style="color: black;">localhost</span> - - <span style="color: black;">&#91;</span><span style="color: #ff4500;">25</span>/Apr/<span style="color: #ff4500;">2009</span> <span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">01</span>:<span style="color: #ff4500;">27</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #ff4500;">200</span> -<br /> localhost - - <span style="color: black;">&#91;</span><span style="color: #ff4500;">25</span>/Apr/<span style="color: #ff4500;">2009</span> <span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">01</span>:<span style="color: #ff4500;">38</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot;GET /Documents/ HTTP/1.1&quot;</span> <span style="color: #ff4500;">200</span> -<br /> localhost - - <span style="color: black;">&#91;</span><span style="color: #ff4500;">25</span>/Apr/<span style="color: #ff4500;">2009</span> <span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">01</span>:<span style="color: #ff4500;">44</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot;GET /Documents/test.txt HTTP/1.1&quot;</span> <span style="color: #ff4500;">200</span> -</div></td></tr></tbody></table></div><p>De plus il est &laquo;&nbsp;chrooté&nbsp;&raquo; au répertoire dans lequel vous l&#8217;aurez lancé &#8211; essayer d&#8217;accéder a http://127.0.0.1:8000/../ vous laissera dans le répertoire courant.</p><p>Voilà pour la petite astuce du soir..</p><p><strong>Maj du 29 Avril 2009</strong>: Vu sur <a rel="nofollow" href="http://www.tux-planet.fr" rel="nofollow">http://www.tux-planet.fr</a>, une version encore plus simple:</p><div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python -m <span style="color: #dc143c;">SimpleHTTPServer</span></div></td></tr></tbody></table></div><p><strong>Maj du 04 Mai 2009</strong>: Voici une version multithreadé et pas beaucoup plus compliquée:</p><div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br /> <span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span><br /> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">SocketServer</span><br /> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">BaseHTTPServer</span><br /> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">os</span><br /> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">CGIHTTPServer</span><br /> port <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">8000</span><br /> <span style="color: #ff7700;font-weight:bold;">class</span> ThreadingCGIServer<span style="color: black;">&#40;</span><span style="color: #dc143c;">SocketServer</span>.<span style="color: black;">ThreadingMixIn</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">BaseHTTPServer</span>.<span style="color: black;">HTTPServer</span><span style="color: black;">&#41;</span>:<br /> &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br /> server <span style="color: #66cc66;">=</span> ThreadingCGIServer<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span> port<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">CGIHTTPServer</span>.<span style="color: black;">CGIHTTPRequestHandler</span><span style="color: black;">&#41;</span><br /> <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Serveur demarre sur le port %s.&quot;</span> % port<br /> <span style="color: #ff7700;font-weight:bold;">try</span>:<br /> &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:<br /> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; server.<span style="color: black;">handle_request</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br /> <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyboardInterrupt</span>:<br /> &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Fini !&quot;</span></div></td></tr></tbody></table></div> ]]></content:encoded> <wfw:commentRss>http://www.crashdump.fr/reseaux/serveur-http-python-en-une-ligne-649/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>HackThisSite.org Basic Howto: 1 à 10</title><link>http://www.crashdump.fr/securite/hackthissiteorg-howto-519/</link> <comments>http://www.crashdump.fr/securite/hackthissiteorg-howto-519/#comments</comments> <pubDate>Fri, 10 Apr 2009 13:04:09 +0000</pubDate> <dc:creator>Crashdump</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Réseaux]]></category> <category><![CDATA[Sécurité]]></category> <category><![CDATA[basic mission]]></category> <category><![CDATA[hack this site]]></category> <category><![CDATA[HackThisSite.org]]></category> <category><![CDATA[tutoriel]]></category><guid isPermaLink="false">http://www.crashdump.fr/?p=519</guid> <description><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2009/04/hacking-shellcode.png" class="attachment-featured-image wp-post-image" alt="hacking-shellcode" title="hacking-shellcode" /></p><br />Il y a des jours, ou, on se fait un peu plus chier que d&#8217;autres.. En bon geek j&#8217;ai occupé mon temps en surf sur le net et je suis tombé sur ça: http://www.hackthissite.com. Il ne sagit pas là d&#8217;une provocation pure et simple mais d&#8217;un site qui propose des défis de h4x0r. Je n&#8217;ai [...]]]></description> <content:encoded><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2009/04/hacking-shellcode.png" class="attachment-featured-image wp-post-image" alt="hacking-shellcode" title="hacking-shellcode" /></p><br /><p><em>Il y a des jours, ou, on se fait un peu plus chier que d&#8217;autres.. En bon geek j&#8217;ai occupé mon temps en surf sur le net et je suis tombé sur ça: </em><a rel="nofollow" href="http://www.hackthissite.org/"><em>http://www.hackthissite.com</em></a><em>. Il ne sagit pas là d&#8217;une provocation pure et simple mais d&#8217;un site qui propose des défis de h4x0r. Je n&#8217;ai eu &#8211; pour l&#8217;instant &#8211; que l&#8217;occasion de réaliser la partie &laquo;&nbsp;Basic Missons&nbsp;&raquo; (les 10 épreuves) et je vais essayer de toutes vous les expliquer ici. Sans plus attendre voici les solutions.</em></p><p><strong>Avant tout, il vous faudra le navigateur  au renard a la queue flamboyante avec quelques une des extensions disponibles: &laquo;&nbsp;</strong><a rel="nofollow" href="http://www.mozilla-europe.org/fr/firefox/"><strong>Firefox</strong></a><strong>&laquo;&nbsp;, &laquo;&nbsp;</strong><a rel="nofollow" href="https://addons.mozilla.org/en-US/firefox/addon/1843"><strong>Firebug</strong></a><strong>&nbsp;&raquo; et &laquo;&nbsp;</strong><a rel="nofollow" href="https://addons.mozilla.org/fr/firefox/addon/6683"><strong>FireCookies</strong></a><strong>&laquo;&nbsp;.</strong></p><p><em></em></p><h2><span style="text-decoration: underline;">Basic 1</span>: &laquo;&nbsp;Basic test of your skills to see if you can do any of these missions. Requirements: HTML.&nbsp;&raquo;</h2><p>La première mission est vraiment très très simple, il suffit d&#8217;aller plonger dans le code source pour y trouver le mot de passe: faites un clic droit et &laquo;&nbsp;View page source&nbsp;&raquo; (ou &laquo;&nbsp;Inspect element&nbsp;&raquo; avec firebug) cherchez un code de la forme:</p><pre>&lt;!-- the first few levels are extremely easy: password is abcd1234 --&gt;</pre><p>Entrez le mot de passe dans le champ puis cliquez: &laquo;&nbsp;submit&nbsp;&raquo;. Bravo vous êtes un 3l1t3 h4x00r :)</p><h2><span style="text-decoration: underline;">Basic 2</span>: &laquo;&nbsp;A slightly more difficult challenge, involving an incomplete password script. Requirements: Common sense.&nbsp;&raquo;</h2><p>Deuxième mission qui on s&#8217;en doute ne va pas être vraiment plus difficile que la première. Il suffira d&#8217;être un petit peu logique.. il est dit que l&#8217;admin n&#8217;as pas uploadé le fichier contenant le mot de passe, donc: le mot de passe est&#8230; vide, quel étourdi ce sam ! Cliquez simplement sur &laquo;&nbsp;submit&nbsp;&raquo; :)</p><h2><span style="text-decoration: underline;">Basic 3</span>: &laquo;&nbsp;Some intuition is needed to find the location of the hidden password file. Requirements: Basic HTML knowledge.&nbsp;&raquo;</h2><p>Très bien, ici, Sam n&#8217;as pas oublié d&#8217;uploader le fichier contenant le mot de passe (en clair..). Comme d&#8217;habitude, avant tout, rendons nous dans la source:</p><pre>&lt;form action="/missions/basic/3/index.php" method="post"&gt;
    <strong>&lt;input type="hidden" name="file" value="password.php"&gt;</strong>
    &lt;input type="password" name="password"&gt;&lt;br /&gt;&lt;br /&gt;
    &lt;input type="submit" value="submit"&gt;</pre><p>Tiens, Sam a encore commis une boulette ! Pointez vôtre navigateur sur &laquo;&nbsp;http://www.hackthissite.org/missions/basic/3/password.php&nbsp;&raquo;, récupérez le mot de passe et next !</p><h2><span style="text-decoration: underline;">Basic 4</span>: &laquo;&nbsp;An email script has been set up, which sends the password to the administrator. Requirements: HTML knowledge, an email address.&nbsp;&raquo;</h2><p>Dans la mission 4, Sam a encore commis de belles erreurs !  Regardons directement la source:</p><pre>&lt;form action="/missions/basic/4/level4.php" method="post"&gt;
    &lt;input type="hidden" name="to" value="webmaster@hulla-balloo.com"&gt;
    &lt;input type="submit" value="Send password to Sam"&gt;
&lt;/form&gt;
&lt;form action="/missions/basic/5/index.php" method="post"&gt;
        &lt;input type="password" name="password"&gt;
        &lt;br /&gt;&lt;br /&gt;
        &lt;input type="submit" value="submit"&gt;
&lt;/form&gt;</pre><p>Comme vous pouvez le voir, il y a deux &laquo;&nbsp;forms&nbsp;&raquo;: Le premier permet d&#8217;envoyer le mot de passe sur l&#8217;adresse mail de Sam alors que le second permet l&#8217;accès quand on connais le mot de passe.</p><p>Ici encore, nous allons exploiter ce code pas très sécure pour nous faire envoyer le mot de passe en forgeant notre propre form. Pour ça, ouvrez firebug en cliquant droit sur le form, puis &laquo;&nbsp;Inspect element&nbsp;&raquo;. Maintenant changez directement l&#8217;adresse mail par la vôtre &#8211; ou changez le type du champ de </p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">type=&quot;hidden&quot;</div></td></tr></tbody></table></div><p>à </p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">type=&quot;text&quot;</div></td></tr></tbody></table></div><p>. Validez.. copiez le mot de passe, revenez en arrière et passons au challenge suivant :)</p><h2><span style="text-decoration: underline;">Basic 5</span>: &laquo;&nbsp;Similar to the previous challenge, but with some extra security measures in place. Requirements: HTML knowledge, JS or FF,  an email address.&nbsp;&raquo;</h2><p>A priori, rien de différent, on procède comme la Basic 4..</p><p>EDIT: il semble que la seule chose qui change c&#8217;est un script qui vérifie nôtre provenance avant de valider l&#8217;envoi du mail&#8230; en effet une autre solution pour le défi précédent aurais été de modifier la source de la page directement depuis une copie sur notre disque dur.</p><h2><span style="text-decoration: underline;">Basic 6</span>: &laquo;&nbsp;An encryption system has been set up, which uses an unknown algorithm to change the text given. Requirements: Persistence, some general cryptography knowledge.&nbsp;&raquo;</h2><p>J&#8217;avoue avoir un peu plus galéré sur ce défi ! C&#8217;est un sacré bond en avant que Sam nous a fait là.. En fait il ne sagit pas là d&#8217;exploit mais de cryptographie pure et simple.</p><p>Qu&#8217;avons nous ? deux formulaires et le mot de passe chiffré: Le premier permet de chiffrer un mot de passe et le deuxième d&#8217;accéder au défi suivant. Le mot de passe étant sous sa forme chiffrée, il nous faudra donc utiliser le premier script pour comprendre ou essayer d&#8217;en déduire la technique utilisée.</p><p>Essayons de chiffrer un caratère:</p><p><span style="font-family: -webkit-monospace;">1</span> nous donne: <span style="font-family: -webkit-monospace;">1</span></p><p><span style="font-family: -webkit-monospace;">1</span> donne <span style="font-family: -webkit-monospace;">1</span>. Hùùùm.. tentons quelque chose de plus long..</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">11111111</div></td></tr></tbody></table></div><p>-&gt; </p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">12345678</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">22222222</div></td></tr></tbody></table></div><p>-&gt; </p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">23456789</div></td></tr></tbody></table></div><p>Nous pouvons voir ici qu&#8217;il y a incrémentation de 1 pour le second chiffre, 2 pour le troisième.. etc. Que se passe t&#8217;il quand nous allons quitter les décimaux simples ? Essayons.</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">99999999</div></td></tr></tbody></table></div><p>-&gt; </p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">9:;&amp;lt;=&amp;gt;?@</div></td></tr></tbody></table></div><p>C&#8217;est la qu&#8217;il m&#8217;a fallu un peu de temps pour réaliser qu&#8217;il sagissait en fait de la table ASCII&#8230; en effet, sur cette table après le &laquo;&nbsp;9&#8243; nous avons &nbsp;&raquo;:&nbsp;&raquo; puis &laquo;&nbsp;;&nbsp;&raquo; puis &nbsp;&raquo;&lt;&nbsp;&raquo;, etc&#8230; <a href="http://www.crashdump.fr/wp-content/uploads/2009/04/ascii_table.jpg">Vérifiez ici par vous même</a> :)</p><p>J&#8217;ai, comme mot de passe chiffré: <span style="font-family: -webkit-monospace;">ef6d4818</span></p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">e - 0 = e</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">f - 1 = e</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">6 - 2 = 4</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">d - 3 = a</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">4 - 4 = 0</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">8 - 5 = 3</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">l - 6 = f</div></td></tr></tbody></table></div><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">8 - 7 = 1</div></td></tr></tbody></table></div><p>Le mot de passe déchiffré est donc: ee4a03f1 dans mon cas :)</p><p><strong>Basic 7: &laquo;&nbsp;The password is hidden in an unknown file, and Sam has set up a script to display a calendar. Requirements: Basic UNIX command knowledge.&nbsp;&raquo;</strong></p><p>Celui ci est vraiment très facile aussi ! Nous apprenons que Sam a crée un script qui retourne la sortie de la commande cal de linux (une aubaine pour nous!). Testons la chose.. Si nous entrons une année dans le champ il nous retourne le résultat classique de la commande cal, rien d&#8217;exceptionnel. Comment cela peut il fonctionner ? Je suppose que le contenu doit être de la forme:</p><div class="wp_syntax"><div class="code"><pre><span>print</span> `cal <span>$input</span>`;</pre></div></div><p>Une simple injection de la forme:</p><pre><span>&amp;&amp; ls</span></pre><p>Nous permet donc de lister le répertoire courant:</p><pre>.
..
level7.php
cal.pl
index.php
k1kh31b1n55h.php
perl5.8.9.core</pre><p>Il semblerais que le fichier k1kh31b1n55h.php contienne notre mot de passe. Bravo étape suivante :)</p><h2><span style="text-decoration: underline;">Basic 8</span>: &laquo;&nbsp;The password is yet again hidden in an unknown file. Sam&#8217;s daughter has begun learning <a rel="nofollow" id="KonaLink0" class="kLink" href="http://www.hackthissite.org/#" target="undefined"><span><span class="kLink">PHP</span></span></a>, and has a small script to demonstrate her knowledge. Requirements: Knowledge of SSI (dynamic html executed by the <a rel="nofollow" id="KonaLink1" class="kLink" href="http://www.hackthissite.org/#" target="undefined"><span><span class="kLink">server</span></span></a>, rather than the browser).&nbsp;&raquo;</h2><p>Sam commence a sécuriser un peu plus ses formulaire, heureusement sa petite soeur a crée un petit script qui va nous ouvrir les portes ! Essayons donc maintenant le script de Stéphanie: Ce script enregistre ce que vous avez entré dans le champ texte avec quelques informations supplémentaires (Longueur du texte.. etc). C&#8217;est a ce moment la que nous allons utiliser une injection par formulaire en utilisant, cette fois ci les SSI. (Du html dynamique, du code exécuté par le serveur.. un peu comme le php). Les SSI sont utilisée &#8211; par exemple &#8211; par apache pour inclure les headers/footers des pages qu&#8217;il génère avec l&#8217;option &laquo;&nbsp;<a rel="nofollow" href="http://httpd.apache.org/docs/2.0/mod/mod_autoindex.html">Indexes</a>&laquo;&nbsp;.</p><p>Nous allons donc essayer d&#8217;insérer le code suivant (exec de la commande linux ls) dans le fichier généré par le script de Stéphanie:</p><pre>&lt;!--#exec cmd="ls .."--&gt;</pre><p>Et voilà le travail:</p><blockquote><pre>Hi, au12ha39vc.php index.php level8.php tmp!
Your name contains 39 characters.</pre></blockquote><p>Il ne vous reste plus qu&#8217;a consulter au12ha39vc.php pour passer au niveau suivant :)</p><h2><span style="text-decoration: underline;">Basic 9</span>: &laquo;&nbsp;The password is again hidden in an unknown file. However, the script that was previously used to find it has some limitations. Requirements: Knowledge of SSI, Unix directory structure.&nbsp;&raquo;</h2><p>Liée a la mission précédente, celle ci s&#8217;avère très simple si on prend un peu de recul&#8230; Tout d&#8217;abord nous n&#8217;avons ici que le champ texte d&#8217;entrée du mot de passe, il va donc falloir chercher ailleurs. Si nous lisons les instructions de notre ami Sam nous aprenons qu&#8217;il sagit ici encore de SSI &#8211; nous avions utilisé:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;lt;!--#exec cmd=&quot;ls ..&quot;--&amp;gt;</div></td></tr></tbody></table></div><p>Donc il suffit de se rendre une mission plus tôt &#8211; retourner sur la 8, oui &#8211; et changer le path du ls pour lister ce répertoire ci.. rien de plus simple. Nous étions ici:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">/missions/basic/8/tmp/</div></td></tr></tbody></table></div><p>et nous voulons aller là:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">/missions/basic/9/</div></td></tr></tbody></table></div><p>, il suffira donc d&#8217;executer cette intruction ci:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;lt;!--#exec cmd=&quot;ls ../../9&quot;--&amp;gt;</div></td></tr></tbody></table></div><p>Encore une victoire pour nous.. plus que deux missions, voyons ce que Sam va nous servir.</p><h2><span style="text-decoration: underline;">Basic 10</span>: &laquo;&nbsp;This time Sam used a more temporary and &laquo;&nbsp;hidden&nbsp;&raquo; approach to authenticating users, but he didn&#8217;t think about whether or not those users knew their way around javascript&#8230;&nbsp;&raquo;</h2><p>Comme dans les missions précédentes nous sommes relativement bien guidés, il nous est dit que Sam a utilisé une méthode d&#8217;authentification cachée: de quoi penser &laquo;&nbsp;Cookies&nbsp;&raquo; ! En étudiant le code nous nous rendons compte que cette fois ci le mot de passe a été codé en dur et n&#8217;est pas accessible.</p><p>Nous allons donc analyser les cookies pour voir ce qu&#8217;il en est. Nous allons avoir besoin de &laquo;&nbsp;FireCookies&nbsp;&raquo; une extension pour Firefox qui permet de gérer les cookies (ajout/suppression/edition). Pour être le plus clair possible voici une capture d&#8217;ecran:</p><p><em><a href="http://www.crashdump.fr/wp-content/uploads/2009/03/firecookies-hackthissite.png"><img class="alignnone size-thumbnail wp-image-526" title="firecookies-hackthissite" src="http://www.crashdump.fr/wp-content/uploads/2009/03/firecookies-hackthissite-430x125.png" alt="firecookies-hackthissite" width="430" height="125" /></a></em></p><p>Vous pouvez voir une ligne “level11_authorized” changez sa valeur de “no” a “yes”, validez. BRAVO.</p> ]]></content:encoded> <wfw:commentRss>http://www.crashdump.fr/securite/hackthissiteorg-howto-519/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Activer Apache2/Php5 sous Mac Os X 10.5</title><link>http://www.crashdump.fr/reseaux/activer-apache2php5-sous-mac-os-x-105-382/</link> <comments>http://www.crashdump.fr/reseaux/activer-apache2php5-sous-mac-os-x-105-382/#comments</comments> <pubDate>Wed, 10 Sep 2008 13:23:18 +0000</pubDate> <dc:creator>Crashdump</dc:creator> <category><![CDATA[Apple]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[Réseaux]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[configuration]]></category> <category><![CDATA[httpd]]></category> <category><![CDATA[index]]></category> <category><![CDATA[léopard]]></category> <category><![CDATA[php 5]]></category> <category><![CDATA[serveur web]]></category> <category><![CDATA[terminal]]></category><guid isPermaLink="false">http://www.crashdump.fr/?p=382</guid> <description><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2008/09/php.jpg" class="attachment-featured-image wp-post-image" alt="php" title="php" /></p><br />Léopard intègre &#171;&#160;d&#8217;usine&#160;&#187; Apache 2.2.6 et Php 5, mais ils ne sont pas activés par défaut, je vais essayer de vous expliquer comment faire pour en profiter. Installer apache Si vous ne l&#8217;avez pas déjà, récupérez TexteMate ici (la version d&#8217;évaluation de 30 jours fera largement l&#8217;affaire) puis dans le menu &#171;&#160;Fichier&#160;&#187; choisissez &#171;&#160;Ouvrir&#160;&#187;. Dans [...]]]></description> <content:encoded><![CDATA[<p><img width="240" height="150" src="http://www.crashdump.fr/wp-content/uploads/2008/09/php.jpg" class="attachment-featured-image wp-post-image" alt="php" title="php" /></p><br /><p><em>Léopard intègre &laquo;&nbsp;d&#8217;usine&nbsp;&raquo; Apache 2.2.6 et Php 5, mais ils ne sont pas activés par défaut, je vais essayer de vous expliquer comment faire pour en profiter.</em></p><li><h2>Installer apache</h2></li><p>Si vous ne l&#8217;avez pas déjà, récupérez TexteMate <a rel="nofollow" href="http://macromates.com/">ici</a> (la version d&#8217;évaluation de 30 jours fera largement l&#8217;affaire) puis dans le menu &laquo;&nbsp;Fichier&nbsp;&raquo; choisissez &laquo;&nbsp;Ouvrir&nbsp;&raquo;. Dans la fenêtre qui vous est présentée sélectionnez &laquo;&nbsp;Affichez les fichiers cachés / Show hidden files&nbsp;&raquo; et ouvrez le fichier: &laquo;&nbsp;/HD/private/etc/apache2/httpd.conf&nbsp;&raquo;.</p><p><a href="http://www.crashdump.fr/wp-content/uploads/2008/09/textedit-hiddenfiles.jpg"><img class="alignnone size-thumbnail wp-image-383" title="textedit-hiddenfiles" src="http://www.crashdump.fr/wp-content/uploads/2008/09/textedit-hiddenfiles-430x125.jpg" alt="" width="430" height="125" /></a></p><p>Voilà, nous avons ouvert le fichier de configuration de apache. Notez que &#8211; si vous faites une bêtise &#8211; il existe une copie de ce fichier dans le sous-dossier nommé &laquo;&nbsp;original&nbsp;&raquo;.<br /> Rendez-vous a la ligne 113 ( Menu &laquo;&nbsp;Navigation / Go to line&#8230;&nbsp;&raquo; ou menu &laquo;&nbsp;View / Gutter / Line numbers&nbsp;&raquo; ) et retirez le commentaire en début de ligne (#) comme dans les captures suivantes:</p><p><a href="http://www.crashdump.fr/wp-content/uploads/2008/09/textedit-editfiles.jpg"><img class="alignnone size-thumbnail wp-image-384" title="textedit-editfiles" src="http://www.crashdump.fr/wp-content/uploads/2008/09/textedit-editfiles-430x125.jpg" alt="" width="430" height="125" /></a></p><p>Ce qui peut se traduire par &laquo;&nbsp;Charger le module php5 pour apache&nbsp;&raquo;. Maintenant nous allons configurer apache pour qu&#8217;il accepte les index.php en plus des traditionnels .html. Pour cela allons à la ligne 224 et faites comme indiqué sur cette capture:</p><p><a href="http://www.crashdump.fr/wp-content/uploads/2008/09/textedit-indexphp-httpdconf.jpg"><img class="alignnone size-thumbnail wp-image-385" title="textedit-indexphp-httpdconf" src="http://www.crashdump.fr/wp-content/uploads/2008/09/textedit-indexphp-httpdconf-430x125.jpg" alt="" width="430" height="125" /></a></p><p>Ok, maintenant sauvegardez &#8211; Il vous sera sûrement demandé un mot de passe, c&#8217;est normal, c&#8217;est un fichier dont le propriétaire est le &laquo;&nbsp;root&nbsp;&raquo; &#8211; vous pouvez maintenant quitter TextMate.<br /> Nous avons fait la configuration de &laquo;&nbsp;base&nbsp;&raquo;. Si vous êtes pressé allez dans les Préférences systèmes / Partage: Désactiver et réactiver le partage web pour relancer apache avec php5.. Félicitations.</p><li><h2>Configuration de php</h2></li><p>Maintenant si vous avez un peu de temps devant vous, nous allons nous pencher sur la configuration de ce dernier: le php.ini qui n&#8217;est pas utilisé pour le moment et dans lequel nous pourrons spécifier pas mal d&#8217;options.</p><p>Ouvrez un Terminal (Applications/Utilitaires) et entrez cette ligne (ce qui aura pour but de copier le fichier php.ini.default en php.ini) &#8211; Une fois encore il vous sera demandé votre mot de passe:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ sudo cp /private/etc/php.ini.default /private/etc/php.ini</div></td></tr></tbody></table></div><p>Ouvrez maintenant le php.ini avec TextEdit (de la même manière qu&#8217;avec le httpd.conf, show hidden files). Vous le trouverez dans &laquo;&nbsp;HD/private/etc/&nbsp;&raquo;.</p><p>Le fichier est plutôt bien commenté (toutes les lignes commençant par un ; est un commentaire). Mais en anglais, pour les anglophobes vous trouverez de la documentation sur <a rel="nofollow" href="http://fr.php.net/manual/fr/ini.php">fr.php.net</a>.</p><p>La première chose que je conseillerais de modifier est la gestion des erreurs: error_reporting.<br /> Le réglage par défaut (ligne 305) est:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">error_reporting = E_ALL &amp;amp; ~E_NOTICE</div></td></tr></tbody></table></div><p>Ce qui aura pour effet d&#8217;afficher seulement les erreurs Php les plus graves, si ce serveur vous sert uniquement pour la &laquo;&nbsp;production&nbsp;&raquo; il est judicieux de le laisser ainsi. Mais si vous en avez un usage développement vous devriez la modifier comme ça (pour éliminer toutes les erreurs de votre code):</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">error_reporting = E_ALL</div></td></tr></tbody></table></div><p>Quand vous aurez fini vos modifications, sauvegardez et allez dans vos préférences système pour relancer apache en cliquant sur &laquo;&nbsp;Partage web&nbsp;&raquo;. Important: si la case est déjà cochée veillez à la décocher puis à la sélectionner à nouveau pour relancer Apache sinon vos modification de ne serais pas prises en compte..</p><p>Cliquez sur le lien &laquo;&nbsp;Votre site web personnel&nbsp;&raquo; ce qui lancera votre navigateur préféré qui affichera la page contenue dans le dossier &laquo;&nbsp;Sites&nbsp;&raquo; de votre répertoire Personnel. ex: /Users/~crashdump/Sites/ pour moi.</p><p>Rendez vous dans ce répertoire supprimez les fichiers qu&#8217;il contient (index.html..) et créez y un fichier index.php avec le code suivant à l&#8217;intérieur:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;lt;?php phpinfo(); ?&amp;gt;</div></td></tr></tbody></table></div><p>Sauvegardez et actualisez le navigateur.. Félicitions (oui, encore) ça fonctionne.</p><p><a href="http://www.crashdump.fr/wp-content/uploads/2008/09/safari-phpmac.jpg"><img class="alignnone size-thumbnail wp-image-386" title="safari-phpmac" src="http://www.crashdump.fr/wp-content/uploads/2008/09/safari-phpmac-430x125.jpg" alt="" width="430" height="125" /></a></p><li><h2>Problèmes recontrés</h2></li><p>Si vous avez fait une mise à jour de Léopard depuis une version précédente 1.x.x vous pouvez rencontrer un problème avec l&#8217;accès a vos pages personnelles (par exemple: &laquo;&nbsp;Forbiden, You don&#8217;t have permission to access /~user on this server.&nbsp;&raquo;) pour régler cela une petite manipulation est nécessaire, car des fichiers indispensables au bon fonctionnement de la chose sont manquants.</p><p>Ouvrez un Terminal:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cd /private/etc/httpd/users<br /> $ ls</div></td></tr></tbody></table></div><p>Vous devriez voir un fichier de la forme: votreLogin.conf, par exemple chez moi il s&#8217;appelle crashdump.conf, nous allons donc les copier dans le répertoire aproprié:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ sudo cp *.conf /private/etc/apache2/users</div></td></tr></tbody></table></div><p>Redémarrez apache à nouveau, (Préférences système, partage..) tout devrait fonctionner maintenant. Vous pouvez aussi avoir des informations sur les erreurs potentielles en tapant:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ tail -n 30 /var/log/apache2/error_log</div></td></tr></tbody></table></div> ]]></content:encoded> <wfw:commentRss>http://www.crashdump.fr/reseaux/activer-apache2php5-sous-mac-os-x-105-382/feed/</wfw:commentRss> <slash:comments>21</slash:comments> </item> <item><title>Optimiser votre base de donnée mysql ?</title><link>http://www.crashdump.fr/coding/optimiser-votre-base-de-donnee-mysql-131/</link> <comments>http://www.crashdump.fr/coding/optimiser-votre-base-de-donnee-mysql-131/#comments</comments> <pubDate>Fri, 09 May 2008 16:36:15 +0000</pubDate> <dc:creator>Crashdump</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[optimisation]]></category> <category><![CDATA[php]]></category> <category><![CDATA[script]]></category> <category><![CDATA[tables]]></category><guid isPermaLink="false">http://blog.crashdump.fr/?p=131</guid> <description><![CDATA[Nous allons voir ici ce qu&#8217;est l&#8217;optimisation d&#8217;une BDD Mysql (MyISAM). Je vous fourni même a la fin, un petit bout de code en php pour réaliser cette optimisation régulierement.. :) C&#8217;est quoi ? Le type de table par défaut de MySQL est MyISAM (Table non transactionnelle: une base de type non transactionnelle lorsqu&#8217;une erreur [...]]]></description> <content:encoded><![CDATA[<p><em>Nous allons voir ici ce qu&#8217;est l&#8217;optimisation d&#8217;une BDD Mysql (MyISAM). Je vous fourni même a la fin, un petit bout de code en php pour réaliser cette optimisation régulierement.. :)</em></p><h2><li>C&#8217;est quoi ?</li></h2><p>Le type de table par défaut de MySQL est MyISAM (Table non transactionnelle: une base de type non transactionnelle lorsqu&#8217;une erreur se produit, exécute tout ce qui se trouvait avant l&#8217;erreur a l&#8217;inverse de la table transactionnelle). Un système très performant, oui, mais qui laisse parfois a désirer quand a la fragmentation &#8211; il lui arrive de laisser trainer des morceaux a droite et a gauche. Oui, ils sont infimes et peut nombreux.. n&#8217;empêche qu&#8217;a force de requêtes (suppression, modification &#8230;), il reste des fois des &laquo;&nbsp;débris&nbsp;&raquo; de donnée qui trainent par ci par là dans la table.</p><p>Il faut donc ranger tout ça parfois ! Inutile de le faire tous les jours, sauf bien sur si votre site a un trafic incroyablement développé.. Personnellement je l&#8217;effectue toutes les semaines.</p><h2><li>Ok, on fait comment ?</li></h2><p>Bêtement en executant cette instruction mysql:<span id="more-131"></span></p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt; OPTIMIZE TABLE `unetable`, `uneautretable`</div></td></tr></tbody></table></div><p>La je suppose que vous vous demandez combien de temps cela va prendre de taper les instructions pour vos 30 tables.. j&#8217;ai eu la même réaction. Voici donc, pour vous mon script d&#8217;optimisation en php:</p><div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;?php<br /> $link = mysql_connect('localhost', 'root', 'motdepasse');<br /> ?&gt;<br /> &lt;html&gt;<br /> Selectionnez la base a optimiser:<br /> &lt;form action=&quot;#&quot; method=&quot;post&quot;&gt;<br /> &lt;select name=&quot;base&quot;&gt;<br /> &lt;?php<br /> $db_list = mysql_list_dbs($link);<br /> while ($row = mysql_fetch_object($db_list))<br /> {<br /> &nbsp; &nbsp; &nbsp; &nbsp; echo '&lt;option value=&quot;'.$row-&gt;Database.'&quot;&gt;'.$row-&gt;Database.'&lt;/option&gt;';<br /> }<br /> ?&gt;<br /> &lt;/select&gt;<br /> &lt;input type=&quot;submit&quot; value=&quot;Envoyer&quot;&gt;<br /> &lt;/form&gt;<br /> &lt;?php<br /> if(isset($_POST[&quot;base&quot;]))<br /> {<br /> &nbsp; &nbsp; &nbsp; &nbsp; $table = mysql_list_tables($_POST[&quot;base&quot;]);<br /> &nbsp; &nbsp; &nbsp; &nbsp; //on prépare la requête<br /> &nbsp; &nbsp; &nbsp; &nbsp; $sql = &quot;OPTIMIZE TABLE &quot;;<br /> &nbsp; &nbsp; &nbsp; &nbsp; //on recherche toutes les données des tables<br /> &nbsp; &nbsp; &nbsp; &nbsp; $req = mysql_query('SHOW TABLE STATUS');<br /> &nbsp; &nbsp; &nbsp; &nbsp; while($data = mysql_fetch_assoc($req))<br /> &nbsp; &nbsp; &nbsp; &nbsp; {<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //on regarde seulement les tables qui affichent des pertes<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($data['Data_free'] &gt; 0)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //et on l'inclut si elle comporte des pertes<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql .= '`'.$data['Name'].'`, ';<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /> &nbsp; &nbsp; &nbsp; &nbsp; }<br /> &nbsp; &nbsp; &nbsp; &nbsp; //on enlève le ', ' de trop<br /> &nbsp; &nbsp; &nbsp; &nbsp; $sql = substr($sql, 0, (strlen($sql)-2));<br /> &nbsp; &nbsp; &nbsp; &nbsp; //et on optimise<br /> &nbsp; &nbsp; &nbsp; &nbsp; mysql_query($sql);<br /> &nbsp; &nbsp; &nbsp; &nbsp; echo 'Optimisation de '.$_POST[&quot;base&quot;].' terminée..';<br /> &nbsp; &nbsp; &nbsp; &nbsp; mysql_close();<br /> }<br /> ?&gt;<br /> &lt;/html&gt;</div></td></tr></tbody></table></div><p>Bonne optimisation ;)</p> ]]></content:encoded> <wfw:commentRss>http://www.crashdump.fr/coding/optimiser-votre-base-de-donnee-mysql-131/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Served from: www.crashdump.fr @ 2012-02-04 18:45:56 by W3 Total Cache -->
