forked from phith0n/JavaThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.java
More file actions
47 lines (41 loc) · 1.42 KB
/
Copy pathApplication.java
File metadata and controls
47 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.govuln.serialization;
import com.govuln.serialization.model.User;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.IOUtils;
import static java.io.ObjectStreamConstants.*;
import java.io.*;
public class Application {
public static void main(String[] args) throws Exception
{
write();
read();
}
public static void write() throws Exception
{
ByteArrayOutputStream byteSteam = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(byteSteam);
oos.writeObject(new User());
String data = Hex.encodeHexString(byteSteam.toByteArray());
System.out.println(data);
ProcessBuilder builder = new ProcessBuilder(
"java",
"-jar",
"D:\\program\\SerializationDumper\\SerializationDumper-v1.13.jar",
data);
InputStream is = builder.start().getInputStream();
IOUtils.copy(is, System.out);
}
public static void read() throws Exception
{
Object[] data = {
STREAM_MAGIC, STREAM_VERSION,
TC_STRING,
"123123",
};
byte[] bs = Converter.toBytes(data);
System.out.println(Hex.encodeHexString(bs));
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bs));
Object obj = ois.readObject();
System.out.println(obj);
}
}