forked from Th4nat0s/Chall_Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
f5discovery.py
executable file
·58 lines (46 loc) · 1.32 KB
/
f5discovery.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
#!/usr/bin/python
# v 0.1
# Copyleft Thanat0s
# http://Thanat0s.trollprod.org
#
# Licence GNU GPL
# A F5 cookie dissector/finder
import re
import sys
import cookielib
import urllib2
import struct
cookies = cookielib.LWPCookieJar()
handlers = [
urllib2.HTTPHandler(),
urllib2.HTTPSHandler(),
urllib2.HTTPCookieProcessor(cookies)
]
opener = urllib2.build_opener(*handlers)
def fetch(uri):
req = urllib2.Request(uri)
return opener.open(req)
def decode(ltmcook):
(host, port, end) = ltmcook.split('.')
(a, b, c, d) = [ord(i) for i in struct.pack("<I", int(host))]
p = [ord(i) for i in struct.pack("<I", int(port))]
return str(str(a)+'.'+str(b)+'.'+str(c)+'.'+str(d)), p[0]*256 + p[1]
if __name__ == '__main__':
if len(sys.argv) < 2:
print 'Scan for a website for a F5 LTM stickiness cookie'
print 'Examples:'
print sys.argv[0] + ' http://thanat0s.trollprod.org'
sys.exit()
uri = sys.argv[1]
res = fetch(uri)
found = False
print '+ Search for Cookies..'
for cookie in cookies:
if re.match(r'^[\d]+\.[\d]+\.[\d]+$', cookie.value):
found = True
ip,port = decode(cookie.value)
print ('\t> %s Backend : %s:%s %s') % (cookie.name,ip,port,'<< Got a F5 one')
else:
print ('\t> %s') % (cookie.name)
if found:
print 'A F5 device was detected'