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"
"log"
"os"
)
func main() {
fs, _ := os.Open("./testcases/ysoserial/CommonsCollections6.ser")
defer fs.Close()
serialization, err := serz.FromReader(fs)
if err != nil {
log.Fatal("parse error")
}
fmt.Println(serialization.ToString())
}
Here is an example to show how to read an exist payload and modify it to a UTF-8 overlong encoding payload.
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
- Support read/write UTF-8 overlong encoding feature
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