• Stars
    star
    588
  • Rank 76,022 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ZKar is a Java serialization protocol analysis tool implement in Go.

ZKar

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

📦 Installing

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())
}

💻 Command line utility tool

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"

asciicast

🛠 Tests

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.

📝 TODO

  • Java bytecodes parser and generator
  • JDK/JRE 8u20 Gadget supporting
  • Serialization payloads generator
  • An implementation of RMI/LDAP in Go

⚖️ License

ZKar is released under the MIT license. See LICENSE

👀 See Also

  • 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

More Repositories

1

Mind-Map

各种安全相关思维导图整理收集
4,457
star
2

JavaThings

Share Things Related to Java - Java安全漫谈笔记相关内容
Java
1,679
star
3

mooder

Mooder是一款开源、安全、简洁、强大的团队内部知识分享平台。
Python
762
star
4

Minos

一个基于Tornado/mongodb/redis的社区系统。
JavaScript
677
star
5

code-breaking

Code-Breaking Puzzles
JavaScript
274
star
6

xray-poc-generation

🧬 辅助生成 XRay YAML POC
JavaScript
252
star
7

vueinfo

Extract website information from Vue
JavaScript
217
star
8

arbitrary-php-extension

这是一个实验性的PHP扩展,加载这个扩展后,每次请求将可以执行一段自己的PHP代码。
C
201
star
9

collision-webshell

A webshell and a normal file that have the same MD5
189
star
10

XssHtml

php富文本过滤类,XSS Filter
PHP
148
star
11

python-xss-filter

Based on native Python module HTMLParser purifier of HTML, To Clear all javascript in html
Python
117
star
12

realworldctf

My Real World CTF challenges
Python
115
star
13

py-wget

small wget by python
Python
88
star
14

XDCTF2015

writeup about XDCTF 2015
Python
63
star
15

PaddingZip

PaddingZip is a tool that you can craft a zip file that contains the padding characters between the file content.
Python
61
star
16

PasswordKeeper

一个本地密码管理软件
C++
49
star
17

ctfdbbuilder

a database query builder for CTFer(出题专用/开发阶段/慎用)
PHP
32
star
18

beautifyjs

A simple JavaScript beautify tool
JavaScript
28
star
19

race-condition-playground

Playground for Race Condition attack
Python
24
star
20

phpsrc-debug-docker

Debug environment for PHP inside a Docker container. Document waiting to be completed.
Dockerfile
24
star
21

Pytalk_Irc

An online IRC system based on Web.py~
JavaScript
21
star
22

sangebaimao_20151112

2015.11.12 三个白帽一题的源码
HTML
18
star
23

vindicator

Vindicator is a lightweight Golang library that is designed to hold and check any blocking function. e.g. subprocess, network connection...
Go
18
star
24

projector-runner

Run Swing based GUI application within the Docker container through the Jetbrains Projector, and access it from browsers.
Shell
17
star
25

bytecode-viewer

git lfs based bytecode-viewer and follow dependencies. Based on https://github.com/Konloch/bytecode-viewer and https://github.com/ThexXTURBOXx/bytecode-viewer
Java
15
star
26

Jsdxss

DOMXSS Filter Based on javascript
JavaScript
15
star
27

fbi_installer

remote install 3DS games for FBI
Go
14
star
28

pyduktape2

Embed the Duktape JS interpreter in Python, forking and develop based on https://github.com/stefano/pyduktape
Cython
14
star
29

tls_proxy

A lightweight reverse proxy server that converts TLS traffic to TCP, allowing secure communication between clients and upstream servers.
Go
10
star
30

phith0n

My Github profile page
8
star
31

embedded_django

a minimal django application template
Python
8
star
32

goattribute

goattribute is a lightweight Go library that allows you to set (and get) attributes of a struct dynamically, using dot notation (e.g., `a.b.c`).
Go
6
star
33

go_sampler

A sample for Go project
Go
5
star
34

asp_mssql_tool

exec mssql command on asp lang
ASP
4
star
35

hyperapp-startup

hyperapp startup boilerplate
JavaScript
4
star
36

Talks

ppt and code in some talks
HTML
4
star
37

webhook

github/bitbucket/coding push webhook
PHP
2
star
38

gin-cookiecutter

Gin template for cookiecutter
Go
1
star
39

vue3-cookiecutter

template for vue3 + vite
SCSS
1
star
40

git-skill

1
star
41

django-cookiecutter

cookiecutter is a command-line utility that creates projects from template.
Python
1
star