Skip to content

Commit 787064b

Browse files
authored
Update threattracer.py
Fixed few runtime bugs that were causing the tool to crash.
1 parent d4e3975 commit 787064b

File tree

1 file changed

+48
-42
lines changed

1 file changed

+48
-42
lines changed

threattracer.py

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pyExploitDb import PyExploitDb
77
from bs4 import BeautifulSoup
88

9-
art = """
9+
art = r"""
1010
_______ _ _ _______
1111
|__ __| | | |__ __|
1212
| | | |__ _ __ ___ __ _| |_ | |_ __ __ _ ___ ___ _ __
@@ -67,8 +67,12 @@ def fetch_cve_details(cpe_string):
6767
pEdb = PyExploitDb()
6868
pEdb.debug = False
6969
pEdb.openFile()
70-
exploit_status = "Public Exploit Found over Exploit-DB" if pEdb.searchCve(cve_id) else "No Public Exploit Found over Exploit-DB"
71-
70+
71+
try:
72+
exploit_status = "Public Exploit Found over Exploit-DB" if pEdb.searchCve(cve_id) else "No Public Exploit Found over Exploit-DB"
73+
except ValueError as e:
74+
exploit_status = "Error processing Exploit-DB response."
75+
7276
snyk_short_name = synk_db(cve_id)
7377

7478
all_cve_details.append({
@@ -141,51 +145,53 @@ def search_marc_info(search_term):
141145
component = input(colored("Enter the component (e.g., Apache): ", "cyan"))
142146
version = input(colored("Enter the version (e.g., 4.2.1): ", "cyan"))
143147

148+
# Fetch and display CPEs
144149
cpe_strings = find_cpes(component, version)
145-
146150
if cpe_strings:
147151
print(colored("CPEs Found:", "green"))
148152
for cpe_string in cpe_strings:
149153
print(colored(f" {cpe_string}", "green"))
150-
151-
for cpe_string in cpe_strings:
152-
results = fetch_cve_details(cpe_string)
153-
if results:
154-
print(colored("\nCVE Details", "cyan", attrs=["underline"]))
155-
for result in results:
156-
cve_id = result["CVE ID"]
157-
print(colored(f"\nCVE ID: {cve_id}", "white"))
158-
if result["Short Name"]:
159-
print(colored(f"Short Name: {result['Short Name']}", "light_blue"))
160-
print(colored(f"Description: {result['Description']}", "yellow"))
161-
if result["Weaknesses"]:
162-
print(colored(f"Weaknesses: {result['Weaknesses']}", "magenta"))
163-
print(colored(f"Link: {result['Link']}", "blue"))
164-
github_urls = fetch_github_urls(cve_id)
165-
if github_urls:
166-
print(colored("Public Exploit/POC Over Github found:", "red"))
167-
for url in github_urls:
168-
print(colored(f" {url}", "blue"))
169-
else:
170-
print(colored("Public Exploit/POC Over Github not found, you might need to check manually", "green"))
171-
print(colored(f"Exploit Status: {result['Exploit Status']}", "red" if result["Exploit Status"] == "Public Exploit Found over Exploit-DB" else "green"))
172154
else:
173-
print(colored("No CPEs found for the provided component and version.", "red"))
174-
175-
download_links = search_and_extract_download_links(component)
176-
155+
print(colored("No CPEs found. Please try different keywords.", "red"))
156+
sys.exit(0)
157+
158+
# Search for Packet Storm Security download links
159+
download_links = search_and_extract_download_links(f"{component} {version}")
177160
if download_links:
178-
print(colored("\nPossible Exploits on Packet Storm Security:", "cyan", attrs=["underline"]))
161+
print(colored("\nPublic exploits found over Packet Storm Security", "yellow"))
179162
for link in download_links:
180-
print(link)
163+
print(colored(f" {link}", "blue"))
164+
165+
# Search Marc Full Disclosure for exploits
166+
marc_info = search_marc_info(f"{component} {version}")
167+
if marc_info:
168+
print(colored("\nExploits found in Marc Full Disclosure", "yellow"))
169+
for result in marc_info:
170+
print(colored(f"{result['Name']}: {result['Link']}", "green"))
181171
else:
182-
print(colored("No download links found on Packet Storm Security.", "red", attrs=["underline"]))
183-
184-
search_term_marc = f"{component} {version}"
185-
print(f"\nUsing keyword "+search_term_marc+" for lookup...")
186-
marc_results = search_marc_info(search_term_marc)
187-
if marc_results:
188-
print(colored("\nPossible Exploits:", "cyan", attrs=["underline"]))
189-
for result in marc_results:
190-
print(colored(f"\nName: {result['Name']}", "white"))
191-
print(colored(f"Link: {result['Link']}", "blue"))
172+
print(colored("\nNo exploits found in Marc Full Disclosure.", "red"))
173+
174+
# Process each CPE string to get CVE details
175+
for cpe_string in cpe_strings:
176+
results = fetch_cve_details(cpe_string)
177+
if results:
178+
print(colored("\nCVE Details", "cyan", attrs=["underline"]))
179+
for result in results:
180+
cve_id = result["CVE ID"]
181+
print(colored(f"\nCVE ID: {cve_id}", "white"))
182+
if result["Short Name"]:
183+
print(colored(f"Short Name: {result['Short Name']}", "magenta"))
184+
print(colored(f"Description: {result['Description']}", "yellow"))
185+
print(colored(f"Weaknesses: {result['Weaknesses']}", "red"))
186+
print(colored(f"Link: {result['Link']}", "blue"))
187+
188+
github_links = fetch_github_urls(cve_id)
189+
if github_links:
190+
print(colored("\nExploit/POC Over Github", "yellow"))
191+
for link in github_links:
192+
print(colored(f" {link}", "green"))
193+
else:
194+
print(colored("\nExploit/POC Over Github: None", "green"))
195+
print(colored(f"Exploit Status: {result['Exploit Status']}", "red"))
196+
197+
print(colored("Script Execution Completed!", "green", attrs=["underline"]))

0 commit comments

Comments
 (0)