Very often programmers, not bring into their web applications security for the simple fact that they do not know the risks…
Here is an example of vulnerable application php, with its schema mysql:
Example:
Table: users(id int, user char(25), password char(25), );
+---+---------+----------------------------------+
| 1 | admin | password 1 |
+---+---------+----------------------------------+
| 2 | pepelux | password2 |
+---+---------+----------------------------------+
Table: news(id int, title char(25), text TEXT), );
+---+---------+----------------------------------+
| 1 | title | content 1 |
+---+---------+----------------------------------+
| 2 | title | content 1 |
+---+---------+----------------------------------+
Vulnerable code:
<?php
@include("config.php")
$id = $_GET['id'];
$result = mysql_query("SELECT title,text FROM news WHERE id=$id LIMIT 1");
$row = mysql_fetch_array($result);
....
?>
(more…)