Created
November 27, 2016 20:47
-
-
Save wellingtonlee/32cd99a7f6202ec8c01279cb90c0c09e to your computer and use it in GitHub Desktop.
SQL Injection Vulnerable PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sql_username = "root"; | |
$sql_password = "forensics"; | |
$db_name = "vuln"; | |
if (isset($_GET['username'])) | |
{ | |
$username = $_GET['username']; | |
$password = $_GET['password']; | |
} | |
// Create connection | |
$conn = new mysqli($servername, $sql_username, $sql_password, $db_name); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
$sql = "select * from users WHERE user_name = '$username'"; | |
$result = $conn->query($sql); | |
if($result->num_rows>0) | |
{ | |
while ($row = $result->fetch_assoc()){ | |
if (!strcmp($password,$row["password"])) | |
{ | |
echo "welcome $username:"; | |
echo "<br/>"; | |
echo "you successfully login!"; | |
} | |
else | |
{ | |
echo "sorry $username"; | |
echo "<br/>"; | |
echo "your login credential is not correct!"; | |
} | |
} | |
} | |
else | |
{ | |
echo "Error: username does not exists!"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment