From 484bf4c1296bda8e8916fb31fa7b916588ea69a9 Mon Sep 17 00:00:00 2001 From: Vouu Date: Mon, 26 Jul 2021 17:54:48 +0700 Subject: [PATCH] Sql injection attack No check data input lead to sql injection vulnerability. We found a vulnerability in your source code and here's how to fix it. --- confirm.php | 2 +- confirm_register.php | 4 ++-- deactivate.php | 2 +- forgot.php | 2 +- index.php | 2 +- msgchecker.php | 4 ++-- msgpost.php | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/confirm.php b/confirm.php index 5d1e3bc..c973677 100644 --- a/confirm.php +++ b/confirm.php @@ -57,7 +57,7 @@ 0) diff --git a/index.php b/index.php index 67eb5b0..a1293a3 100644 --- a/index.php +++ b/index.php @@ -60,7 +60,7 @@ if(isset($_POST['signin'])) { - $email = $_POST['email']; + $email = mysqli_real_escape_string($conn, $_POST['email']); $password = base64_encode($_POST['password']); // "SELECT * FROM `people` WHERE name='$name'" $sql = "SELECT * FROM `users` WHERE `email`='$email' and `password`='$password'"; diff --git a/msgchecker.php b/msgchecker.php index c4da17c..d04072d 100644 --- a/msgchecker.php +++ b/msgchecker.php @@ -2,7 +2,7 @@ session_start(); include 'connection.php'; - $name = $_POST['name']; + $name = mysqli_real_escape_string($conn, $_POST['name']); // $sql = "SELECT convs, stored_at, ip FROM conv WHERE name = '$name';"; $sql = "SELECT `convs`, `ip`, `stored_at` FROM `conv` WHERE chatroom = '$name' ORDER BY `id` DESC"; // print_r($sql); @@ -19,7 +19,7 @@ while ($row = mysqli_fetch_assoc($result)) { if($row['ip'] == $remote_ip) { - $sql1 = "SELECT `convs`, `ip`, `stored_at` FROM `conv` WHERE chatroom = '$name' AND ip = $remote_ip ORDER BY `id` DESC"; + $sql1 = "SELECT `convs`, `ip`, `stored_at` FROM `conv` WHERE chatroom = '$name' AND ip = $remote_ip ORDER BY `id` DESC"; $res = $res.'
'; $res = $res.'You'; $res = $res."

".$row['convs']; diff --git a/msgpost.php b/msgpost.php index 7ee0886..56533b8 100644 --- a/msgpost.php +++ b/msgpost.php @@ -1,8 +1,8 @@