Skip to content

Instantly share code, notes, and snippets.

@conikeec
Created June 14, 2018 14:02
Show Gist options
  • Save conikeec/8fa3f00cf49b1fa6c8ff145229f73e99 to your computer and use it in GitHub Desktop.
Save conikeec/8fa3f00cf49b1fa6c8ff145229f73e99 to your computer and use it in GitHub Desktop.
// Vulnerable class
class LogFile implements Serializable
{
public String filename;
public String filecontent;
// Function called during deserialization
private void readObject(ObjectInputStream in)
{
System.out.println("readObject from LogFile");
try
{
// Unserialize data
in.defaultReadObject();
System.out.println("File name: " + filename + ", file content: \n" + filecontent);
// Do something useful with the data
// Restore LogFile, write file content to file name
FileWriter file = new FileWriter(filename);
BufferedWriter out = new BufferedWriter(file);
System.out.println("Restoring log data to file...");
out.write(filecontent);
out.close();
file.close();
}
catch (Exception e)
{
System.out.println("Exception: " + e.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment