forked from Aabyss-Team/threat-broadcast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcve_info.py
75 lines (53 loc) · 1.8 KB
/
cve_info.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : EXP
# @Time : 2020/4/25 22:17
# @File : cve_info.py
# -----------------------------------------------
import hashlib
class CVEInfo:
def __init__(self):
self.id = ''
self.src = ''
self.url = ''
self.time = ''
self.title = ''
self.info = ''
self.md5 = ''
def is_vaild(self):
return not not self.title
def MD5(self):
if not self.md5:
data = '%s%s%s' % (self.id, self.title, self.url)
self.md5 = hashlib.md5(data.encode(encoding='UTF-8')).hexdigest()
return self.md5
def to_html(self):
return '<br/>'.join([
"<br/>==============================================",
"[<b>漏洞来源</b>] %s" % self.src,
"[<b>漏洞编号</b>] <font color='blue'>%s</font>" % self.id,
"[<b>披露时间</b>] %s" % self.time,
"[<b>漏洞描述</b>] %s" % self.title,
"[<b>相关链接</b>] <a href='%s'>%s</a>" % (self.url, self.url)
])
def to_msg(self):
return '\n'.join([
"\n==============================================",
"[ TITLE ] %s" % self.title,
"[ TIME ] %s" % self.time,
"[ CVE ] %s" % self.id,
"[ SRC ] %s" % self.src,
"[ URL ] %s" % self.url
])
def __str__(self):
return self.__repr__()
def __repr__(self):
return '\n'.join([
"\n==============================================",
"[ TITLE ] %s" % self.title,
"[ TIME ] %s" % self.time,
"[ CVE ] %s" % self.id,
"[ SRC ] %s" % self.src,
"[ URL ] %s" % self.url,
"[ INFO ] %s" % self.info,
])