3
3
from termcolor import colored
4
4
import json
5
5
from pyExploitDb import PyExploitDb
6
+ from bs4 import BeautifulSoup
6
7
7
8
art = """
8
9
_______ _ _ _______
@@ -25,7 +26,6 @@ def find_cpes(component, version):
25
26
}
26
27
27
28
response = requests .get (base_url , params = params )
28
- #print(f"URL Used: {response.url}") Print the URL used to find CPE
29
29
content = response .text
30
30
31
31
cpe_matches = re .findall (r'cpe:(.*?)<' , content )
@@ -44,7 +44,7 @@ def fetch_cve_details(cpe_string):
44
44
base_url = "https://services.nvd.nist.gov/rest/json/cves/1.0"
45
45
results = []
46
46
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 ])
48
48
url = f"{ base_url } ?cpeMatchString=cpe:/{ cve_query_string } "
49
49
50
50
response = requests .get (url )
@@ -53,7 +53,7 @@ def fetch_cve_details(cpe_string):
53
53
data = response .json ()
54
54
except json .JSONDecodeError :
55
55
print (colored (f"Error decoding JSON for CPE: { cpe_string } . Skipping." , "red" ))
56
- return [] # Return an empty list to indicate the error
56
+ return []
57
57
58
58
if "result" in data :
59
59
cves = data ["result" ]["CVE_Items" ]
@@ -75,7 +75,6 @@ def fetch_cve_details(cpe_string):
75
75
else :
76
76
description_text = "Description not available."
77
77
78
- # Check for public exploit using pyExploitDb
79
78
pEdb = PyExploitDb ()
80
79
pEdb .debug = False
81
80
pEdb .openFile ()
@@ -109,14 +108,36 @@ def fetch_github_urls(cve_id):
109
108
return github_urls
110
109
return []
111
110
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
+
112
132
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 " )
115
135
116
136
component = input (colored ("Enter the component (e.g., jquery): " , "cyan" ))
117
137
version = input (colored ("Enter the version (e.g., 1.0.0): " , "cyan" ))
118
138
119
139
cpe_strings = find_cpes (component , version )
140
+
120
141
if cpe_strings :
121
142
print (colored ("CPEs Found:" , "green" ))
122
143
for cpe_string in cpe_strings :
@@ -135,7 +156,7 @@ def fetch_github_urls(cve_id):
135
156
if result ["Weaknesses" ]:
136
157
print (colored (f"Weaknesses: { result ['Weaknesses' ]} " , "magenta" ))
137
158
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 )
139
160
if github_urls :
140
161
print (colored ("Public Exploit/ POC Over Github found:" , "red" ))
141
162
for url in github_urls :
@@ -146,5 +167,13 @@ def fetch_github_urls(cve_id):
146
167
print (colored (f"Exploit Status: { result ['Exploit Status' ]} " , "red" ))
147
168
else :
148
169
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 ("\n Possible Exploits/ 0Days/ CVEs:" , "cyan" ))
176
+ for link in download_links :
177
+ print (link )
149
178
else :
150
179
print (colored ("CPEs not found for the provided component and version." , "red" ))
0 commit comments