【问题标题】:why does sql comparison ignore case [duplicate]为什么sql比较忽略大小写[重复]
【发布时间】:2019-12-10 04:50:15
【问题描述】:

我正在做一些 sqli 挑战(overthewire.org,natas Web 应用程序挑战),在其中一个 sqli 挑战中我遇到了以下问题。

当我比较 substr(password,1,1)="a" 时,它会忽略大小写。比如

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

将是真实的,所以将是

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

如果我使用

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

反而一切正常。

有人知道为什么要这样实施吗?这是默认的mysql行为吗? 最好的

【问题讨论】:

  • 谢谢,后面的基本上就是我要找的答案了。

标签: mysql sql sql-injection


【解决方案1】:

简而言之,您可以指定数据库将使用的排序规则,并且大多数默认设置为不区分大小写的排序规则,因此在比较文本时会忽略大小写。

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

【讨论】:

    猜你喜欢
    • 2010-11-07
    • 1970-01-01
    • 2016-01-29
    • 2010-11-26
    • 2014-10-30
    • 2016-09-02
    • 2011-09-16
    相关资源
    最近更新 更多