Trying some malicious injection against bWAPP and came across bypass captcha
Filter validating captcha is
if($_POST["captcha_user"] == $_SESSION["captcha"])
Tried input 1' || '2
but it doesn't bypass logical condition.
Trying some malicious injection against bWAPP and came across bypass captcha
Filter validating captcha is
if($_POST["captcha_user"] == $_SESSION["captcha"])
Tried input 1' || '2
but it doesn't bypass logical condition.
Ok, this is a prime example of why you have to understand a system for you to be able to breach it. That's probably the point of this exercise as well; you need to know and notice security vulnerabilities.
If you don't know a particular one: you have to be able to read technical documentation, and figure out how to use a particular weakness. In this case the weakness has been pointed out specifically: the ==
comparator - with a link to how it works. From the description of how it works, you have to be able to figure out how to attack it.
==
is hilighted as insecure in many, many places. ===
is the recomended comparator when user input is involved (or in general even).
How ==
works is clearly documented, type for type. Furthermore, you can test what is the expected value of the $_SESSION["captcha"]
by visiting the page and submitting a valid captcha.
And as you know the language and source code, you can trivially test it on your own computer:
<?php
$captcha = "somestring";
$userinput = true;
if ($userinput == $captcha)
{
print("== leads to truthy eval\n");
}
if ($userinput === $captcha)
{
print("=== leads to truthy eval\n");
}
?>
What do you expect that this snippet will output? true
is obviously not equal to "somestring"
.
That's the point of this excersize: hilight a common security vulnerability in PHP code, and teach you how it works, and what protections you can use against it.