-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcve_radar.py
137 lines (101 loc) · 4.64 KB
/
cve_radar.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import requests
from bs4 import BeautifulSoup
from discord_webhook import DiscordWebhook
import nvdlib
import datetime
import smtplib
import time
def send_to_discord(cveid, cvescore, publishdate, descrip ,cveref):
discord_webhook_url = 'YOUR DISCORD WEBHOOK'
data = {
"content": cveid + '\n' + cvescore + '\n' + cveseverity + '\n' + cveref
}
requests.post(discord_webhook_url, data=data)
def send_mail(cveid, cvescore, publishdate, lastmodif, vulnstat, cveref, cvevendortag):
cvss_sev = cvss_calc(cvescore)
sender = 'YOUR MAIL ADDRESS'
receviers = ["EMAIL RECIPIENTS"]
subject = 'CVE Alert'
body = """
CVE Code: %s
------------------------------------------------------
CVSS Base Score (3.x): %s
------------------------------------------------------
Severity Level: %s
------------------------------------------------------
Publish Date: %s
------------------------------------------------------
Last Modified Date: %s
------------------------------------------------------
Vuln Status: %s
------------------------------------------------------
NVD Link: %s
------------------------------------------------------
Product / Vendor: %s
##########################
Created By Mehdi0x90. CVE Radar
""" % (cveid, cvescore, cvss_sev, publishdate, lastmodif, vulnstat, cveref, cvevendortag)
message = "From: %s\nTo: %s\nSubject: %s\n\n%s" % (sender, receviers, subject, body)
mail_user = "YOUR MAIL USER"
mail_password = "YOUR MAIL PASSWORD"
sent_from = "YOUR MAIL ADDRESS"
sent_to = ["EMAIL RECIPIENTS"]
try:
smtp_server = smtplib.SMTP_SSL('YOUR MAIL SERVER', 465)
smtp_server.ehlo()
smtp_server.login(mail_user, mail_password)
smtp_server.sendmail(sent_from, sent_to, message)
smtp_server.close()
print ('='*60)
print ("Email sent successfully!")
except Exception as ex:
print ("Something went wrong in sending Email...",ex)
def cvss_calc(cvss_base_score):
severity_Level = ""
if cvss_base_score is None:
severity_Level = "None"
elif cvss_base_score == 0:
severity_Level = "None"
elif 3.9 >= cvss_base_score >= 0.1:
severity_Level = "Low"
elif 6.9 >= cvss_base_score >= 4:
severity_Level = "Medium"
elif 8.9 >= cvss_base_score >= 7:
severity_Level = "High"
elif 10 >= cvss_base_score >= 9:
severity_Level = "Critical"
return severity_Level
def intersection(description_list_keyword, Device_keyword):
return list(set(description_list_keyword) & set(Device_keyword))
if __name__ == "__main__":
end = datetime.datetime.now()
end_1 = end.strftime('%Y-%m-%d %H:%M')
start = end - datetime.timedelta(days=1)
start_1 = start.strftime('%Y-%m-%d %H:%M')
Device_keyword = ['cisco', 'microsoft', 'fortinet', 'sophos', 'mozilla', 'google', 'chromium', 'nginx', 'asus', 'hp', 'intel', 'nvidia', 'linux', 'canonical', 'centos', 'splunk', 'manageengine', 'symantec', 'oracle', 'jquery', 'nodejs', 'getbootstrap', 'apache', 'openvpn', 'winzip', 'adobe', 'solarwinds', 'zabbix', 'mongodb', 'videolan', 'python', 'vmware', 'realvnc', 'putty', 'openssl', 'debian', 'ubuntu']
try:
r = nvdlib.searchCVE(pubStartDate = start_1, pubEndDate = end_1)
for eachCVE in r:
time.sleep(1)
print(eachCVE.id)
print('CVSS Base Score (3.x): ' + str(eachCVE.score[1]))
print('Severity Level: ', cvss_calc(eachCVE.score[1]))
print('Pubished Date: ' + str(eachCVE.published[:10]))
print('Last Modified Date: ' + str(eachCVE.lastModified[:10]))
print('Vuln Status: ' + str(eachCVE.vulnStatus))
print('Description: ' + str(eachCVE.descriptions[0].value))
print('NVD Link: ' + eachCVE.url)
description_list = str(eachCVE.descriptions[0].value)
description_list_keyword = description_list.lower().split(" ")
cve_vendor_tag = intersection(description_list_keyword, Device_keyword)
if not intersection(description_list_keyword, Device_keyword):
print("CVE not match by your assets!")
else:
send_mail(eachCVE.id, eachCVE.score[1], eachCVE.published[:10], eachCVE.lastModified[:10], str(eachCVE.vulnStatus), str(eachCVE.url), cve_vendor_tag)
print("Email Sent...")
print ('='*60)
send_to_discord(eachCVE.id, str(eachCVE.score[1]), eachCVE.v31severity, eachCVE.url)
time.sleep(1)
except Exception as ex:
print ('Something went wrong!',ex)
pass