I already know about PHP strings == comparison vulnerabilities
- http://marcosvalle.github.io/ctf/php/2016/05/12/php-comparison-vlun.html
- https://www.owasp.org/images/6/6b/PHPMagicTricks-TypeJuggling.pdf
- https://hydrasky.com/network-security/php-string-comparison-vulnerabilities/
But I can not find the way to bypass == comparison for sha256 string.
Below is the example code:
$username = $mysqli->real_escape_string($_POST['username']);
$password = $mysqli->real_escape_string(hash("sha256", $_POST['password']));
$UserDB = $mysqli->query("SELECT * FROM Database")->fetch_assoc()['value'];
$PwDB = $mysqli->query("SELECT * FROM Database")->fetch_assoc()['value'];
if($UserDB == $username){
if($PwDB == $password){
$_SESSION['admin'] = "Admin_".$username."_Password_".$password;
header("Location: admin.php");
exit;
} else {
$content .= alert("danger", "Password is wrong.");
}
} else {
$content .= alert("danger", "Username is wrong.");
}
Do you have any ideas to bypass sha256 password?
if($_POST['username'] AND $_POST['password']){ // Check username/password with above code. } else if($_POST['username']){ $content .= alert("Please fill all fields."); }