forked from breenmachine/JavaUnserializeExploits
- Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathDecodeObject.java
More file actions
Latest commit
49 lines (47 loc) · 1.36 KB
/
Copy pathDecodeObject.java
File metadata and controls
49 lines (47 loc) · 1.36 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
48
49
importjava.util.Base64;
importjava.io.InputStream;
importjava.io.ByteArrayInputStream;
importjava.io.ObjectInputStream;
importjava.io.OptionalDataException;
importjava.io.StreamCorruptedException;
importjava.util.Arrays;
publicclassDecodeObject{
publicstaticvoidmain(Stringargs[]) throwsException{
intskip=0;
intremainder = 0;
Stringb64 = args[0];
byte[] bytes = Base64.getDecoder().decode(b64);
ByteArrayInputStreambis = newByteArrayInputStream(bytes);
intorigSize = bis.available();
System.out.println("Data Length: "+origSize);
Objecto = null;
while(o == null){
try{
bis.reset();
bis.skip(skip);
ObjectInputStreamois = newObjectInputStream(bis);
o = ois.readObject();
System.out.println("Object found...");
System.out.println(o.getClass().getName());
System.out.println("Bytes skipped: "+skip);
System.out.println("Bytes left: "+bis.available());
skip = origSize - bis.available();
}
catch (StreamCorruptedExceptionode){
skip = skip+1;
bis.skip(1);
}
catch (OptionalDataExceptionode){
bis.skip(1);
skip = skip+1;
}
catch (ClassNotFoundExceptioncnf)
{
System.out.println("Object found..."+cnf.getMessage());
System.out.println("Bytes skipped: "+skip);
System.out.println("Bytes left: "+bis.available());
skip = origSize - bis.available();
}
}
}
}