-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
clickjacking.py
executable file
·90 lines (70 loc) · 1.87 KB
/
clickjacking.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
#!/usr/bin/python2.7
# Python - ClickjackingTester
# Author: Sebastian Neef - Internetwache.org
# Twitter: @internetwache
# Comment: Happy Hacking!
import sys, urllib2
clickjacking = False
class ClickjackingTest(object):
def __init__(self):
self.__init()
def __init(self):
self.__url = ""
self.__csrfPoc = ""
def __create_poc(self):
html = '''
<html>
<body>
<iframe src="'''+self.__url+'''"></iframe>
</body>
</html>
'''
self.__csrfPoc = html
def __is_clickjackable(self):
url = self.__url
try:
if url[:4] != "http":
url = "http://" + url
sys.argv[1] = url
req = urllib2.urlopen(url)
headers = req.info()
if not "X-Frame-Options" in headers:
return True
except:
pass
return False
def getURL(self):
return self.__url
def getPoC(self):
return self.__csrfPoc
def test(self,url):
self.__init()
self.__url = url
if(not self.__is_clickjackable()):
return False
self.__create_poc()
return True
def usage():
print "[*] Usage: ", sys.argv[0]," [URL]"
print "[-] URL: the url to test"
def main():
print "[*] Started ClickjackingTester"
if len(sys.argv) <= 2:
if(len(sys.argv)==1 or sys.argv[1]=="-h" or sys.argv[1]=="--help"):
usage()
sys.exit(0)
else:
url = sys.argv[1]
else:
usage()
sys.exit(0)
clkTester = ClickjackingTest()
print "[*] Testing..."
if clkTester.test(url):
print "[*] X-Frame-Options-Header is missing"
print "[*] Clickjacking is possibe"
print clkTester.getPoC()
else:
print "[*] You can't clickjack this!"
print "[+] Done"
main()