-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxss_protection.py
52 lines (35 loc) · 1.62 KB
/
xss_protection.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
import requests
from flask import request
class xss_Protection():
def xss_protect(self):
global username1
global print2
global bool_flag2
username1 = request.args.get('url')
req3 = requests.get(username1)
a_2=req3.headers
print(a_2)
bool_flag2=False
print2="there is kind of possible of implementing xss, as it will not block the page when it finds the inline scripts."
if("X-XSS-Protection" in a_2):
if("0" in a_2["X-XSS-Protection"]):
bool_flag2=False
print2="here, they disabling the xss-filters, i.e. setting xss protection to 0."
else:
bool_flag2=True
print2="if the browser founds an inline scripts, it blocks. So, some reflected xss can be prevented."
elif("Content-Security-Policy" in a_2):
if("script-src" in a_2["Content-Security-Policy"]):
if("'unsafe-inline'" in a_2["Content-Security-Policy"]):
bool_flag2=False
print2="this page accepts inline scripts, instead of blocking it."
elif("'none'" in a_2["Content-Security-Policy"]):
bool_flag2=True
print2="this page blocks prevents xss by blocking the inline scripts."
else:
bool_flag2=False
print2="they are not filtering xss and won't block the web page."
else:
bool_flag2=False
print2="they are not filtering xss and won't block the web page."
return print2,bool_flag2