forked from dipsec/Scripts-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPython-SecurityHeaders.py
47 lines (30 loc) · 1.23 KB
/
Python-SecurityHeaders.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
import urllib2
import sys
url = sys.argv[1]
req = urllib2.Request(url)
res = urllib2.urlopen(req)
RetHeaders = res.headers
print "URL: " + url + "\n"
print "---- Security Headers Found ----\n"
if "Strict-Transport-Security" in RetHeaders:
print "[-] Security Header Found: Strict-Transport-Security"
if "X-Frame-Options" in RetHeaders:
print "[-] Security Header Found: X-Frame-Options"
if "X-XSS-Protection" in RetHeaders:
print "[-] Security Header Found: X-XSS-Protection"
if "X-Content-Type-Options" in RetHeaders:
print "[-] Security Header Found: X-Content-Type-Options"
if "Content-Security-Policy" in RetHeaders:
print "[-] Security Header Found: Content-Security-Policy"
print "\n---- Missing Headers ----\n"
if "Strict-Transport-Security" not in RetHeaders:
print "[-] Missing Header: Strict-Transport-Security"
if "X-Frame-Options" not in RetHeaders:
print "[-] Missing Header: X-Frame-Options"
if "X-XSS-Protection" not in RetHeaders:
print "[-] Missing Header: X-XSS-Protection"
if "X-Content-Type-Options" not in RetHeaders:
print "[-] Missing Header: X-Content-Type-Options"
if "Content-Security-Policy" not in RetHeaders:
print "[-] Missing Header: Content-Security-Policy"
res.close()