I'm learning about SQL Injection, and I'm playing around on my local machine with vulnerable web application, which has login form.
How the login mechanism works is that it first searches whether there exists a user with the typed username in the database, if there exists, it returns the user data from the database, and then it checks whether what is typed in the password field is equal to the actual user password returned by the database. Please note that there is no hashing of the password involved.
The application uses a query like the one below to retrieve the user's data from the database: "SELECT * FROM accounts WHERE username = '" + username + "'"
. I already used something like this for the username field in the form: test' OR 1=1 LIMIT 1--
, and this actually returns in the application the first user's data from the database (I checked this in debug mode). But, the login still fails, because as I said the password value that I entered, and the actual user's password don't match, simply, when it come to this line of code, it fails:
if (enteredPasswordField.Equals(usersPassword, StringComparison.Ordinal)) return SUCCESS;
else return FAILURE;
And as can be seen the user's password is not involved in the SQL query. I was thinking of starting a new SQL statement at the username field to change the users' password, but it kind of undermines the purpose. Any ideas how can I bypass this?