-
Notifications
You must be signed in to change notification settings - Fork 0
/
readAttack.py
40 lines (24 loc) · 913 Bytes
/
readAttack.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
import requests
URL = "https://attack.mitre.org/techniques/T1055/"
page = requests.get(URL)
index = 0
while index != -1:
index = page.text.find("https://capec.mitre.org/data/definitions", index)
print(index)
if index != -1:
endUrlIndex = page.text.find('"', index)
capecUrl = page.text[index:endUrlIndex]
print(capecUrl)
capecPage = requests.get(capecUrl)
cweIndex = 0
while cweIndex != -1:
cweIndex = capecPage.text.find("http://cwe.mitre.org/data/definitions", cweIndex)
if cweIndex != -1:
endCweIndex = capecPage.text.find('"', cweIndex)
cweUrl = capecPage.text[cweIndex:endCweIndex]
cweId = "CWE-" + cweUrl.split('/')[-1].split('.')[0]
print(cweId)
cweIndex += 1
else:
break
index += 1