-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_exploit.py
60 lines (49 loc) · 2.4 KB
/
fetch_exploit.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
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
import time
def fetch_exploit_db_links(cve_id):
# Set up Selenium WebDriver with headless option
chrome_options = Options()
chrome_options.add_argument("--headless") # Run in headless mode
chrome_options.add_argument("--disable-gpu") # Disable GPU acceleration (optional)
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
exploit_db_url = f"https://www.exploit-db.com/search?cve={cve_id}"
driver.get(exploit_db_url)
time.sleep(3) # Wait for the page to load
# Parse the page source
soup = BeautifulSoup(driver.page_source, 'html.parser')
# Extract data from the exploit table
exploit_data = []
table = soup.find('table', {'id': 'exploits-table'}) # Ensure there's a table with id 'exploits-table'
if table:
rows = table.find_all('tr')[1:] # Skip header row
for row in rows:
cols = row.find_all('td')
if len(cols) > 1:
# Extract each column data
date = cols[0].text.strip() if cols[0] else None
download_link = f"https://www.exploit-db.com{cols[1].find('a')['href']}" if cols[1].find('a') else None
author = cols[6].text.strip() if cols[6] else None
verified = "mdi-check" in cols[3].find("i").get("class", [])
title = cols[4].text.strip() if cols[4] else None
titlelink =f"https://www.exploit-db.com{cols[4].find('a')['href']}" if cols[4] else None
exploit_type = cols[5].text.strip() if cols[5] else None
platform = cols[6].text.strip() if cols[6] else None
# Append the extracted data to the list
exploit_data.append({
'date': date,
'download_link': download_link,
'verified': verified,
'title': title,
'type': exploit_type,
'platform': platform,
'author': author,
'titlelink': titlelink
})
driver.quit()
return exploit_data