2024-01-03 13:20:15 +08:00
|
|
|
import requests
|
|
|
|
|
import json
|
|
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
|
|
from rprint import *
|
|
|
|
|
from lxml import etree
|
|
|
|
|
|
|
|
|
|
search_url = "https://www.opencve.io/cve?cvss=&search={product}&page={page}"
|
|
|
|
|
|
|
|
|
|
def get_cve_json(product: str, page: int) -> list:
|
|
|
|
|
header = ["CVE","Vendors","Products","Updated","CVSS v2","CVSS v3","cve-summary"]
|
|
|
|
|
url = search_url.format(product=product, page=page)
|
|
|
|
|
ret = []
|
|
|
|
|
r =requests.get(url)
|
|
|
|
|
if r.status_code == 200:
|
|
|
|
|
html_tree = etree.HTML(r.text)
|
|
|
|
|
table_html = html_tree.xpath('//*[@id="cves"]')
|
|
|
|
|
if table_html:
|
|
|
|
|
table_html = table_html[0]
|
|
|
|
|
else:
|
|
|
|
|
return []
|
|
|
|
|
table_html = etree.tostring(table_html, pretty_print=True, encoding='utf-8')
|
|
|
|
|
df_list = pd.read_html(table_html)
|
|
|
|
|
df = df_list[0]
|
|
|
|
|
table_data = df.values.tolist()
|
|
|
|
|
table_data.insert(0,header)
|
|
|
|
|
counter = 0
|
|
|
|
|
for row in table_data[1:]:
|
|
|
|
|
if counter%2 == 0:
|
|
|
|
|
ret.append(dict(zip(header, row)))
|
|
|
|
|
else:
|
2024-01-03 14:13:05 +08:00
|
|
|
ret[-1].update({"cve-summary": row[0].lower()})
|
2024-01-03 13:20:15 +08:00
|
|
|
counter += 1
|
|
|
|
|
return ret
|
|
|
|
|
else:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
def result_init(result: dict, cve_list: list) -> None:
|
|
|
|
|
# tmp = {name:{"overflow": 0, "RCE": 0, "command injection": 0,}}
|
|
|
|
|
for cve in cve_list:
|
2024-01-03 14:13:05 +08:00
|
|
|
if type(cve["Products"]) == str and cve["CVE"][4:8] == "2023":
|
2024-01-03 13:20:15 +08:00
|
|
|
for name in cve["Products"][2:].split(", "):
|
|
|
|
|
try:
|
2024-01-03 14:13:05 +08:00
|
|
|
if name not in result.keys():
|
|
|
|
|
if name == "Ac18":
|
|
|
|
|
info("-----",cve)
|
|
|
|
|
result.update({name:{"total cve":0, "overflow": 0, "command injection": 0,}})
|
2024-01-03 13:20:15 +08:00
|
|
|
except:
|
|
|
|
|
error("Error in init, proble wrong product")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stastic(result: dict, cve_list: list) -> bool:
|
2024-01-03 14:13:05 +08:00
|
|
|
ret = True
|
2024-01-03 13:20:15 +08:00
|
|
|
result_init(result, cve_list)
|
|
|
|
|
for cve in cve_list:
|
2024-01-03 14:13:05 +08:00
|
|
|
if "2023" in cve["CVE"][:9]:
|
|
|
|
|
if type(cve["Products"]) == str:
|
|
|
|
|
for name in cve["Products"][2:].split(", "):
|
|
|
|
|
if "overflow" in cve["cve-summary"].lower():
|
|
|
|
|
result[name]["overflow"] += 1
|
|
|
|
|
if "command injection" in cve["cve-summary"].lower():
|
|
|
|
|
result[name]["command injection"] += 1
|
|
|
|
|
result[name]["total cve"] += 1
|
2024-01-03 13:20:15 +08:00
|
|
|
else:
|
2024-01-03 14:13:05 +08:00
|
|
|
ret = False
|
|
|
|
|
return ret
|
2024-01-03 13:20:15 +08:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
banner()
|
2024-01-03 14:13:05 +08:00
|
|
|
# keywords = ["tenda","tp-link","mercury"]
|
|
|
|
|
keywords = ["tenda",]
|
2024-01-03 13:20:15 +08:00
|
|
|
for word in keywords:
|
|
|
|
|
cve_list = get_cve_json(word,1)
|
|
|
|
|
result = {}
|
2024-01-03 14:13:05 +08:00
|
|
|
page = 1
|
2024-01-03 13:20:15 +08:00
|
|
|
while(stastic(result, cve_list)):
|
|
|
|
|
# info(word, page)
|
|
|
|
|
cve_list = get_cve_json(word,page)
|
|
|
|
|
page+=1
|
|
|
|
|
with open(word+".log","w") as f:
|
|
|
|
|
f.write(str(result))
|
|
|
|
|
f.write("\n")
|
|
|
|
|
info("="*0x10," "*5,word," "*5,"="*0x10)
|
|
|
|
|
for i in result:
|
|
|
|
|
success(i.ljust(35," "), result[i])
|