- Code: Select all
[spoiler]your answers[/spoiler]
In this lesson, explain the various vulnerabilities found in this code, next, create a test-case that can be used to find out how an attacker would exploit those vulnerabilities.
Once a sufficient number of answers are given, I will break down the responses and the code.
Login action page:
- Code: Select all
<?php
$user = $_POST['username'];
$pass = $_POST['password'];
$select_admin = mysql_query("SELECT * FROM cms_admin");
while ($dati_admin = mysql_fetch_array($select_admin))
{
$username = $dati_admin['username'];
$password = $dati_admin['password'];
}
if ($user == $username && $pass == $password)
{
setcookie("login", "OK", time() + $logintime);
}
admin/delete_page.php
- Code: Select all
$admin = ($_COOKIE['login'] == 'OK') ? true : false;
if ($admin)
$id = $_GET['id'];
$delete = mysql_query("DELETE FROM cms_content WHERE id='$id'");
if ($delete)
{
echo "" . _DELETE_PAGE_SUCCESS . "";
}
else
{
echo "" . _DELETE_PAGE_ERROR . "";
}
}















