No live database here: reason it through. This is the login endpoint of a legacy app.
And this is the
An attacker posts
php
<?php
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = "SELECT id, user, notes FROM users WHERE user = '$user' AND pass = '$pass'";
$row = mysqli_fetch_assoc(mysqli_query($conn, $sql));
if ($row) { echo "Welcome " . $row['user'] . " — note: " . $row['notes']; }And this is the
users table, in insertion order:python
id | user | pass | notes
---+---------+------------------+--------------------------------------------------
1 | admin | 9f2c1b... | bnVsbGhhdmVue3VuaW9uX3NlbGVjdF9ldmVyeXRoaW5nfQ==
2 | alice | 4d51aa... | cGxlYXNlIHJvdGF0ZSBteSBrZXk=
3 | bob | 77e0f3... | bm90aGluZyB0byBzZWUgaGVyZQ==An attacker posts
user=' OR 1=1 -- with any password. Work out exactly what the page prints, and decode it.