Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 15/04/2011, 23h49   #1
Invité de passage
 
Homme Youyou
Administrateur de base de données
Inscription : avril 2011
Messages : 16
Détails du profil
Informations personnelles :
Nom : Homme Youyou
Âge : 20
Localisation : Maroc

Informations professionnelles :
Activité : Administrateur de base de données
Secteur : Boutique - Magasin

Informations forums :
Inscription : avril 2011
Messages : 16
Points : 1
Points : 1
Envoyer un message via MSN à Prototype
Par défaut Faille // Injection SQL

J'utilise Kiiz'CMS qui fournit une boutique qui comporte une grosse faille de type "Injection SQL". Les Hackeurs peuvent mettre une simple quote ' dans la barre d'adresse (&cat=1) ==> (&cat='1) et provoquer des erreurs pour que mysql_error() indique des infos sur la BDD. Le Hackeur a donc accès a tout les comptes. Merci de m'aider à résoudre cette faille.

Voici la page php:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<div class="titleSite"><b>&#8362;</b> Boutique !</div>
<?php
if ($connect) {
	echo '<center>Vous avez actuellement <b>'.$compte->points.'</b> PB à dépenser.</center><br><center><b>[Veuillez selectionner une catégorie]</center></b><br />';
 
	}
?>
<br />
 
<center><table width="95%"><tr>
		<td><a href="index.php?p=boutique&cat=1"><center>Equipements</center></a></td>
		<td><a href="index.php?p=boutique&cat=2"><center>Dofus</center></a></td>
		<td><a href="index.php?p=boutique&cat=4"><center>Armes</center></a></td>
		<td><a href="index.php?p=boutique&cat=5"><center>Familiers</center></a></td>
		<td><a href="index.php?p=boutique&cat=6"><center>Divers</center></a></td>
</tr></table><br /></center>
 
<?php
		switch ($_GET['cat'])
		{
			case 1: // EQUIPEMENT SPECIALE
			case 2: // DOFUS 
			case 4:	// ARMES SPECIALE OU FM
			case 5: // FAMILIER SPECIALE
			case 6: // DIVERS ET AUTRES
 
		$repItems = mysql_query("SELECT ID FROM boutique_objets WHERE type='".$_GET['cat']."' ORDER BY ID");
				while ($donItems = mysql_fetch_array($repItems))
				{
					$itemActuel = new Item($donItems[0]);
		?>
 
<div id="bgBoutique">	
<object style="position:absolute;margin-top: 75px; margin-left: 384px;"width="88px;" height="88px" type="application/x-shockwave-flash" data="img_boutique/swf/<?php echo $itemActuel->swf; ?>">
<param name="movie" value="img_boutique/swf/<?php echo $itemActuel->swf; ?>" />
<param name="wmode" value="transparent" />
</object>
<span style="overflow:hidden; overflow-x: hidden; overflow-y: auto; overflow : -moz-scrollbars-vertical; width: 197px; height: 120px;text-align: left;position:absolute;margin-top: 44px; margin-left: 170px; font-size: 8.5px;"><?php echo $itemActuel->stats; ?></span>
<span style="position:absolute;margin-top: 48px; margin-left: 54px;">Niveau : <b><?php echo $itemActuel->level; ?></b></span>
<span style="position:absolute;font-size: 14px;margin-top: 12px; margin-left: 11px;"><b><?php echo $itemActuel->name; ?></b><i><b><small> = <font color="red"><?php echo $itemActuel->cout; ?> PB</b></font></small></i></span>
<a href="index.php?p=acheter&objet=<?php echo $itemActuel->ID; ?>"><div style="margin-top:126px;margin-left:30px;position:absolute;width:97px;height:45px;"></div></a>
</div>
 
<center>_ _ _ _ _ _ _ _ _ _ _ _ _ _</center><br />
 
<?php
				}
 
			break;
 
			default:
			?><center>[Veuillez selectionner une catégorie]</center><br /><?php
			break;
		}
 
?>
Prototype est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/04/2011, 00h09   #2
Membre émérite
 
Avatar de vorace
 
Homme
Développeur
Inscription : août 2010
Messages : 587
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Meurthe et Moselle (Lorraine)

Informations professionnelles :
Activité : Développeur

Informations forums :
Inscription : août 2010
Messages : 587
Points : 861
Points : 861
tu as le choix, avec un mysql_real_escape_string($_GET['cat']) ou un (int)$_GET['cat'], ce qui donne :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<div class="titleSite"><b>&#8362;</b> Boutique !</div>
<?php
if ($connect) {
	echo '<center>Vous avez actuellement <b>'.$compte->points.'</b> PB à dépenser.</center><br><center><b>[Veuillez selectionner une catégorie]</center></b><br />';
 
	}
?>
<br />
 
<center><table width="95%"><tr>
		<td><a href="index.php?p=boutique&cat=1"><center>Equipements</center></a></td>
		<td><a href="index.php?p=boutique&cat=2"><center>Dofus</center></a></td>
		<td><a href="index.php?p=boutique&cat=4"><center>Armes</center></a></td>
		<td><a href="index.php?p=boutique&cat=5"><center>Familiers</center></a></td>
		<td><a href="index.php?p=boutique&cat=6"><center>Divers</center></a></td>
</tr></table><br /></center>
 
<?php
		switch ((int)$_GET['cat'])
		{
			case 1: // EQUIPEMENT SPECIALE
			case 2: // DOFUS 
			case 4:	// ARMES SPECIALE OU FM
			case 5: // FAMILIER SPECIALE
			case 6: // DIVERS ET AUTRES
 
		$repItems = mysql_query("SELECT ID FROM boutique_objets WHERE type='".mysql_real_escape_string($_GET['cat'])."' ORDER BY ID");//ou (int)$_GET['cat']
				while ($donItems = mysql_fetch_array($repItems))
				{
					$itemActuel = new Item($donItems[0]);
		?>
 
<div id="bgBoutique">	
<object style="position:absolute;margin-top: 75px; margin-left: 384px;"width="88px;" height="88px" type="application/x-shockwave-flash" data="img_boutique/swf/<?php echo $itemActuel->swf; ?>">
<param name="movie" value="img_boutique/swf/<?php echo $itemActuel->swf; ?>" />
<param name="wmode" value="transparent" />
</object>
<span style="overflow:hidden; overflow-x: hidden; overflow-y: auto; overflow : -moz-scrollbars-vertical; width: 197px; height: 120px;text-align: left;position:absolute;margin-top: 44px; margin-left: 170px; font-size: 8.5px;"><?php echo $itemActuel->stats; ?></span>
<span style="position:absolute;margin-top: 48px; margin-left: 54px;">Niveau : <b><?php echo $itemActuel->level; ?></b></span>
<span style="position:absolute;font-size: 14px;margin-top: 12px; margin-left: 11px;"><b><?php echo $itemActuel->name; ?></b><i><b><small> = <font color="red"><?php echo $itemActuel->cout; ?> PB</b></font></small></i></span>
<a href="index.php?p=acheter&objet=<?php echo $itemActuel->ID; ?>"><div style="margin-top:126px;margin-left:30px;position:absolute;width:97px;height:45px;"></div></a>
</div>
 
<center>_ _ _ _ _ _ _ _ _ _ _ _ _ _</center><br />
 
<?php
				}
 
			break;
 
			default:
			?><center>[Veuillez selectionner une catégorie]</center><br /><?php
			break;
		}
 
?>
__________________
Développeur informatique contrarié...
vorace est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/04/2011, 01h01   #3
Invité de passage
 
Homme Youyou
Administrateur de base de données
Inscription : avril 2011
Messages : 16
Détails du profil
Informations personnelles :
Nom : Homme Youyou
Âge : 20
Localisation : Maroc

Informations professionnelles :
Activité : Administrateur de base de données
Secteur : Boutique - Magasin

Informations forums :
Inscription : avril 2011
Messages : 16
Points : 1
Points : 1
Envoyer un message via MSN à Prototype
Merci à vous.
Prototype est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h24.


 
 
 
 
Partenaires

Hébergement Web