This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
51 lines (41 loc) · 1.54 KB
/
main.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
from flask import Flask, render_template, request, redirect
from datetime import datetime
from scan import SecurityScan
#--------------------CONFIG--------------------#
app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True
#--------------------ROUTES--------------------#
@app.route('/', methods=["GET", "POST"])
def Home():
if request.method == "POST":
req = request.form
url = req.get("url")
return redirect('/report?url=' + url)
if request.method == "GET":
return render_template('pages/Home.html')
@app.route('/report', methods=['GET'])
def Report():
#-------------GENERAL INFORMATIONS-------------#
url = request.args.get('url')
date = datetime.utcnow().strftime("%m/%d/%Y, %H:%M:%S")
#----------------SECURITY SCANS----------------#
headers = SecurityScan().check_headers(url)
https = SecurityScan().test_https(url)
https_redirect = SecurityScan().test_http_to_https(url, 5)
risk={'High': 0, 'Medium': 0, 'Low': 0, 'Info': 0}
for value in https.values():
if value == False:
risk['High']+=1
if https_redirect == False:
risk['High']+=1
for header, value in headers.items():
warn = value.get('warn')
if warn == 3:
risk['High']+=1
elif warn == 2:
risk['Medium']+=1
elif warn == 1:
risk['Low']+=1
else:
risk['Info']+=1
return render_template('pages/Report.html', url=url, date=date, risk=risk, headers=headers, https=https, https_redirect=https_redirect )