|
| 1 | +import sys |
1 | 2 | import requests
|
2 | 3 | import re
|
3 | 4 | from termcolor import colored
|
4 | 5 | import json
|
5 | 6 | from pyExploitDb import PyExploitDb
|
6 | 7 | from bs4 import BeautifulSoup
|
| 8 | +import subprocess |
7 | 9 |
|
8 | 10 | art = """
|
9 | 11 | _______ _ _ _______
|
10 | 12 | |__ __| | | |__ __|
|
11 | 13 | | | | |__ _ __ ___ __ _| |_ | |_ __ __ _ ___ ___ _ __
|
12 |
| - | | | '_ \| '__/ _ \/ _` | __|| | '__/ _` |/ __/ _ \ '__| |
| 14 | + | | | '_ \| '__/ _ \/ _` | __|| | '__/ _` |/__ / _ \ '__| |
13 | 15 | | | | | | | | | __/ (_| | |_ | | | | (_| | (_| __/ |
|
14 | 16 | |_| |_| |_|_| \___|\__,_|\__||_|_| \__,_|\___\___|_| Version 2.1
|
15 | 17 | A Script to identify CVE and public exploits using CPE by name & version
|
@@ -49,6 +51,10 @@ def fetch_cve_details(cpe_string):
|
49 | 51 |
|
50 | 52 | response = requests.get(url)
|
51 | 53 |
|
| 54 | + if response.status_code != 200: |
| 55 | + print(colored(f"Error: Unable to retrieve CVE data for CPE: {cpe_string}. Status code: {response.status_code}", "red")) |
| 56 | + return [] |
| 57 | + |
52 | 58 | try:
|
53 | 59 | data = response.json()
|
54 | 60 | except json.JSONDecodeError:
|
@@ -124,11 +130,43 @@ def search_and_extract_download_links(product_name):
|
124 | 130 | download_links.append(f"https://packetstormsecurity.com{href}")
|
125 | 131 |
|
126 | 132 | if not download_links:
|
127 |
| - print(colored("No download links found on Packet Storm Security.", "red")) |
| 133 | + print(colored("No download links found on Packet Storm Security.", "red", attrs=["underline"])) |
128 | 134 | return None
|
129 | 135 |
|
130 | 136 | return download_links
|
131 | 137 |
|
| 138 | +def search_marc_info(search_term): |
| 139 | + # Make a GET request to the URL |
| 140 | + url = f"https://marc.info/?l=full-disclosure&s={search_term}" |
| 141 | + response = requests.get(url) |
| 142 | + |
| 143 | + # Check if the request was successful |
| 144 | + if response.status_code == 200: |
| 145 | + # Parse the HTML content of the page |
| 146 | + soup = BeautifulSoup(response.text, 'html.parser') |
| 147 | + |
| 148 | + # Check if the response contains "No hits found for" |
| 149 | + if "No hits found for" in soup.get_text(): |
| 150 | + print(colored("No possible exploits found on Marc.Info.", "yellow", attrs=["underline"])) |
| 151 | + else: |
| 152 | + # Find all <a> tags within <pre> tags, excluding those with "full-disc" in the text |
| 153 | + post_links = soup.find('pre').find_all('a', string=lambda text: "full-disc" not in text) |
| 154 | + |
| 155 | + # Print all names and links |
| 156 | + if post_links: |
| 157 | + results = [] |
| 158 | + for link in post_links: |
| 159 | + name = link.get_text(strip=True) |
| 160 | + link_url = "https://marc.info" + link['href'] |
| 161 | + results.append({"Name": name, "Link": link_url}) |
| 162 | + return results |
| 163 | + else: |
| 164 | + print(colored("No matching results found on Marc.Info.", "yellow")) |
| 165 | + else: |
| 166 | + print(colored("Failed to retrieve the web page from Marc.Info.", "red")) |
| 167 | + print(f"Status code: {response.status_code}") |
| 168 | + return None |
| 169 | + |
132 | 170 | if __name__ == "__main__":
|
133 | 171 | print(colored("CVE and Exploit Finder Script", "green", attrs=["bold"]))
|
134 | 172 | print("This script searches for CVEs, exploits, and possible 0-Days for any product.\n")
|
@@ -174,8 +212,18 @@ def search_and_extract_download_links(product_name):
|
174 | 212 | download_links = search_and_extract_download_links(component)
|
175 | 213 |
|
176 | 214 | if download_links:
|
177 |
| - print(colored("\nPossible Exploits on Packet Storm Security:", "cyan")) |
| 215 | + print(colored("\nPossible Exploits on Packet Storm Security:", "cyan", attrs=["underline"])) |
178 | 216 | for link in download_links:
|
179 | 217 | print(link)
|
180 | 218 | else:
|
181 |
| - print(colored("No download links found on Packet Storm Security.", "red")) |
| 219 | + print(colored("No download links found on Packet Storm Security.", "red", attrs=["underline"])) |
| 220 | + |
| 221 | + # Search Marc.Info |
| 222 | + search_term_marc = f"{component} {version}" |
| 223 | + print(f"\nUsing keyword "+search_term_marc+" for lookup...") |
| 224 | + marc_results = search_marc_info(search_term_marc) |
| 225 | + if marc_results: |
| 226 | + print(colored("\nPossible Exploits:", "cyan", attrs=["underline"])) |
| 227 | + for result in marc_results: |
| 228 | + print(colored(f"\nName: {result['Name']}", "white")) |
| 229 | + print(colored(f"Link: {result['Link']}", "blue")) |
0 commit comments