-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
91 lines (75 loc) · 3.88 KB
/
app.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
from datetime import datetime
from urllib.parse import urlparse
from modules.api.module import api
from modules.ml.model import predict, build_features
from modules.ml.features import Features
from modules.api.helpful_functions import ping
from flask import Flask, render_template, request
app = Flask(__name__, static_folder='static')
app.register_blueprint(api, url_prefix='/api')
@app.route("/", methods=['GET'], strict_slashes=False)
def main_page():
# Function of UI main page route
return render_template('main_page.html')
@app.route("/res", methods=['GET', 'POST'], strict_slashes=False)
def res_page():
# Function of UI result page route
if request.method == 'POST':
try:
url = request.form.to_dict(flat=False)['url'][0]
except:
error = 'Specify url'
if url != '':
check = urlparse(url)
if check.scheme != '' and check.netloc != '':
ping_status = ping(url)
if ping_status:
features = build_features(url)
ans = predict(url, features)
features = features.get_features()
checks = """["URL contains IP"
"URL's length check"
"Is shortning present"
"Is At symbol present"
"Redirecting using '//'"
"If prefix or suffix separated by -"
"If subdomain is present"
"If ssl is present"
"For how long domain is registred"
"Is favicon present"
"Is port is non-standart"
"Is https tokein is present in the domain"
"Are internal links leading to another domain"
"If the anchor and the website have different domain names/If anchor doesnt link to any webpage"
"If links in tags lead to a same domain"
"If contains sfh"
"If personal information is directed to a server or to an external email"
"If URL is in WHOIS database"
"If site redirects more than once"
"If status bar changes or not"
"If right click is disabled or not"
"Is pop-up window is present"
"Does site use Iframe or not"
"If domain is older than 6 month or not"
"Is there DNS record for a website or not"
"If website traffic is lower than 100000"
"If pageRank is lower than 0.2 or not"
"Is website is indexed by google or not"
"Are there any links leading to a website"
"Is host is on Top Phishing IP's rank or not"]""".split('\n')
if ans == Features.PHISHING:
status = 'phishing'
else:
status = 'not_phishing'
return render_template('result.html', status=status, checks=checks, detailed=features)
else:
error = 'Host down'
else:
error = 'Invalid url'
else:
error = 'Invalid url'
return render_template('result.html', error=error)
elif request.method == 'GET':
return render_template('result.html')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)