Files
BLEN/poc/Redis/Unauth_Access/poc.py
openx-org f310dd03ff v.1.0
2021-12-21 16:37:18 +08:00

82 lines
2.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding:utf-8
import redis
from lib.core.common import url_handle,get_random_ua
from lib.core.poc import POCBase
from lib.core.log import logwarning
# ...
import urllib3
urllib3.disable_warnings()
class POC(POCBase):
def __init__(self, host, proxy=None):
if host.startswith("redis://"):
self.target = host[8:]
elif host.startswith("http://") or host.startswith("https://"):
self.target = host.split("://")[1]
else:
err_msg = "The target format cannot be parsed : %s , exit the POC"%(host)
logwarning(err_msg)
exit()
self.proxy = None
self.timeout = 10
_info = {
"author" : "jijue", # POC作者
"version" : "1", # POC版本默认是1
"CreateDate" : "2021-06-09", # POC创建时间
"UpdateDate" : "2021-06-09", # POC创建时间
"PocDesc" : """
出于专注与web领域的考虑本POC仅简单支持检测redis未授权访问而已,
另外redis连接比较慢扫起来会比http要久很多扫之前做好心理准备
""", # POC描述写更新描述没有就不写
"name" : "Redis未授权访问", # 漏洞名称
"VulnID" : "", # 漏洞编号以CVE为主若无CVE使用CNVD若无CNVD留空即可
"AppName" : "Redis", # 漏洞应用名称
"AppVersion" : "", # 漏洞应用版本
"VulnDate" : "2021-06-09", # 漏洞公开的时间,不知道就写今天格式xxxx-xx-xx
"VulnDesc" : """
""", # 漏洞简要描述
"fofa-dork":"""
app="redis"
""", # fofa搜索语句
"example" : "", # 存在漏洞的演示url写一个就可以了
"exp_img" : "", # 先不管
}
def _verify(self):
"""
返回vuln
存在漏洞vuln = [True,html_source] # html_source就是页面源码
不存在漏洞vuln = [False,""]
"""
vuln = [False,""]
redis_host = self.target.split(":")[0] # url自己按需调整
redis_port = self.target.split(":")[1]
try:
"""
检测逻辑漏洞存在则修改vuln值为True漏洞不存在则不动
"""
r = redis.Redis(redis_host, port=redis_port, db=0, socket_timeout=6.0)
if r.ping() is True:
vuln = [True,"connect success"]
else:
vuln = [False,"connect field"]
except Exception as e:
raise e
return vuln
def _attack(self):
return self._verify()