2021-12-21 16:37:18 +08:00
|
|
|
|
# coding:utf-8
|
|
|
|
|
|
import requests
|
|
|
|
|
|
from lib.core.common import url_handle,get_random_ua
|
|
|
|
|
|
from lib.core.poc import POCBase
|
|
|
|
|
|
# ...
|
|
|
|
|
|
import urllib3
|
|
|
|
|
|
urllib3.disable_warnings()
|
|
|
|
|
|
|
|
|
|
|
|
class POC(POCBase):
|
|
|
|
|
|
|
|
|
|
|
|
_info = {
|
|
|
|
|
|
"author" : "jijue", # POC作者
|
|
|
|
|
|
"version" : "1", # POC版本,默认是1
|
|
|
|
|
|
"CreateDate" : "2021-06-09", # POC创建时间
|
|
|
|
|
|
"UpdateDate" : "2021-06-09", # POC创建时间
|
|
|
|
|
|
"PocDesc" : """
|
|
|
|
|
|
略
|
|
|
|
|
|
""", # POC描述,写更新描述,没有就不写
|
|
|
|
|
|
|
|
|
|
|
|
"name" : "H2 数据库 Web控制台未授权访问", # 漏洞名称
|
2022-04-24 14:09:03 +08:00
|
|
|
|
"VulnID" : "oFx-2021-0001", # 漏洞编号,以CVE为主,若无CVE,使用CNVD,若无CNVD,留空即可
|
2021-12-21 16:37:18 +08:00
|
|
|
|
"AppName" : "H2 数据库", # 漏洞应用名称
|
|
|
|
|
|
"AppVersion" : "", # 漏洞应用版本
|
|
|
|
|
|
"VulnDate" : "2021-06-09", # 漏洞公开的时间,不知道就写今天,格式:xxxx-xx-xx
|
|
|
|
|
|
"VulnDesc" : """
|
|
|
|
|
|
H2 数据库是 Java 中的嵌入式内存数据库。
|
|
|
|
|
|
带有 h2 数据库的 Springboot 带有一个 web 管理页面,
|
|
|
|
|
|
如果您设置以下选项,则该页面没有身份验证:
|
|
|
|
|
|
spring.h2.console.enabled=true
|
|
|
|
|
|
spring.h2.console.settings.web-allow-others=true
|
|
|
|
|
|
""", # 漏洞简要描述
|
|
|
|
|
|
|
|
|
|
|
|
"fofa-dork":"""
|
|
|
|
|
|
"springboot"
|
|
|
|
|
|
""", # fofa搜索语句
|
|
|
|
|
|
"example" : "", # 存在漏洞的演示url,写一个就可以了
|
|
|
|
|
|
"exp_img" : "", # 先不管
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def _verify(self):
|
|
|
|
|
|
"""
|
|
|
|
|
|
返回vuln
|
|
|
|
|
|
|
|
|
|
|
|
存在漏洞:vuln = [True,html_source] # html_source就是页面源码
|
|
|
|
|
|
|
|
|
|
|
|
不存在漏洞:vuln = [False,""]
|
|
|
|
|
|
"""
|
|
|
|
|
|
vuln = [False,""]
|
|
|
|
|
|
url = self.target + "/h2-console/" # url自己按需调整
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
headers = {"User-Agent":get_random_ua(),
|
|
|
|
|
|
"Connection":"close",
|
|
|
|
|
|
# "Content-Type": "application/x-www-form-urlencoded",
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
"""
|
|
|
|
|
|
检测逻辑,漏洞存在则修改vuln值为True,漏洞不存在则不动
|
|
|
|
|
|
"""
|
|
|
|
|
|
req = requests.get(url,headers = headers , proxies = self.proxy ,timeout = self.timeout,verify = False,allow_redirects=False)
|
|
|
|
|
|
if req.status_code == 200 and \
|
|
|
|
|
|
"H2 Console" in req.text and \
|
|
|
|
|
|
"location.href = 'login.jsp?jsessionid=" in req.text and \
|
|
|
|
|
|
"Welcome to H2" in req.text:
|
|
|
|
|
|
vuln = [True,req.text]
|
|
|
|
|
|
else:
|
|
|
|
|
|
vuln = [False,req.text]
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
raise e
|
|
|
|
|
|
|
|
|
|
|
|
# 以下逻辑酌情使用
|
|
|
|
|
|
if self._honeypot_check(vuln[1]) == True:
|
|
|
|
|
|
vuln[0] = False
|
|
|
|
|
|
|
|
|
|
|
|
return vuln
|
|
|
|
|
|
|
|
|
|
|
|
def _attack(self):
|
|
|
|
|
|
return self._verify()
|