0

I'm doing some sqli challenges (overthewire.org, the natas web application challenges) and during one of the sqli challenges I encountered the following problem.

when I do compare substr(password,1,1)="a" it will ignore the case. So for example

Select * from users where username="user" and substr(password,1,1)='a'

will be true and so will be

Select * from users where username="user" and substr(password,1,1)='A'

If I use

`Select * from users where username="user" and ascii(substr(password,1,1))=ascii('a')` 

instead everything works fine.

Does someone have information why it is implemented that way? is this the default mysql behaviour? Best

a_horse_with_no_name
  • 440,273
  • 77
  • 685
  • 758
Zapho Oxx
  • 245
  • 1
  • 13

1 Answers1

4

In a nutshell you can specify a collation that the database will use and most default to a case insensitive collation, hence it ignores case when comparing text.

https://dev.mysql.com/doc/refman/8.0/en/charset-general.html