提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
反序列化漏洞也被称为"unserialization vulnerability"。它存在于那些允许将对象从字符串或二进制数据转换回原始对象的应用程序中。反序列化漏洞的问题在于,恶意用户可以构造特殊的序列化数据,通过应用程序的反序列化过程来执行恶意代码。这可以导致应用程序在反序列化过程中执行任意的代码,包括读取、修改或删除应用程序的敏感数据,或者在应用程序上下文中执行不受控制的操作。
一、经典的序列化过程
比如JAVA常见的序列化的例子
import java.io.*;
public class SerializationExample {
public static void main(String[] args) {
// 创建Student对象
Student student = new Student("John", 20, "Computer Science");
// 将Student对象序列化保存到文件中
try {
FileOutputStream fileOut = new FileOutputStream("student.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(student);
out.close();
fileOut.close();
System.out.println("Serialized data is saved in student.ser file");
} catch (IOException e) {
e.printStackTrace();
}
// 将保存的文件反序列化为Student对象
try {
FileInputStream fileIn = new FileInputStream("student.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
Student serializedStudent = (Student) in.