Created
June 14, 2018 14:02
-
-
Save conikeec/8fa3f00cf49b1fa6c8ff145229f73e99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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