select * from ttt where name = 'shuibianshu' * 'xxooxxoo'
这条语句为什么可以把 ttt 表里的全部数据查出来? 后面星号两边的字符串可以随便乱输。
select * from ttt where name = 'shuibianshu' * 'xxooxxoo'
这条语句为什么可以把 ttt 表里的全部数据查出来? 后面星号两边的字符串可以随便乱输。
|
EchoUtopiaApr 22, 2016
1
我试的时候返回的星号后面那个条件的查询结果
|
|
SilentDepthApr 22, 2016
2
我是想说,那个字念 suí……
|
|
lancerliuApr 22, 2016
3
数据库类型和版本呢?
我执行这条语句是报错的 |
|
5
@SilentDepth 哈哈 我的平翘舌一直有问题 ;)
|
|
cdxyApr 22, 2016
6
aaa' or 1=1 --
注意--右边有空格,在 url 里面可以 --+ 完整语句: select * from ttt where name='aaa' or 1=1 -- ' * 'xxx'; |
|
7
'shuibianshu' * 'xxooxxoo'===>0
试试: select 'shuibianshu' * 'xxooxxoo' from ttt where name = 'shuibianshu' * 'xxooxxoo' |
|
8
后面两个字符串中间的星号 是做了乘法运算 结果是 0 , 然后匹配字符串的时候,表里的字符串都被转成了 0 , 0=0 ,所以就都查出来了。 参考资料: http://stackoverflow.com/questions/22080382/mysql-why-comparing-a-string-to-0-gives-true
|
|
ivveiApr 22, 2016
9
Mysql 奇葩问题就是多啊
|
|
liyj144Apr 22, 2016
10
因为'shuibianshu' * 'xxooxxoo' 的值是整数类型的 0 , 然后查询是 name 先做整型转换,然后和 0 对比,因为一般字符串(只要首字符不是数字的,比如 1qwe 这样的记录)都转成了 0 ,所以就造成了这种假象。
|
|
lancerliuApr 22, 2016
11
|
|
loadingApr 22, 2016
12
这个是考试题?
|
|
billleeApr 22, 2016
13
看了这个,我只想说,弱类型真可怕。
|
|
SunnySuoAug 4, 2016
14
楼主,我司招后端开发工程师( golang ), web 前端工程师、资深软件工程师,欢迎关注! http://v2ex.com/t/296530#reply3
|