0

我想在表单上做一个sql注入的小测试

表单将检索名称和 mdp 并检查数据是否存在于数据库中 这是表单代码-我不使用准备好的查询-

登录.php

<?php

  try
  {
    $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
    $bdd = new PDO('mysql:host=localhost;dbname=tuto', 'root', '',
     $pdo_options);

    }catch(Exception $e)
     {
     die('Erreur : '.$e->getMessage());
     }


    if(!empty( $_POST['username']) AND !empty( $_POST['password'])) {
    $login = $_POST['username'];
    $password = $_POST['password'];


   // Requête SQL
         $req = $bdd->query("SELECT * FROM sqli WHERE username='$login' AND                   password='$password'") or die("erreur ".mysql_error());
   $donnees = $req->fetch();
   $row=mysql_fetch_array($result);

  if ($row['username']==$username && $row['password']==$password) {

    echo "login succceful".$row['username'];

    } else {
    echo "login unsuccceful";
    }


      }

    ?>  

表单.php

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">

<!-- <link       href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"   rel="stylesheet" integrity="sha384-  BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"   crossorigin="anonymous"> -->
   <title>SQLI</title>
    </head>

    <h1>  Connect </h1>



  <html>
   <body>
        < form action="login.php" method="POST">
           <p>username:</p><input type="text" name="username" />
           <p>password:</p><input type="password" name="password" />
           <br />
           <input type="submit" value="Login" />
        </form>


      </body>
     </html>

     </html>

你有一些建议如何做这个查询

$req = $bdd->query("SELECT * FROM sqli WHERE username='snort' OR 1=1 --AND     password='123 ")

谢谢

4

0 回答 0