我已经制作了一个非常基本的网站,它使用 PHP 和 MySQLI 具有注册和登录功能,基本上我认为我没有完全掌握它但我正在尝试使用 burp 套件发起 sql 注入攻击以尝试想一想如何从我的 SQL 数据库中检索值或使用未知密码绕过任何类型的登录。例如,假设有一个名为“admin”的用户,我想以“admin”身份登录但不知道密码,我可以使用什么技术用于使用 SQL 注入来绕过这个。(这是我的网站 https://csci400sqlgroup6.000webhostapp.com/login.php)我授予任何可以攻击它的权限,因为数据库中没有存储任何重要内容,而且它是用于课堂的研究。如果你能成功发起攻击,请告诉我它是如何完成的以及它是如何工作的。
以下是我如何将我的数据库连接到我的登录页面。
<?php
session_start();
include("connection.php");
include("functions.php");
if($_SERVER['REQUEST_METHOD'] == "POST")
{
//something was posted
$user_name = $_POST['user_name'];
$password = $_POST['password'];
if(!empty($user_name) && !empty($password) && !is_numeric($user_name))
{
//read from database
$query = "select * from users where user_name = '$user_name' limit 1";
$result = mysqli_query($conn, $query);
if($result)
{
if($result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
if($user_data['password'] === $password)
{
$_SESSION['user_id'] = $user_data['user_id'];
header("Location: index.php");
die;
}
}
}
echo "wrong username or password!";
}else
{
echo "wrong username or password!";
}
}
?>
我希望绕过使用密码以“admin”身份登录或能够检索存储的 SQL 数据库的需要,该网站是为了研究而故意设计的。本质上,在使用基本的 sql 注入攻击攻击 burp 套件中的“user_name”和“password”值时,我没有收到任何特定错误,但是什么也不会发生,因为我只会收到“错误的用户名或密码”错误。