@dsmm/dsmm 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +103 -0
- package/README.md +70 -2
- package/agent-presets/dsmm-builder/agent.cordis.yml +210 -0
- package/agent-presets/dsmm-builder/preset.yml +3 -0
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-clarifier/preset.yml +3 -0
- package/agent-presets/dsmm-code-search/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-code-search/preset.yml +3 -0
- package/agent-presets/dsmm-creative/agent.cordis.yml +31 -0
- package/agent-presets/dsmm-creative/preset.yml +3 -0
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-doc-search/preset.yml +3 -0
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-media-reader/preset.yml +3 -0
- package/agent-presets/dsmm-oracle/agent.cordis.yml +31 -0
- package/agent-presets/dsmm-oracle/preset.yml +3 -0
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +31 -0
- package/agent-presets/dsmm-oracle-2nd/preset.yml +3 -0
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +215 -0
- package/agent-presets/dsmm-orchestrator/preset.yml +3 -0
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +33 -0
- package/agent-presets/dsmm-plan-critic/preset.yml +3 -0
- package/agent-presets/dsmm-planner/agent.cordis.yml +33 -0
- package/agent-presets/dsmm-planner/preset.yml +3 -0
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +33 -0
- package/agent-presets/dsmm-reviewer/preset.yml +3 -0
- package/cordis.patch.yml +8 -0
- package/docs/agent-presets.md +19 -0
- package/docs/compatibility.md +49 -0
- package/docs/design.md +237 -0
- package/docs/lsp.md +40 -0
- package/docs/migration-from-ocmm.md +54 -0
- package/docs/model-routing.md +61 -0
- package/docs/releasing.md +52 -0
- package/docs/research/deepseek-v4-pro.md +74 -0
- package/docs/research/oh-dsh.md +96 -0
- package/docs/roadmap.md +207 -0
- package/docs/runtime-recovery.md +75 -0
- package/docs/safety-guards.md +55 -0
- package/docs/settings-status.md +55 -0
- package/docs/skill-sync.md +20 -0
- package/lib/commands.d.ts +13 -0
- package/lib/commands.js +55 -0
- package/lib/dsh-events.d.ts +21 -0
- package/lib/dsh-events.js +2 -0
- package/lib/dsh-types.d.ts +312 -0
- package/lib/dsh-types.js +2 -0
- package/lib/guards.d.ts +10 -0
- package/lib/guards.js +252 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.js +58 -0
- package/lib/lsp.d.ts +30 -0
- package/lib/lsp.js +154 -0
- package/lib/mode.d.ts +6 -0
- package/lib/mode.js +62 -0
- package/lib/model-family.d.ts +6 -0
- package/lib/model-family.js +49 -0
- package/lib/model-routing.d.ts +11 -0
- package/lib/model-routing.js +128 -0
- package/lib/plan-validation.d.ts +3 -0
- package/lib/plan-validation.js +119 -0
- package/lib/preset-materializer.d.ts +36 -0
- package/lib/preset-materializer.js +258 -0
- package/lib/preset-registry.d.ts +5 -0
- package/lib/preset-registry.js +126 -0
- package/lib/preset-skills.d.ts +12 -0
- package/lib/preset-skills.js +28 -0
- package/lib/prompts.d.ts +13 -0
- package/lib/prompts.js +82 -0
- package/lib/recovery-policy.d.ts +25 -0
- package/lib/recovery-policy.js +252 -0
- package/lib/role-providers.d.ts +13 -0
- package/lib/role-providers.js +61 -0
- package/lib/role-routing.d.ts +15 -0
- package/lib/role-routing.js +144 -0
- package/lib/role-subagents.d.ts +6 -0
- package/lib/role-subagents.js +54 -0
- package/lib/roles.d.ts +29 -0
- package/lib/roles.js +241 -0
- package/lib/runtime-recovery.d.ts +5 -0
- package/lib/runtime-recovery.js +168 -0
- package/lib/session-scope.d.ts +9 -0
- package/lib/session-scope.js +40 -0
- package/lib/settings.d.ts +123 -0
- package/lib/settings.js +447 -0
- package/lib/shell-command.d.ts +18 -0
- package/lib/shell-command.js +492 -0
- package/lib/skills.d.ts +18 -0
- package/lib/skills.js +64 -0
- package/lib/state.d.ts +13 -0
- package/lib/state.js +64 -0
- package/lib/status.d.ts +55 -0
- package/lib/status.js +193 -0
- package/package.json +129 -4
- package/patches/agent-presets-root.example.cordis.patch.yml +14 -0
- package/patches/ocmm-lsp-mcp.example.cordis.patch.yml +15 -0
- package/prompts/deepseek-flash.md +11 -0
- package/prompts/deepseek-v4-pro.md +14 -0
- package/prompts/deepwork.md +32 -0
- package/skills/brainstorming/SKILL.md +15 -0
- package/skills/debugging/SKILL.md +12 -0
- package/skills/debugging/references/logging.md +91 -0
- package/skills/debugging/references/methodology/00-setup.md +108 -0
- package/skills/debugging/references/methodology/02-investigate.md +67 -0
- package/skills/debugging/references/methodology/03-flaky-triage.md +69 -0
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +83 -0
- package/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/skills/debugging/references/methodology/06-fix.md +123 -0
- package/skills/debugging/references/methodology/08-qa.md +94 -0
- package/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +217 -0
- package/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/skills/debugging/references/runtimes/go.md +252 -0
- package/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/skills/debugging/references/runtimes/node.md +260 -0
- package/skills/debugging/references/runtimes/python.md +248 -0
- package/skills/debugging/references/runtimes/rust.md +234 -0
- package/skills/debugging/references/scripts/dap.mjs +533 -0
- package/skills/debugging/references/tools/dap.md +89 -0
- package/skills/debugging/references/tools/ghidra.md +212 -0
- package/skills/debugging/references/tools/playwright-cli.md +316 -0
- package/skills/debugging/references/tools/pwndbg.md +263 -0
- package/skills/debugging/references/tools/pwntools.md +265 -0
- package/skills/dispatching-parallel-agents/SKILL.md +14 -0
- package/skills/receiving-code-review/SKILL.md +13 -0
- package/skills/remove-ai-slops/SKILL.md +14 -0
- package/skills/requesting-code-review/SKILL.md +10 -0
- package/skills/subagent-driven-development/SKILL.md +13 -0
- package/skills/writing-plans/SKILL.md +14 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# pwndbg — GDB With the Useful Views Always On
|
|
2
|
+
|
|
3
|
+
**https://github.com/pwndbg/pwndbg**
|
|
4
|
+
|
|
5
|
+
pwndbg is a GDB plugin that turns GDB into something humans can actually use for binary debugging. It's strictly a superset of plain GDB — every vanilla GDB command still works, and pwndbg adds views and commands that make you productive.
|
|
6
|
+
|
|
7
|
+
**If you'd reach for plain `gdb`, reach for pwndbg instead.** The only reason not to is if pwndbg isn't installed on the machine, and that's a 2-minute fix.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# macOS
|
|
15
|
+
brew install pwndbg
|
|
16
|
+
# Or from source:
|
|
17
|
+
git clone https://github.com/pwndbg/pwndbg
|
|
18
|
+
cd pwndbg && ./setup.sh
|
|
19
|
+
|
|
20
|
+
# Linux
|
|
21
|
+
# Most distros: apt/dnf/pacman install pwndbg (check availability)
|
|
22
|
+
# Or the same git + ./setup.sh
|
|
23
|
+
|
|
24
|
+
# Verify
|
|
25
|
+
gdb --version
|
|
26
|
+
gdb ./any-binary
|
|
27
|
+
# At gdb prompt, you should see pwndbg banner + colorful context view
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Once installed, pwndbg auto-loads every time you start `gdb`. You don't source anything manually.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## The `context` view — the one feature that changes everything
|
|
35
|
+
|
|
36
|
+
Plain GDB: you run `info registers`, then `bt`, then `x/10xw $rsp`, then `disas`. Four commands to see what's going on.
|
|
37
|
+
|
|
38
|
+
pwndbg: `context` (or it auto-shows at every break). One command. Everything on screen:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
──── registers ────
|
|
42
|
+
RAX 0x0
|
|
43
|
+
RBX 0x7ffffffde158
|
|
44
|
+
RCX 0x7fffff7abf10
|
|
45
|
+
...
|
|
46
|
+
──── disasm ────
|
|
47
|
+
► 0x401234 mov rdi, rax
|
|
48
|
+
0x401237 call 0x401190
|
|
49
|
+
...
|
|
50
|
+
──── stack ────
|
|
51
|
+
00:0000│ rsp 0x7ffffffde0a0 → 0x7fffff7c4000
|
|
52
|
+
01:0008│ 0x7ffffffde0a8 → 0x0
|
|
53
|
+
...
|
|
54
|
+
──── backtrace ────
|
|
55
|
+
► f 0 0x401234 parse_input+0x3c
|
|
56
|
+
f 1 0x401180 main+0x120
|
|
57
|
+
f 2 0x7fffff7a5083 __libc_start_main+0xf3
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
You always know where you are, what the CPU state is, what's on the stack, and how you got here. This is why pwndbg is the default.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Launch recipes
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Debug an existing binary
|
|
68
|
+
gdb ./target
|
|
69
|
+
|
|
70
|
+
# With args
|
|
71
|
+
gdb --args ./target arg1 arg2
|
|
72
|
+
|
|
73
|
+
# Attach to a running process
|
|
74
|
+
gdb -p $(pgrep target)
|
|
75
|
+
|
|
76
|
+
# With a core dump
|
|
77
|
+
gdb ./target ./core
|
|
78
|
+
|
|
79
|
+
# Headless / remote (for automation or IDE attach)
|
|
80
|
+
gdbserver :2345 ./target # on the target box
|
|
81
|
+
gdb ./target # on your box
|
|
82
|
+
(gdb) target remote <host>:2345
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
At the pwndbg prompt:
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Essential commands (pwndbg additions)
|
|
90
|
+
|
|
91
|
+
### Layout / view
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
context # reprint the context view (usually auto)
|
|
95
|
+
context regs stack # only show registers + stack sections
|
|
96
|
+
tel $rsp 20 # telescope — walk pointers at $rsp for 20 slots (KEY COMMAND)
|
|
97
|
+
tel $rdi 10 # walk pointers at $rdi (e.g. to dump a struct)
|
|
98
|
+
stack 20 # 20 entries of stack
|
|
99
|
+
vmmap # virtual memory map of the process
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**`telescope` is pwndbg's killer command.** Given an address, it walks pointers recursively:
|
|
103
|
+
```
|
|
104
|
+
00:0000│ 0x7ffd... → 0x601010 (heap) → 0x2a (unknown, i.e. a number 42)
|
|
105
|
+
01:0008│ 0x7ffd... → 0x7fff... (stack) → 'hello world'
|
|
106
|
+
```
|
|
107
|
+
This single view resolves 80% of "what is at this address" questions.
|
|
108
|
+
|
|
109
|
+
### Heap debugging
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
heap # overview of chunks
|
|
113
|
+
bins # tcache / fastbin / unsorted / smallbin / largebin state
|
|
114
|
+
malloc_chunk <addr> # inspect a specific chunk
|
|
115
|
+
find_fake_fast <addr> # (exploit context) find fake-fast overlap candidates
|
|
116
|
+
vis_heap_chunks # visualize heap layout
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For use-after-free / double-free / heap overflow hypotheses, `heap` + `bins` is usually sufficient to see the corruption.
|
|
120
|
+
|
|
121
|
+
### Exploitation-adjacent (useful for bug understanding too)
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
checksec # NX, PIE, RELRO, canary status
|
|
125
|
+
rop --grep 'pop rdi' # find ROP gadgets
|
|
126
|
+
nx # step over (aliased nicely)
|
|
127
|
+
ni # step over single instruction
|
|
128
|
+
si # step into single instruction
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Search
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
search -t byte 0x41 # find byte 0x41 anywhere in memory
|
|
135
|
+
search -t string "admin" # find string
|
|
136
|
+
search -p <addr> # find pointers to <addr>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Standard GDB commands still work
|
|
142
|
+
|
|
143
|
+
pwndbg doesn't replace GDB; it augments it. Everything you know still works:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
break main # breakpoint at function
|
|
147
|
+
b *0x401234 # breakpoint at address
|
|
148
|
+
b file.c:42 # breakpoint at file:line
|
|
149
|
+
c # continue
|
|
150
|
+
n # next (source-level step over)
|
|
151
|
+
s # step (source-level step into)
|
|
152
|
+
finish # step out
|
|
153
|
+
info breakpoints # list breakpoints
|
|
154
|
+
delete <n> # delete breakpoint
|
|
155
|
+
watch <var> # break on write to variable
|
|
156
|
+
rwatch <var> # break on read
|
|
157
|
+
awatch <var> # break on access
|
|
158
|
+
p <expr> # print expression
|
|
159
|
+
p/x <expr> # print in hex
|
|
160
|
+
x/20xw <addr> # examine 20 words as hex
|
|
161
|
+
bt # backtrace
|
|
162
|
+
frame <n> # switch frame
|
|
163
|
+
info registers # registers (but `context` is better)
|
|
164
|
+
disassemble <func> # disasm a function
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Python scripting inside GDB
|
|
170
|
+
|
|
171
|
+
pwndbg exposes a full Python API. Useful for automating observations across many breakpoints:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
(gdb) python
|
|
175
|
+
import gdb
|
|
176
|
+
def on_break():
|
|
177
|
+
frame = gdb.selected_frame()
|
|
178
|
+
pc = frame.read_register('pc')
|
|
179
|
+
print(f'hit at {hex(int(pc))}')
|
|
180
|
+
# Dump args, locals, anything
|
|
181
|
+
end
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Or scripted runs from outside:
|
|
185
|
+
```bash
|
|
186
|
+
gdb -batch -ex 'source script.gdb' -ex 'run' ./target
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Common workflows by bug type
|
|
192
|
+
|
|
193
|
+
### Segfault / crash
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
gdb ./target
|
|
197
|
+
(gdb) run <args>
|
|
198
|
+
# ... crash ...
|
|
199
|
+
(gdb) context # see the crash site
|
|
200
|
+
(gdb) bt # how did we get here?
|
|
201
|
+
(gdb) info registers # what state
|
|
202
|
+
(gdb) tel $rsp 20 # what's on the stack
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### "Function returns wrong value"
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
gdb ./target
|
|
209
|
+
(gdb) break <function>
|
|
210
|
+
(gdb) run <args>
|
|
211
|
+
# At breakpoint:
|
|
212
|
+
(gdb) finish # let it run to the return
|
|
213
|
+
# pwndbg shows RAX (return value) in context
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### "Variable has unexpected value at point X"
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
gdb ./target
|
|
220
|
+
(gdb) break <point-X>
|
|
221
|
+
(gdb) run
|
|
222
|
+
# At breakpoint:
|
|
223
|
+
(gdb) p <var> # its value
|
|
224
|
+
(gdb) watch <var> # set a watchpoint — break when it changes
|
|
225
|
+
(gdb) c # continue; next stop is where it was modified
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### "Memory corruption / heap bug"
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
gdb ./target
|
|
232
|
+
(gdb) run
|
|
233
|
+
# Crash at free():
|
|
234
|
+
(gdb) heap # heap state
|
|
235
|
+
(gdb) bins # bin state — often shows corruption here
|
|
236
|
+
(gdb) vis_heap_chunks # visualize
|
|
237
|
+
(gdb) malloc_chunk <suspicious-addr>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Gotchas
|
|
243
|
+
|
|
244
|
+
- **`bt` looks weird on stripped binaries** — function names become offsets. Use Ghidra's function labels to map back (see [ghidra.md](ghidra.md)).
|
|
245
|
+
- **PIE binaries have randomized base addresses.** Addresses you see in Ghidra are unslid; addresses in pwndbg are slid. The `vmmap` command shows the base, and pwndbg's `piebase` command gives you the offset.
|
|
246
|
+
- **Optimized builds inline functions.** You'll set a breakpoint on `my_function` and it won't hit because the function was inlined. Either disable optimizations or break on callers.
|
|
247
|
+
- **Stack canaries trigger `__stack_chk_fail`.** If you see that in a backtrace, the bug caused a stack-smash; look one frame up.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Phase 9 cleanup specifics
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Kill gdb / pwndbg sessions
|
|
255
|
+
pkill -f 'gdb' || true
|
|
256
|
+
pkill -f 'gdbserver' || true
|
|
257
|
+
|
|
258
|
+
# Remove core dumps generated during session
|
|
259
|
+
rm -f ./core ./core.* ~/core.*
|
|
260
|
+
|
|
261
|
+
# Remove any scripted GDB files
|
|
262
|
+
rm -f /tmp/debug-*.gdb
|
|
263
|
+
```
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# pwntools — Scripted Binary / Network Interaction
|
|
2
|
+
|
|
3
|
+
**https://docs.pwntools.com/en/stable/ · https://github.com/Gallopsled/pwntools**
|
|
4
|
+
|
|
5
|
+
pwntools is a Python framework for building reproducible interactions with binaries and network services. Originally built for CTF exploitation, it's the correct tool for any situation where you need:
|
|
6
|
+
|
|
7
|
+
- A crafted input sent to a binary or network service, repeatably
|
|
8
|
+
- A "failing test" equivalent for a bug that only manifests with specific byte-level input
|
|
9
|
+
- A fuzz harness
|
|
10
|
+
- An exploit PoC
|
|
11
|
+
- Anything where you're tempted to use `echo ... | ./binary` but need more control than shell allows
|
|
12
|
+
|
|
13
|
+
**Use pwntools for Phase 5 reproduction of binary bugs and Phase 7 tests against binaries.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install pwntools
|
|
21
|
+
# Or in a venv:
|
|
22
|
+
python -m venv .venv && source .venv/bin/activate
|
|
23
|
+
pip install pwntools
|
|
24
|
+
|
|
25
|
+
# Verify
|
|
26
|
+
python -c 'from pwn import *; print("ok")'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
On some Linux distros you may need build deps: `apt install python3-dev libssl-dev`.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## The core API in five idioms
|
|
34
|
+
|
|
35
|
+
### 1. Process / Remote — the same interface
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from pwn import *
|
|
39
|
+
|
|
40
|
+
# Local process
|
|
41
|
+
p = process('./target')
|
|
42
|
+
|
|
43
|
+
# Remote service
|
|
44
|
+
p = remote('example.com', 1337)
|
|
45
|
+
|
|
46
|
+
# SSH (tunnel to a remote process)
|
|
47
|
+
shell = ssh('user', 'host', password='...')
|
|
48
|
+
p = shell.process('./target', cwd='/tmp')
|
|
49
|
+
|
|
50
|
+
# Same methods on all of the above — this is the value proposition
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. I/O — the only five methods you need
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
p.send(b'data') # send bytes
|
|
57
|
+
p.sendline(b'data') # send bytes + \n
|
|
58
|
+
p.recv(n) # receive up to n bytes
|
|
59
|
+
p.recvuntil(b'> ') # receive until pattern (blocks)
|
|
60
|
+
p.recvline() # receive until \n
|
|
61
|
+
p.interactive() # hand control to your terminal (for manual exploration)
|
|
62
|
+
|
|
63
|
+
# Combined
|
|
64
|
+
p.sendlineafter(b'prompt> ', b'payload')
|
|
65
|
+
p.sendafter(b'key:', key)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Timeouts:
|
|
69
|
+
```python
|
|
70
|
+
try:
|
|
71
|
+
data = p.recvuntil(b'done', timeout=5)
|
|
72
|
+
except pwnlib.exception.EOFError:
|
|
73
|
+
print('process died')
|
|
74
|
+
except TimeoutError:
|
|
75
|
+
print('no response in 5s')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 3. context — set arch/OS once, tools align
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
context.binary = elf = ELF('./target') # auto-sets arch/os/endianness
|
|
82
|
+
# or explicitly:
|
|
83
|
+
context.update(arch='amd64', os='linux', endian='little', bits=64)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
After setting context, helpers like `asm()`, `disasm()`, `cyclic()`, and `ROP()` produce correct output for that target automatically.
|
|
87
|
+
|
|
88
|
+
### 4. ELF — parse without reverse-engineering by hand
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
elf = ELF('./target')
|
|
92
|
+
|
|
93
|
+
elf.symbols['main'] # address of main
|
|
94
|
+
elf.plt['printf'] # address in PLT (dynamic linkage)
|
|
95
|
+
elf.got['printf'] # GOT entry
|
|
96
|
+
elf.address = 0x555555554000 # set base for PIE binaries
|
|
97
|
+
elf.search(b'/bin/sh') # find string or bytes in the binary
|
|
98
|
+
elf.functions['main'].address # same as elf.symbols['main']
|
|
99
|
+
list(elf.functions)[:10] # first 10 function names
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For the libc that's linked:
|
|
103
|
+
```python
|
|
104
|
+
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
|
|
105
|
+
libc.symbols['system']
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 5. cyclic — find offsets without counting
|
|
109
|
+
|
|
110
|
+
For "where exactly does user input reach this variable" bugs:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
p = process('./target')
|
|
114
|
+
p.sendline(cyclic(256)) # send a De Bruijn pattern
|
|
115
|
+
# Crash occurs; note the crash value (e.g. RIP = 0x6161616c)
|
|
116
|
+
offset = cyclic_find(0x6161616c) # returns 12 (or wherever in the pattern)
|
|
117
|
+
# Now you know: byte 12 of your input lands at RIP
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Saves an hour of "pad by N bytes then check" iteration.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Logging during debug
|
|
125
|
+
|
|
126
|
+
pwntools logs output by default. Configure level in the script:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
context.log_level = 'debug' # very verbose — shows sent/received bytes
|
|
130
|
+
context.log_level = 'info' # default
|
|
131
|
+
context.log_level = 'warning' # quiet
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
For long scripts, log milestones:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
log.info('Connected to target')
|
|
138
|
+
log.success('Bypassed the check')
|
|
139
|
+
log.failure('Canary corrupted')
|
|
140
|
+
log.progress('brute-forcing').status('attempt %d' % i)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Typical debug-session patterns
|
|
146
|
+
|
|
147
|
+
### Reproduce a crash with a specific input
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
# /tmp/debug-repro.py
|
|
151
|
+
from pwn import *
|
|
152
|
+
context.binary = './target'
|
|
153
|
+
|
|
154
|
+
p = process('./target')
|
|
155
|
+
p.sendlineafter(b'> ', b'<bad input that crashes>')
|
|
156
|
+
p.wait()
|
|
157
|
+
# If it crashed, p.poll() returns non-zero
|
|
158
|
+
assert p.poll() is not None and p.poll() != 0, 'expected crash, got clean exit'
|
|
159
|
+
log.success(f'confirmed crash (exit {p.poll()})')
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Journal this script path. Run it as your "red test":
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
python /tmp/debug-repro.py
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Fuzz harness for a suspected input class
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
# /tmp/debug-fuzz.py
|
|
172
|
+
from pwn import *
|
|
173
|
+
import random
|
|
174
|
+
|
|
175
|
+
context.binary = './target'
|
|
176
|
+
context.log_level = 'warning' # keep quiet in the loop
|
|
177
|
+
|
|
178
|
+
crashes = []
|
|
179
|
+
for i in range(1000):
|
|
180
|
+
payload = bytes(random.randint(0, 255) for _ in range(random.randint(1, 100)))
|
|
181
|
+
p = process('./target')
|
|
182
|
+
p.sendline(payload)
|
|
183
|
+
p.wait()
|
|
184
|
+
if p.poll() is not None and p.poll() < 0: # crashed by signal
|
|
185
|
+
crashes.append((payload, p.poll()))
|
|
186
|
+
log.success(f'iter {i}: crash sig={-p.poll()}')
|
|
187
|
+
|
|
188
|
+
open('/tmp/debug-crashes.txt', 'w').write(repr(crashes))
|
|
189
|
+
log.info(f'found {len(crashes)} crashes')
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Automated exploit harness (CTF or self-testing a known CVE)
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
from pwn import *
|
|
196
|
+
context.binary = elf = ELF('./target')
|
|
197
|
+
libc = elf.libc or ELF('/lib/x86_64-linux-gnu/libc.so.6')
|
|
198
|
+
|
|
199
|
+
p = process('./target')
|
|
200
|
+
|
|
201
|
+
# Leak
|
|
202
|
+
p.sendline(b'A' * 64 + p64(elf.plt['puts']) + p64(elf.symbols['main']) + p64(elf.got['puts']))
|
|
203
|
+
leak = u64(p.recv(6).ljust(8, b'\x00'))
|
|
204
|
+
libc.address = leak - libc.symbols['puts']
|
|
205
|
+
log.success(f'libc base: {hex(libc.address)}')
|
|
206
|
+
|
|
207
|
+
# Exploit
|
|
208
|
+
rop = ROP(libc)
|
|
209
|
+
rop.system(next(libc.search(b'/bin/sh')))
|
|
210
|
+
p.sendline(b'A' * 64 + rop.chain())
|
|
211
|
+
|
|
212
|
+
p.interactive()
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Integration with gdb / pwndbg
|
|
218
|
+
|
|
219
|
+
pwntools can launch your process under gdb:
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
p = gdb.debug('./target', gdbscript='''
|
|
223
|
+
break main
|
|
224
|
+
continue
|
|
225
|
+
''')
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Or attach to a running pwntools-launched process:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
p = process('./target')
|
|
232
|
+
gdb.attach(p, gdbscript='break *0x401234')
|
|
233
|
+
# continues in a new terminal window with gdb attached
|
|
234
|
+
p.sendline(b'trigger input')
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
This is the best way to debug a specific crash repeatably — pwntools drives input, gdb/pwndbg observes runtime state.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Gotchas
|
|
242
|
+
|
|
243
|
+
- **Python version**: pwntools supports Python 3.8+. Very old distros may not have it.
|
|
244
|
+
- **`p.interactive()` blocks.** It's for manual exploration; remove it from automated scripts.
|
|
245
|
+
- **ASLR on local runs**: turn off for reproducibility during debugging: `echo 0 | sudo tee /proc/sys/kernel/randomize_va_space` (remember to revert — journal this!).
|
|
246
|
+
- **`gdb.debug()` requires `gdb-multiarch`** for cross-arch binaries.
|
|
247
|
+
- **Subprocess cleanup**: if your script crashes, orphan `./target` processes may linger. Kill them at Phase 9 or add `atexit` cleanup.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Phase 9 cleanup specifics
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Remove pwntools debug scripts
|
|
255
|
+
rm -f /tmp/debug-*.py
|
|
256
|
+
rm -f /tmp/debug-crashes.txt
|
|
257
|
+
|
|
258
|
+
# Kill orphan target processes from failed runs
|
|
259
|
+
pkill -f './target' || true # adjust to actual binary name
|
|
260
|
+
|
|
261
|
+
# Restore ASLR if disabled
|
|
262
|
+
# echo 2 | sudo tee /proc/sys/kernel/randomize_va_space # Linux default
|
|
263
|
+
|
|
264
|
+
# Revert any binary patches applied for testing (see native-binary.md for details)
|
|
265
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dispatching-parallel-agents
|
|
3
|
+
description: Use in dsmm deepwork mode when two or more tasks can run independently without shared state or sequential dependencies.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dispatching Parallel Agents
|
|
7
|
+
|
|
8
|
+
Use this skill only when parallel work is genuinely independent.
|
|
9
|
+
|
|
10
|
+
1. Split work by non-overlapping files, data, or decisions. If tasks may edit the same area or depend on each other's outcome, run them sequentially.
|
|
11
|
+
2. Give every dispatched agent a narrow scope, acceptance criteria, forbidden areas, and the evidence it must return.
|
|
12
|
+
3. Keep shared decisions in the coordinator; do not ask parallel agents to make incompatible architecture or API choices.
|
|
13
|
+
4. When agents return, compare their outputs against the plan, inspect changed files, and check for merge conflicts, duplicated work, or inconsistent assumptions.
|
|
14
|
+
5. Verify the combined result, not just each agent's isolated evidence, before continuing. Use only currently callable DSH tools and obey the host's depth and permission decisions; no child may enlarge Git authority or independently dispatch a conflicting role.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: receiving-code-review
|
|
3
|
+
description: Use when reviewer feedback arrives for dsmm work; verify findings before changing code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Receiving Code Review
|
|
7
|
+
|
|
8
|
+
Treat review feedback as claims to verify, not commands to obey blindly.
|
|
9
|
+
|
|
10
|
+
1. Reproduce or inspect each finding in the current code.
|
|
11
|
+
2. Fix only confirmed issues within the requested scope.
|
|
12
|
+
3. Re-run the evidence that proves the fix.
|
|
13
|
+
4. Re-request only an explicitly required review or one affected by a substantive fix or new evidence. Push back with concrete code and evidence when feedback is incorrect; escalate a suggestion that would alter approved scope, safety, data, permissions or public APIs.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: remove-ai-slops
|
|
3
|
+
description: Use in dsmm deepwork mode to remove AI-generated code slop without changing behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Remove AI Slops
|
|
7
|
+
|
|
8
|
+
Use this skill when asked to clean AI-generated or low-quality patterns from existing code.
|
|
9
|
+
|
|
10
|
+
1. Lock current behavior first with existing tests, new regression tests, or a clearly recorded manual check.
|
|
11
|
+
2. Identify the slop category and affected files before editing: dead code, duplicated logic, vague abstractions, overbroad error handling, noisy comments, needless indirection, or inconsistent style.
|
|
12
|
+
3. Clean the smallest safe surface. Preserve public APIs, user-visible behavior, data formats, and error semantics unless the user explicitly asks to change them.
|
|
13
|
+
4. Do not mix cleanup with unrelated refactors or feature work.
|
|
14
|
+
5. Re-run the behavior lock and relevant verification commands after cleanup; report any behavior risk that remains.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: requesting-code-review
|
|
3
|
+
description: Use when implementation risk, uncertainty, user requirement or integration complexity benefits from focused independent review.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Requesting Code Review
|
|
7
|
+
|
|
8
|
+
Review is evidence chosen for risk, not a fixed completion ceremony. Share the actual current diff and new files, goal, acceptance criteria, tests and real-surface evidence, constraints, and focused risk. A status label is not proof.
|
|
9
|
+
|
|
10
|
+
DSMM Reviewer is primary-model or primary-lane implementation self-review. Oracle and Oracle 2nd are external-model cross-check slots only when their caller explicitly selects an available different model; priority is not capability rank. Do not use implementation reviewers for research, design, root-cause diagnosis or plan criticism, and do not fan out every role merely because it exists. Re-request only a review affected by a substantive change or newly relevant evidence. Review never authorizes Git writes.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subagent-driven-development
|
|
3
|
+
description: Use when executing an approved plan has independent bounded work that benefits from DSH subagent delegation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Subagent-Driven Development
|
|
7
|
+
|
|
8
|
+
Delegate only when the actual DSH tool for that logical role is callable and its provider advertises the necessary persona/tool-filter/depth capabilities. A child joins its parent's preset; the role-specific tool must supply its own persona and tool filter. Preset files alone do not prove availability.
|
|
9
|
+
|
|
10
|
+
- Direct work is valid when delegation adds no value. Otherwise give a worker approved outcome, exclusive file ownership, constraints, acceptance evidence and no-Git-write boundary.
|
|
11
|
+
- Keep dependent or overlapping work sequential; independent work may proceed together when shared state and tool limits permit.
|
|
12
|
+
- Preserve the host's stricter depth, cancellation, permissions and model availability. Never infer a child task ID or retry authority from prose.
|
|
13
|
+
- Inspect actual changes and evidence on return; integrate and run proportionate verification. Request review only for a concrete risk or explicit requirement, not after every task by default.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: writing-plans
|
|
3
|
+
description: Use for complex behavior work or a migration whose dependencies and risks require durable coordination before editing code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Writing Plans
|
|
7
|
+
|
|
8
|
+
Write an outcome-oriented plan that enables a capable implementer to act without rediscovering material decisions.
|
|
9
|
+
|
|
10
|
+
- State approved goal, desired end state, scope exclusions and useful acceptance evidence.
|
|
11
|
+
- Describe current state, interfaces, dependencies, ownership boundaries, ordering, risks and safeguards. Group independent outcomes into waves; include paths and commands when they prevent ambiguity.
|
|
12
|
+
- Complex business or behavior implementation defaults to planner → plan-critic → implementation. A bounded, simple low-risk change may skip; having multiple steps alone does not force a plan.
|
|
13
|
+
- Give the critic real plan and evidence. Address substantive blockers; do not require receipt hashes, fixed revision rounds or repeated review after editorial changes.
|
|
14
|
+
- Planning does not authorize Git writes or broaden permissions. Escalate decisions changing scope, safety/data, public APIs or irreversible actions.
|