-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathfingerprinter.py
194 lines (193 loc) · 5.91 KB
/
fingerprinter.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import subprocess
import requests
from urlparse import urlparse
#####################################################
#
# Color class for text output
# Making shit pretty since 1982!
#
#########################################################
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
def disable(self):
self.HEADER = ''
self.OKBLUE = ''
self.OKGREEN = ''
self.WARNING = ''
self.FAIL = ''
self.ENDC = ''
######################################################
# Fingerprinter function:
# Uses a head request to fingerprint
# server usingarch_define the Server and X headers
# uses the () and xfind() functions
#
# Requires "u" as the url
#
# Returns "d" as dict listing server
# powered by and/or ASP version information
#
#
######################################################
def fingerprint(sess, url, msf, dos):
d = {}
u = url.scheme + '://' + url.netloc + '/'
r = sess.options(u)
print("options response status: " + str(r.status_code))
if r.status_code == 200:
print("response headers: ")
for h in r.headers:
print("- " + h + " ==> " + r.headers[h])
#print(bcolors.HEADER + "[*] looking at header %s " % h + bcolors.ENDC)
if "Server" in h:
d.update({'Server': r.headers[h]})
o = exploit_finder(r.headers[h], msf, dos)
if o is not None:
for k,v in o.iteritems():
d.update({k:v})
if "Allow" in h:
print("[*] Searching for enabled WebDAV...")
if "PROPFIND" in r.headers[h]:
print(bcolors.OKGREEN + "[+] WebDAV enabled!" + bcolors.ENDC)
d.update({'WebDAV': 'Enabled'})
else:
d.update({'WebDAV': 'Disabled'})
if "X-Powered-By" in h:
x = xfind(r.headers[h], msf, dos)
if x is not None:
for k,v in x.iteritems():
d.update({k:v})
return d
#######################################################
# exploit_find function:
# Uses the server header to identify IIS or Apache or nginx
# web server arch and then returns y as a list of possible
# exploits in addition to DAV scanning.
#
# Requires "m" as server header value
#
# Returns "y" a list of exploits for the server.
#
#######################################################
def exploit_finder(m, msf, dos):
y = {}
if "/" in m:
n = m.split('/')
print(bcolors.HEADER + "[*] Server identified itself as %s with version %s. Finding exploits for server"% (n[0], n[1]) + bcolors.ENDC)
if n[0] == "Microsoft-IIS":
if n[1] == "5.0":
from sploits import IIS5
y = IIS5(msf, dos).sploits
return y
if n[1] == "6.0":
from sploits import IIS6
y = IIS6(msf, dos).sploits
return y
if n[1] == "7.5":
from sploits import IIS75
y = IIS75(msf, dos).sploits
return y
print(bcolors.WARNING + "[-] No public exploits found for IIS version %s" % n[1] + bcolors.ENDC)
return None
if n[0] == "Apache":
if "1.3" in n[1]:
from sploits import Apache13
y = Apache13(msf, dos).sploits
return y
if "2.0" in n[1]:
from sploits import Apache20
y = Apache20(msf, dos).sploits
return y
if "2.2" in n[1]:
from sploits import Apache22
y = Apache22(msf, dos).sploits
return y
if "2.4" in n[1]:
from sploits import Apache24
y = Apache24(msf, dos).sploits
return y
print(bcolors.WARNING + "[-] No public exploits found for Apache version %s" % n[1] + bcolors.ENDC)
return None
if n[0] == "nginx":
if "0.6" in n[1]:
from sploits import nginx06
y = nginx06(msf, dos).sploits
return y
if "0.7" in n[1] or "0.8" in n[1]:
#0.7 and 0.8 have the same vulnerabilities. We'll lump them together
from sploits import nginx078
y = nginx078(msf, dos).sploits
return y
if "1.1.17" in n[1]:
from sploits import nginx11
y = nginx11(msf, dos).sploits
return y
#same as with 0.7 and 0.8 similar vulnerabilities so we combine them.
if "1.3.9" in n[1] or "1.4" in n[1]:
from sploits import nginx134
y = nginx134(msf, dos).sploits
return y
print(bcolors.WARNING + "[-] No public exploits found for nginx version %s" % n[1] + bcolors.ENDC)
return None
else:
print(bcolors.HEADER + "[*] no sploit collection has been provided for %s. Checking local exploit-db..." % m + bcolors.ENDC)
from sploits import Other
y = Other(m, msf, dos).sploits
return y
#########################################################
# xfind function:
# Uses the x-powered-by header to find technologies
# that are in use on the server
#
# Requires "m" as x-powered-by header value
#
# Returns "l" as list of technologies or m if only one
# technology
#
##########################################################
def xfind(m, msf, dos):
ploit = {}
if "," in m:
l = m.split(',')
k = len(l)
for a in l:
print("[*] Searching for exploits for %s" % a)
if "/" in a:
b = a.split('/')
if b[0] == "PHP":
from sploits import PHP
if PHP(b[1],msf,dos).sploits is not None:
for k,v in p.sploits.iteritems():
ploit[k] = v
else:
print("[-] Unable to find public exploits for %s" % a)
if b[0] == "ASP.NET":
from sploits import ASP
if ASP(b[1],msf,dos).sploits is not None:
for k,v in p.sploits.iteritems():
ploit[k] = v
else:
print("[-] Unable to find public exploits for %s" % a)
else:
if "ASP.NET" in m:
if "/" in m:
n = m.split('/')
print"[*] Server uses %s and is at version %s" % (n[0], n[1])
from sploits import ASP
if ASP(n[1],msf,dos).sploits is not None:
for k,v in ASP(n[1],msf,dos).sploits.iteritems():
ploit[k] = v
if "PHP" in m:
if "/" in m:
n = m.split('/')
print"[*] Server uses %s and is at version %s" % (n[0], n[1])
from sploits import PHP
if PHP(n[1],msf,dos).sploits is not None:
for k,v in PHP(n[1],msf,dos).sploits.iteritems():
ploit[k] = v
return ploit