Hi @all
War schon lange nicht mehr hier. ![]()
Also ich hab mich heute morgen mal rangesetzt um ein bischen mit SQL Injections herumzuspielen.
Da musste ich feststellen, dass diese fast unmöglich sind.
Hier mein 1. Code:
PHP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SQL Injection</title>
</head>
<body>
<?php
include_once 'mysql.php';
if(MySQL::connect() === MySQL::MySQL_Success)
{
if(isset($_GET['check']))
{
echo 'name="'.$_POST['username'].'" AND password="'.md5($_POST['password']).'"';
$result = MySQL::count_entry('users', 'name="'.$_POST['username'].'" AND password="'.md5($_POST['password']).'"');
if($result == 1)
{
echo '<h1>Success</h1>';
}
else
{
echo '<h1>LOL</h1>';
}
}
else
{
echo '<h1>Login</h1>';
echo '<form action="SQL_Injection.php?check=1" method="POST">';
echo '<p>Username:<br><input name="username" type="text" size="30" /></p>';
echo '<p>Password:<br><input name="password" type="password " size="30" /></p>';
echo '<p><input type="submit" value=" Absenden "></p>';
echo '</form>';
}
}
else
{
echo '<p style="font-weight: bolder; font-size: 48px; font-family: Arial;">Leider keine Datenbank!</p>';
}
?>
</body>
</html>
Alles anzeigen
Falls nun die Eingabe beim Feld "Username" == {administrator" or "1"=="1} ist und bei Passwort == {aei" or "1"=="1}
Dann funktioniert es auch nicht da das ganze Passwortfeld in md5 verschlüsselt wird.
Querry: name="administrator" or "1"=="1" AND password="a609b99b7ef9fb9652b330170242eeb8"
Hab ich da einen Überlegungsfehler? Falls nein müsste man sehr schlecht programmieren um eine SQL Injection möglich zu machen.