Skip to content

Commit 40bccb2

Browse files
authored
Update threattracer.py
Searched for exploits at packetstorm
1 parent 2a52ba7 commit 40bccb2

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

threattracer.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from termcolor import colored
44
import json
55
from pyExploitDb import PyExploitDb
6+
from bs4 import BeautifulSoup
67

78
art = """
89
_______ _ _ _______
@@ -25,7 +26,6 @@ def find_cpes(component, version):
2526
}
2627

2728
response = requests.get(base_url, params=params)
28-
#print(f"URL Used: {response.url}") Print the URL used to find CPE
2929
content = response.text
3030

3131
cpe_matches = re.findall(r'cpe:(.*?)<', content)
@@ -44,7 +44,7 @@ def fetch_cve_details(cpe_string):
4444
base_url = "https://services.nvd.nist.gov/rest/json/cves/1.0"
4545
results = []
4646

47-
cve_query_string = ":".join(cpe_string.split(":")[1:5]) # Extract relevant CPE part (vendor, product, version, update)
47+
cve_query_string = ":".join(cpe_string.split(":")[1:5])
4848
url = f"{base_url}?cpeMatchString=cpe:/{cve_query_string}"
4949

5050
response = requests.get(url)
@@ -53,7 +53,7 @@ def fetch_cve_details(cpe_string):
5353
data = response.json()
5454
except json.JSONDecodeError:
5555
print(colored(f"Error decoding JSON for CPE: {cpe_string}. Skipping.", "red"))
56-
return [] # Return an empty list to indicate the error
56+
return []
5757

5858
if "result" in data:
5959
cves = data["result"]["CVE_Items"]
@@ -75,7 +75,6 @@ def fetch_cve_details(cpe_string):
7575
else:
7676
description_text = "Description not available."
7777

78-
# Check for public exploit using pyExploitDb
7978
pEdb = PyExploitDb()
8079
pEdb.debug = False
8180
pEdb.openFile()
@@ -109,14 +108,36 @@ def fetch_github_urls(cve_id):
109108
return github_urls
110109
return []
111110

111+
def search_and_extract_download_links(product_name):
112+
search_url = f"https://packetstormsecurity.com/search/?q={product_name}"
113+
response = requests.get(search_url)
114+
115+
download_links = []
116+
117+
if response.status_code == 200:
118+
soup = BeautifulSoup(response.text, 'html.parser')
119+
results = soup.find_all('a', href=True)
120+
121+
for result in results:
122+
href = result['href']
123+
if '/files/download/' in href and href.endswith('.txt'):
124+
download_links.append(f"https://packetstormsecurity.com{href}")
125+
126+
if not download_links:
127+
print(colored("No download links found on Packet Storm Security.", "red"))
128+
return None
129+
130+
return download_links
131+
112132
if __name__ == "__main__":
113-
print(colored("CPE Finder Script", "green", attrs=["bold"]))
114-
print("This script searches for the CPEs of a component and version.\n")
133+
print(colored("CVE and Exploit Finder Script", "green", attrs=["bold"]))
134+
print("This script searches for CVEs, exploits, and download links for a product.\n")
115135

116136
component = input(colored("Enter the component (e.g., jquery): ", "cyan"))
117137
version = input(colored("Enter the version (e.g., 1.0.0): ", "cyan"))
118138

119139
cpe_strings = find_cpes(component, version)
140+
120141
if cpe_strings:
121142
print(colored("CPEs Found:", "green"))
122143
for cpe_string in cpe_strings:
@@ -135,7 +156,7 @@ def fetch_github_urls(cve_id):
135156
if result["Weaknesses"]:
136157
print(colored(f"Weaknesses: {result['Weaknesses']}", "magenta"))
137158
print(colored(f"Link: {result['Link']}", "blue"))
138-
github_urls = fetch_github_urls(cve_id) # Print GitHub URLs for this CVE
159+
github_urls = fetch_github_urls(cve_id)
139160
if github_urls:
140161
print(colored("Public Exploit/ POC Over Github found:", "red"))
141162
for url in github_urls:
@@ -146,5 +167,13 @@ def fetch_github_urls(cve_id):
146167
print(colored(f"Exploit Status: {result['Exploit Status']}", "red"))
147168
else:
148169
print(colored(f"Exploit Status: {result['Exploit Status']}", "green"))
170+
171+
# Search for download links
172+
download_links = search_and_extract_download_links(component)
173+
174+
if download_links is not None:
175+
print(colored("\nPossible Exploits/ 0Days/ CVEs:", "cyan"))
176+
for link in download_links:
177+
print(link)
149178
else:
150179
print(colored("CPEs not found for the provided component and version.", "red"))

0 commit comments

Comments
 (0)