-
Notifications
You must be signed in to change notification settings - Fork 4
/
view.py
105 lines (85 loc) · 2.74 KB
/
view.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
import json,time
import requests
import urllib3
from flask import request, Blueprint, render_template
urllib3.disable_warnings()
path = Blueprint('path', __name__)
@path.route('/', methods=['GET', "POST"])
@path.route('/index', methods=['GET', "POST"])
def index():
return render_template("index.html")
@path.route('/post_form', methods=['POST', ])
def post_form():
per_page = int(request.form.get('per_page',10))
data = {
'page': int(request.form.get('page', 1)),
'per_page':per_page,
}
vuln_no = ''
if request.form.get('vuln_no'):
vuln_no = request.form.get('vuln_no')
try:
res = requests.get('https://www.oscs1024.com/oscs/v1/vdb/vuln_info/'+vuln_no ).json()
rows = []
count = 0
if 'title' in res.keys():
count = 1
rows = [res]
for i in rows:
idx = rows.index(i)
rows[idx]['created_at'] = i['published_time']
rows[idx]['mps'] = i['mps_id']
except Exception as e:
rows = []
count = 0
# rows = res['data']
respos = {
"status": 0,
"data": {
'rows': rows,
"count": count
},
'msg': ''
}
else:
res = requests.post('https://www.oscs1024.com/oscs/v1/intelligence/list', json=data).json()
rows = res['data']['data']
for i in rows:
idx = rows.index(i)
rows[idx]['created_at'] = i['created_at'].replace('T', ' ').replace('+', ' ')[0:per_page]
respos = {
"status": 0,
"data": {
'rows': rows,
"count": res['data']['total']
},
'msg': ''
}
return json.dumps(respos)
@path.route('/detail', methods=['GET' ])
def detail():
mps = request.args.get('id')
json_data = {
'vuln_no': mps,
}
res = requests.post('https://www.oscs1024.com/oscs/v1/vdb/info', json=json_data).json()
rows = res['data'][0]
effect = ''
url = ''
for i in rows['references']:
url += i['url']+"\r\n<br/>"
rows['url'] =url
for i in rows['effect']:
effect += i['name']+'@'+str(i['affected_version'])+"\r\n<br/>"
rows['effect'] = effect
if 'CVE' in rows['cve_id'] :
rows['cve_id'] = '<a href="%s">%s</a>'%('https://nvd.nist.gov/vuln/detail/'+rows['cve_id'],'https://nvd.nist.gov/vuln/detail/'+rows['cve_id'])
respos = {
"status": 0,
"data":rows,
'msg': ''
}
return json.dumps(respos)
def getTimestr(timeint):
timeArray = time.localtime(timeint)
return time.strftime("%Y-%m-%d", timeArray)