agentleFS
Cristallin2006Cristallin2006/ghidra-skill-for-dsh/pwn-exploit/SKILL.md

pwn-exploit

Skill11 starsChanged 49 days agoMITView on GitHub

CTF 二进制利用(pwn):栈溢出/ROP/ret2libc/SROP/格式化字符串/堆利用(tcache/House of X)/FSOP/seccomp 沙箱 ORW/内核 pwn 入门/游戏与文字冒险题(商店经济溢出·道具编辑堆原语)。触发:pwn/利用/exploit/getshell/拿到 shell/ROP/ret2libc/格式化串/堆题/tcache/canary 绕过/给了 libc 和 nc 地址/冒险游戏菜单题。不做:程序逻辑没读懂(回 ghidra-static)、漏洞模式识别(归 vuln-audit)、web/纯密码题。动手前必须先用 skill 工具加载本 skill 全文并遵守其流程;一切观察/结论用 ledger.py 落账。

The file

Files
SKILL.md

Pwn Exploit(场景 8:从洞到 flag)

前置:漏洞已由 vuln-audit/ghidra-static 定位,或附件是典型 pwn 配置(binary + libc.so.6 + nc 地址)/后继:拿到远程 flag 回显 → ledger.py conclude --program-accept 交付;「打不通、其实是程序没读懂」→ 回 ghidra-static;「洞在哪都还没确认」→ 回 vuln-audit

执行环境铁规:exp 一律在 WSL 里跑,pwntools 在 Windows 半残、pwndbg 仅 Linux。Windows 侧只做静态分析(ghidra-core 部分)。

路径约定

# WSL 内:
PW=/root/re-pwn-venv/bin          # pwntools 4.15.0(checksec/cyclic/asm/libcdb)+ ROPgadget + ropper + qiling
PE="$HOME/.dsh/skills/pwn-exploit/scripts"   # 本 skill 脚本
SK="$HOME/.dsh/skills/ghidra-core/scripts"   # ledger.py 等家族闸门
# 系统级:gdb 15.1 + pwndbg(~/.gdbinit 已挂)、one_gadget、seccomp-tools(gem)、patchelf(apt)

流程

1. 开局硬门:pwn_triage(没跑过禁止写 exp)

python3 "$PE/pwn_triage.py" ./vuln            # 保护矩阵 + 附件核对 + 策略 hint
  • 输出 NX/Canary/PIE/RELRO/seccomp 五件套 + 附件清单(有没有给 libc/ld/Dockerfile)+ 决策树路由
  • seccomp 检出 → 立即 seccomp-tools dump ./vuln 看白名单(留 ORW 走 ORW 链,见 references/basic-chain.md §7)
  • 结论立即 python3 "$SK/ledger.py" conclude --source checksec 锁定——后续所有地址策略由此派生,禁止中途凭印象改判

2. 保护 → 策略决策树

NXCanaryPIERELRO打法
关———直接塞 shellcode(shellcraft_asm.py 生成)
开无无任意ret2win / ret2libc,地址写死
开无开任意先 leak 代码地址算 PIE base 再 ROP
开有任意任意先 leak canary(fork server 逐字节爆破 / fmtstr 泄露),禁止硬撞
———PartialGOT 可写 → GOT overwrite 是最短路径
———FullGOT 只读 → __free_hook(glibc<2.34)/ 返回地址 / FSOP

完整决策与 pitfall 见 references/basic-chain.md §1-2。

3. 漏洞类型路由表

分诊/审计发现去哪
栈溢出(gets/scanf %s/strcpy/栈上 memcpy 长度失控)references/basic-chain.md §2 标准链路 → references/overflow-basics.md 变体(canary 逐字节/struct 指针/parser 溢出)
要写 ROP 链 / badchar / 栈迁移 / ret2csureferences/rop-and-shellcode.md;进阶(SROP/RETF 架构切换/ret2dlresolve/.fini_array)→ references/rop-advanced.md、references/advanced.md
printf(user_input)references/format-string.md(leak/GOT 覆写/blind pwn/__free_hook)+ scripts/fmtstr_payload_suite.py
菜单题 malloc/free/edit、tcache/fastbin/unsorted binreferences/heap-techniques.md + heap-techniques-2.md(glibc 2.39 tcache 保护、House of Apple/Force/Orange/Einherjar/Tangerine/Emma/Water)
Full RELRO + PIE 的堆题、要打 _IO_2_1_stdout_references/heap-fsop.md(FSOP/vtable 校验绕过)
seccomp 禁 execvereferences/basic-chain.md §7 ORW 链 + scripts/seccomp_orw_generator.py;RETF x64→x32 绕过 → references/rop-advanced.md
内核题(vmlinuz/bzImage/initramfs/ko)references/kernel.md(环境/QEMU/ret2usr/modprobe_path)→ kernel-bypass.md(KASLR/KPTI/SMEP/SMAP)→ kernel-techniques.md(tty_struct kROP/cross-cache);Tier C 需独立 QEMU 环境
沙箱/受限 shell/自定义 VM 逃逸references/sandbox-escape.md
游戏/文字冒险题(菜单+RPG:商店/战斗/道具编辑/地图移动)references/game-pwn.md(命令面发现/经济系统整数溢出/数值墙=路标/道具编辑=堆原语入口)
以上都不像、手法很怪references/advanced-exploits.md ~ -5(五本案例集,按关键词 grep)+ references/field-notes.md

