Reputation: 1269
I'm in the process of learning PHP and MySQL. I came across an example of a SQL injection from the PHP man page, where the final injected SQL query was:
SELECT * FROM users WHERE user='aidan' AND password='' OR ''=''
I'm confused about what the OR ''=''
means in this context? I know what that statement does, but I'm just trying to understand how it can be used in another scenario, and what the ''=''
signifies.
Thanks!
Upvotes: 3
Views: 79
Reputation: 859
It's just an expression that means true, it's not likely to be used on other scenarios
Upvotes: 1
Reputation: 1125
If you were accepting a query in the format of SELECT * FROM users WHERE user='aidan' AND password='$password'
a user could fill in ' OR ''='
for the password which will close out the password field and then allow the SQL query to check if ''=''
which will return true
and cause them to gain access without entering a valid password.
Upvotes: 3
Reputation: 29424
''=''
evaluates always to true.password='' OR ''=''
evaluates therefore also to true.→ The password will not be checked and you are able to gain user access without a correct password.
Upvotes: 4