import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
publicclass Person implementsSerializable {
privateString name;
privateint age;
publicPerson(){}
publicPerson(String name,int age){
this.name=name;
this.age=age;
}
@Override
publicString toString() {
return"Person{"+
"name='" + name + "\'" +
",'age=" + age +
'}';
}
}
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
public class SerializationTest {
public static void serialize(Object obj) throws IOException {
ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("ser.bin"));
oos.writeObject(obj);
}
public static void main(String[] args) throws Exception{
Person person=new Person("xinyuan",22);
serialize(person);
System.out.println(person);
}
}
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
public class UnserializationTest {
public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream ois=new ObjectInputStream(new FileInputStream("ser.bin"));
Object obj = ois.readObject();
return obj;
}
public static void main(String[] args) throws Exception{
Person person=(Person) unserialize("ser.bin");
System.out.println(person);
}
}
调用链 gadget chain 相同名称,相同类型
执行类 sink(rce ssrf 写文件等等)
https://github.com/frohoff/ysoserial/
征集原创技术文章中,欢迎投递
投稿邮箱:[email protected]
文章类型:黑客极客技术、信息安全热点安全研究分析等安全相关
通过审核并发布能收获200-800元不等的稿酬。