4. exp 工程规范(强制)

  • 模板三态:一律从 references/basic-chain.md §6 骨架起手(process / REMOTE / GDB 三态,context.log_level='debug' 只在 DEBUG 开);收编的 5 个生成器(ret2libc/SROP/fmtstr/seccomp ORW/shellcraft)产 payload 片段,不是完整 exp
  • 接收锚定 recvuntil/recvline,禁止 sleep 猜时序(race 题除外,见 references/advanced.md)
  • 偏移/地址/canary 全部来自工具读数(cyclic + pwndbg core / ROPgadget|ropper 双工具互验),禁止手数栈布局——读数不一致时第一嫌疑人是读数不是程序(铁律 8)
  • 调试崩溃现场:python3 exp.py GDB 或 core 文件 + pwndbg> cyclic -l;看崩溃现场优先于改 payload 重试

5. 验证门:本地通 ≠ 远程通

  1. 题目给了 libc → 本地必须 patchelf --set-interpreter ./ld.so --set-rpath '$ORIGIN' ./vuln 对齐后再测(见 references/basic-chain.md §3)
  2. 题目没给 libc → leak 两个函数地址低 12 位,$PW/libcdb lookup puts 0xf70 read 0x.. 反查版本;查不到上 DynELF(references/rop-and-shellcode.md)
  3. flag 结论的证据必须是远程回显:ledger.py conclude --kind flag --program-accept '<远程 cat flag 输出>';patchelf 副本上的成功只配 --source runtime-oracle 中间结论

6. 时间盒与断路器

  • payload 迭代走 ledger 断路器:region 键 payload@<vuln_func>,同一漏洞点第二次改动必须 --delta 回答「和上次差在哪」,答不出强制升级(pwndbg 看现场 / 回静态核对 / 换技术路线)——禁止不换思路改第三个 payload
  • 半边事实接线(强制,b781ff3c 判例):一旦推出「正常路径不可行 / 作者必须留了路」类结论,禁止闷头向前找新路——先 python3 "$SK/ledger.py" query <样本> 全量盘点已有 conclude/observe,专找已识别但从未利用的发现(洞、异常值、天量数字),把它接到当前断点上。判例:25 强网杯 adventure——agent 10:11 识别 shop 整数溢出、10:40 算出龙 800 万 HP 打不死,两个半边事实 30 分钟没接线,超时零 exploit;10:29 亲眼看到炸弹 700 万库存也没联想。数值墙(打不死的血条/买不起的价格)出现 = 出题人在指路,答案几乎一定在账本上已经记过的某个发现里
  • 单技术路线 ≤20 分钟无产出 → 回 §3 路由表换行;leak 出的地址不像 libc(低 12 位对不上符号表)→ 回 §5.2 重查版本
  • 彻底卡住:ledger.py stuck --escalate '<能力范围内的下一步>',escalate 必须先执行再谈交卷(铁律 6)

脚本速查

脚本一句话
scripts/pwn_triage.py开局硬门:零依赖解析 ELF 保护五件套 + 附件核对(libc/ld/Dockerfile)+ 决策树 hint;发现 libc 附件但未 patchelf 对齐时告警;seccomp 检出提示 seccomp-tools dump
scripts/ret2libc_two_stage.py两段式 ret2libc payload 生成器(leak → 回 main → system),yield 多变体
scripts/srop_execve.pySROP execve 帧生成器(SigreturnFrame,rax=15)
scripts/fmtstr_payload_suite.py格式化串 payload 套件(按写入宽度分档)
scripts/seccomp_orw_generator.pyseccomp 环境 ORW(open/read/write)shellcode 生成
scripts/shellcraft_asm.pyshellcraft + asm 包装生成器

生成器脚本依赖 pwntools,在 WSL 用 /root/re-pwn-venv/bin/python 跑。

References

文件何时读
references/basic-chain.md第一站:checksec 打法树/栈溢出标准链路/libc 泄露/one_gadget 抉择/canary 与 PIE 绕过/pwntools 骨架/seccomp ORW(中文,家族工具路径)
references/overflow-basics.md栈/全局溢出变体:canary 逐字节爆破、struct 指针覆写、parser 溢出、带符号整数绕过、OOB 读 leak
references/rop-and-shellcode.mdROP 主参考:ret2libc/ret2csu/badchar XOR/栈迁移/exotic gadget/DynELF
references/rop-advanced.mdSROP(含 UTF-8 约束)/RETF 架构切换过 seccomp/ret2dlresolve/.fini_array 劫持/盲 shellcode
references/format-string.mdfmtstr 全家桶:leak/GOT 覆写/blind/__free_hook/.rela.plt/变换后 fmtstr
references/heap-techniques.md / heap-techniques-2.md堆主参考:tcache/fastbin/unsorted bin、unlink、House of X 全家、glibc 2.39 保护、自定义分配器(nginx/talloc)、musl 堆
references/heap-fsop.mdFSOP:_IO_2_1_stdout_ 泄露链、vtable 校验绕过、Full RELRO+PIE 收尾
references/advanced.mdseccomp 进阶/UAF/JIT/ret2dlresolve/内核入门衔接
references/advanced-exploits.md ~ -5案例配方库(VM/JIT/类型混淆/Windows SEH/CFG/奇技),按症状关键词 grep
references/sandbox-escape.md自定义 VM/FUSE/restricted shell/模拟器逃逸
references/game-pwn.md游戏/文字冒险题:命令面发现(hash 桶+堆字符串表)、经济系统整数溢出、「数值墙=路标」、道具编辑堆原语、作者故意后门(adventure 判例,中文)
references/kernel.md / kernel-bypass.md / kernel-techniques.md内核:QEMU 环境搭建 → KASLR/KPTI/SMEP/SMAP 绕过 → tty_struct kROP/cross-cache/userfaultfd
references/field-notes.md上述都查完后的杂项笔记(堆速查/历史套路)

知识来源:ljagiello/ctf-skills ctf-pwn(MIT);basic-chain.md 组织结构参考 zhaoxuya520/reverse-skill(MIT)。翻译层在路由表,references 正文保留英文原文。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.