ZKar is a Java serialization protocol analysis tool implement in Go. This tool is still work in progress, so no complete API document and contribution guide.
ZKar provides:
- A Java serialization payloads parser and viewer in pure Go, no CGO or JDK is required
- From the Java serialization protocol to a Go struct
- A Go library that can manipulate the Java serialization data
- WIP: ysoserial implement in Go
- WIP: Java class bytecodes parser, viewer and manipulation
- WIP: An implementation of RMI/LDAP in Go
Using ZKar is easy. use go get
to install the ZKar along with the library and its dependencies:
go get -u github.com/phith0n/zkar
Next, use github.com/phith0n/zkar/*
in your application:
package main
import (
"fmt"
"github.com/phith0n/zkar/serz"
"io/ioutil"
"log"
)
func main() {
data, _ := ioutil.ReadFile("./testcases/ysoserial/CommonsCollections6.ser")
serialization, err := serz.FromBytes(data)
if err != nil {
log.Fatal("parse error")
}
fmt.Println(serialization.ToString())
}
ZKar also provides a command line utility tool that you can use it directly:
$ go run main.go
NAME:
zkar - A Java serz tool
USAGE:
main [global options] command [command options] [arguments...]
COMMANDS:
generate generate Java serz attack payloads
dump parse the Java serz streams and dump the struct
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help (default: false)
For example, you are able to dump the payload CommonsBeanutils3 from ysoserial like:
$ go run main.go dump -f "$(pwd)/testcases/ysoserial/CommonsBeanutils3.ser"
ZKar is a well-tested tool that passed all ysoserial generated gadgets parsing and rebuilding tests. It means that gadget generating by ysoserial can be parsed by ZKar, and parsed struts can be converted back into bytes string which is equal to the original one.
Gadget | Package | Parse | Rebuild | Parse Time |
---|---|---|---|---|
AspectJWeaver | ysoserial | ā | ā | 80.334Āµs |
BeanShell1 | ysoserial | ā | ā | 782.613Āµs |
C3P0 | ysoserial | ā | ā | 98.321Āµs |
Click1 | ysoserial | ā | ā | 573.298Āµs |
Clojure | ysoserial | ā | ā | 72.415Āµs |
CommonsBeanutils1 | ysoserial | ā | ā | 461.15Āµs |
CommonsCollections1 | ysoserial | ā | ā | 64.484Āµs |
CommonsCollections2 | ysoserial | ā | ā | 508.918Āµs |
CommonsCollections3 | ysoserial | ā | ā | 564.071Āµs |
CommonsCollections4 | ysoserial | ā | ā | 535.449Āµs |
CommonsCollections5 | ysoserial | ā | ā | 137.609Āµs |
CommonsCollections6 | ysoserial | ā | ā | 68.753Āµs |
CommonsCollections7 | ysoserial | ā | ā | 178.549Āµs |
FileUpload1 | ysoserial | ā | ā | 35.39Āµs |
Groovy1 | ysoserial | ā | ā | 150.991Āµs |
Hibernate1 | ysoserial | ā | ā | 789.674Āµs |
Hibernate2 | ysoserial | ā | ā | 168.624Āµs |
JBossInterceptors1 | ysoserial | ā | ā | 632.581Āµs |
JRMPClient | ysoserial | ā | ā | 32.967Āµs |
JRMPListener | ysoserial | ā | ā | 38.263Āµs |
JSON1 | ysoserial | ā | ā | 2.157225ms |
JavassistWeld1 | ysoserial | ā | ā | 468.596Āµs |
Jdk7u21 | ysoserial | ā | ā | 355.01Āµs |
Jython1 | ysoserial | ā | ā | 216.862Āµs |
MozillaRhino1 | ysoserial | ā | ā | 1.775193ms |
MozillaRhino2 | ysoserial | ā | ā | 409.124Āµs |
Myfaces1 | ysoserial | ā | ā | 22.997Āµs |
Myfaces2 | ysoserial | ā | ā | 38.131Āµs |
ROME | ysoserial | ā | ā | 485.804Āµs |
Spring1 | ysoserial | ā | ā | 797.469Āµs |
Spring2 | ysoserial | ā | ā | 358.041Āµs |
URLDNS | ysoserial | ā | ā | 21.502Āµs |
Vaadin1 | ysoserial | ā | ā | 438.729Āµs |
Wicket1 | ysoserial | ā | ā | 23.509Āµs |
JDK8u20* | pwntester | ā | ā | 529.3Āµs |
Notice: For parsing JDK8u20 payload, you should add --jdk8u20
flag to dump
command.
As the payload is not a valid serialized data stream, it's necessary to tell ZKar patches the data through this flag.
- Java bytecodes parser and generator
- JDK/JRE 8u20 Gadget supporting
- Serialization payloads generator
- An implementation of RMI/LDAP in Go
ZKar is released under the MIT license. See LICENSE
- SerializationDumper: A tool to dump and rebuild Java serialization streams and Java RMI packet contents in a more human readable form.
- ysoserial: A proof-of-concept tool for generating payloads that exploit unsafe Java object deserialization.
- Java-Deserialization-Cheat-Sheet: The cheat sheet about Java Deserialization vulnerabilities