@aegis-scan/skills 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.
Files changed (69) hide show
  1. package/ATTRIBUTION.md +75 -0
  2. package/CHANGELOG.md +129 -0
  3. package/LICENSE +21 -0
  4. package/README.md +123 -0
  5. package/dist/bin.d.ts +3 -0
  6. package/dist/bin.d.ts.map +1 -0
  7. package/dist/bin.js +122 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/commands/info.d.ts +5 -0
  10. package/dist/commands/info.d.ts.map +1 -0
  11. package/dist/commands/info.js +75 -0
  12. package/dist/commands/info.js.map +1 -0
  13. package/dist/commands/install.d.ts +7 -0
  14. package/dist/commands/install.d.ts.map +1 -0
  15. package/dist/commands/install.js +87 -0
  16. package/dist/commands/install.js.map +1 -0
  17. package/dist/commands/list.d.ts +7 -0
  18. package/dist/commands/list.d.ts.map +1 -0
  19. package/dist/commands/list.js +82 -0
  20. package/dist/commands/list.js.map +1 -0
  21. package/dist/index.d.ts +13 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +13 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/skills-loader.d.ts +23 -0
  26. package/dist/skills-loader.d.ts.map +1 -0
  27. package/dist/skills-loader.js +213 -0
  28. package/dist/skills-loader.js.map +1 -0
  29. package/package.json +63 -0
  30. package/skills/defensive/README.md +9 -0
  31. package/skills/mitre-mapped/README.md +10 -0
  32. package/skills/offensive/snailsploit-fork/advanced-redteam/SKILL.md +148 -0
  33. package/skills/offensive/snailsploit-fork/ai-security/SKILL.md +592 -0
  34. package/skills/offensive/snailsploit-fork/basic-exploitation/SKILL.md +10783 -0
  35. package/skills/offensive/snailsploit-fork/bug-identification/SKILL.md +1256 -0
  36. package/skills/offensive/snailsploit-fork/crash-analysis/SKILL.md +12466 -0
  37. package/skills/offensive/snailsploit-fork/deserialization/SKILL.md +185 -0
  38. package/skills/offensive/snailsploit-fork/edr-evasion/SKILL.md +1806 -0
  39. package/skills/offensive/snailsploit-fork/exploit-dev-course/SKILL.md +428 -0
  40. package/skills/offensive/snailsploit-fork/exploit-development/SKILL.md +699 -0
  41. package/skills/offensive/snailsploit-fork/fast-checking/SKILL.md +487 -0
  42. package/skills/offensive/snailsploit-fork/file-upload/SKILL.md +822 -0
  43. package/skills/offensive/snailsploit-fork/fuzzing/SKILL.md +340 -0
  44. package/skills/offensive/snailsploit-fork/fuzzing-course/SKILL.md +2105 -0
  45. package/skills/offensive/snailsploit-fork/graphql/SKILL.md +209 -0
  46. package/skills/offensive/snailsploit-fork/idor/SKILL.md +608 -0
  47. package/skills/offensive/snailsploit-fork/initial-access/SKILL.md +1528 -0
  48. package/skills/offensive/snailsploit-fork/jwt/SKILL.md +276 -0
  49. package/skills/offensive/snailsploit-fork/keylogger-arch/SKILL.md +197 -0
  50. package/skills/offensive/snailsploit-fork/mitigations/SKILL.md +1351 -0
  51. package/skills/offensive/snailsploit-fork/oauth/SKILL.md +366 -0
  52. package/skills/offensive/snailsploit-fork/open-redirect/SKILL.md +487 -0
  53. package/skills/offensive/snailsploit-fork/osint/SKILL.md +399 -0
  54. package/skills/offensive/snailsploit-fork/osint-methodology/SKILL.md +434 -0
  55. package/skills/offensive/snailsploit-fork/parameter-pollution/SKILL.md +595 -0
  56. package/skills/offensive/snailsploit-fork/race-condition/SKILL.md +881 -0
  57. package/skills/offensive/snailsploit-fork/rce/SKILL.md +1069 -0
  58. package/skills/offensive/snailsploit-fork/request-smuggling/SKILL.md +773 -0
  59. package/skills/offensive/snailsploit-fork/shellcode/SKILL.md +477 -0
  60. package/skills/offensive/snailsploit-fork/sqli/SKILL.md +372 -0
  61. package/skills/offensive/snailsploit-fork/ssrf/SKILL.md +830 -0
  62. package/skills/offensive/snailsploit-fork/ssti/SKILL.md +349 -0
  63. package/skills/offensive/snailsploit-fork/vuln-classes/SKILL.md +1229 -0
  64. package/skills/offensive/snailsploit-fork/waf-bypass/SKILL.md +820 -0
  65. package/skills/offensive/snailsploit-fork/windows-boundaries/SKILL.md +15153 -0
  66. package/skills/offensive/snailsploit-fork/windows-mitigations/SKILL.md +14546 -0
  67. package/skills/offensive/snailsploit-fork/xss/SKILL.md +784 -0
  68. package/skills/offensive/snailsploit-fork/xxe/SKILL.md +996 -0
  69. package/skills/ops/README.md +6 -0
@@ -0,0 +1,1256 @@
1
+ <!-- aegis-local: forked 2026-04-23 from SnailSploit/Claude-Red@c74d53e2938b59f111572e0819265a1e73029393; attribution preserved, see ATTRIBUTION.md -->
2
+
3
+ # SKILL: Bug Identification
4
+
5
+ ## Metadata
6
+ - **Skill Name**: bug-identification
7
+ - **Folder**: offensive-bug-identification
8
+ - **Source**: https://github.com/SnailSploit/offensive-checklist/blob/main/bug-identification.md
9
+
10
+ ## Description
11
+ Systematic bug identification methodology: source code review patterns, black-box testing strategies, taint analysis, dangerous function hunting, data flow tracing, and automated scanning setup. Use for code audits, bug bounty triage, or building vulnerability identification pipelines.
12
+
13
+ ## Trigger Phrases
14
+ Use this skill when the conversation involves any of:
15
+ `bug identification, code review, taint analysis, dangerous functions, data flow, source audit, black box, vulnerability identification, static analysis, code audit, bug hunting`
16
+
17
+ ## Instructions for Claude
18
+
19
+ When this skill is active:
20
+ 1. Load and apply the full methodology below as your operational checklist
21
+ 2. Follow steps in order unless the user specifies otherwise
22
+ 3. For each technique, consider applicability to the current target/context
23
+ 4. Track which checklist items have been completed
24
+ 5. Suggest next steps based on findings
25
+
26
+ ---
27
+
28
+ ## Full Methodology
29
+
30
+ # Bug Identification
31
+
32
+ ## Overview
33
+
34
+ Bug identification is the process of discovering potential vulnerabilities in software through various techniques including static analysis, dynamic analysis, and fuzzing. This document outlines methodologies and tools for effective vulnerability research.
35
+
36
+ For practical exploit development, see [Exploit Development](/exploit/development.md).
37
+
38
+ ```mermaid
39
+ flowchart TD
40
+ BugId["Bug Identification"]
41
+
42
+ %% Main Methods
43
+ Static["Static Analysis"]
44
+ Dynamic["Dynamic Analysis"]
45
+ Fuzzing["Fuzzing"]
46
+ AI["AI-Assisted"]
47
+
48
+ %% Static Analysis Methods
49
+ CodeReview["Manual Code Review"]
50
+ RevEng["Reverse Engineering"]
51
+ PatchDiff["Patch Diffing"]
52
+ StaticTools["Static Analysis Tools"]
53
+ SBOM["Supply Chain Analysis"]
54
+
55
+ %% Dynamic Analysis Methods
56
+ DebugTrace["Debugging/Tracing"]
57
+ DBI["Dynamic Binary Instrumentation"]
58
+ Taint["Taint Analysis"]
59
+ SymExec["Symbolic Execution"]
60
+ Snapshot["Snapshot Analysis"]
61
+
62
+ %% Fuzzing Methods
63
+ DumbFuzz["Dumb Fuzzing"]
64
+ SmartFuzz["Smart Fuzzing"]
65
+ EvoFuzz["Evolutionary Fuzzing"]
66
+ LLMFuzz["LLM-Guided Fuzzing"]
67
+
68
+ %% AI Methods
69
+ LLMTriage["LLM Crash Triage"]
70
+ MLPattern["ML Pattern Recognition"]
71
+ AutoVariant["Automated Variant Analysis"]
72
+
73
+ %% Connections
74
+ BugId --> Static
75
+ BugId --> Dynamic
76
+ BugId --> Fuzzing
77
+ BugId --> AI
78
+
79
+ Static --> CodeReview
80
+ Static --> RevEng
81
+ Static --> PatchDiff
82
+ Static --> StaticTools
83
+ Static --> SBOM
84
+
85
+ Dynamic --> DebugTrace
86
+ Dynamic --> DBI
87
+ Dynamic --> Taint
88
+ Dynamic --> SymExec
89
+ Dynamic --> Snapshot
90
+
91
+ Fuzzing --> DumbFuzz
92
+ Fuzzing --> SmartFuzz
93
+ Fuzzing --> EvoFuzz
94
+ Fuzzing --> LLMFuzz
95
+
96
+ AI --> LLMTriage
97
+ AI --> MLPattern
98
+ AI --> AutoVariant
99
+
100
+ %% Combinations
101
+ Taint -.-> Fuzzing
102
+ SymExec -.-> Fuzzing
103
+ RevEng -.-> Fuzzing
104
+ AI -.-> Fuzzing
105
+ AI -.-> Static
106
+
107
+ class BugId primary
108
+ ```
109
+
110
+ ## Vulnerability Research Methodology
111
+
112
+ ### Phase 1: Reconnaissance
113
+
114
+ - **Target Enumeration:** Identify version, dependencies, configuration
115
+ - **Attack Surface Mapping:** List all input vectors, APIs, protocols
116
+ - **Documentation Review:** RFCs, specifications, developer docs
117
+ - **Prior Art Analysis:** CVE database, exploit-db, bug trackers
118
+
119
+ ### Phase 2: Static Analysis
120
+
121
+ - **Source Review:** If available, focus on parsing/validation code
122
+ - **Binary Analysis:** Reverse engineering with Ghidra/IDA
123
+ - **Patch Diffing:** Compare vulnerable vs patched versions
124
+ - **SBOM Analysis:** Check third-party component vulnerabilities
125
+
126
+ ### Phase 3: Dynamic Analysis
127
+
128
+ - **Behavioral Analysis:** Monitor syscalls, network, file I/O
129
+ - **Debugging:** Trace execution paths with controlled input
130
+ - **Instrumentation:** Coverage-guided exploration
131
+ - **Taint Analysis:** Track input propagation
132
+
133
+ ### Phase 4: Fuzzing
134
+
135
+ - **Corpus Generation:** Create valid seed inputs
136
+ - **Harness Development:** Isolate target functionality
137
+ - **Coverage Monitoring:** Identify untested code paths
138
+ - **Crash Triage:** Classify and prioritize findings
139
+
140
+ ### Phase 5: Exploitation
141
+
142
+ - **Primitive Development:** Convert bug to reliable primitives
143
+ - **Mitigation Bypass:** Defeat ASLR, DEP, CFG, etc.
144
+ - **Payload Development:** Create working exploit
145
+ - **Weaponization:** Package for real-world use (if authorized)
146
+
147
+ ## Attack Surface Identification
148
+
149
+ Before diving into specific bug hunting techniques, it's essential to understand where to look for vulnerabilities.
150
+
151
+ ### Windows User Mode
152
+
153
+ - Shared Memory
154
+ - RPC
155
+ - Named Pipes
156
+ - File & Network IO
157
+ - Windows Messages
158
+ - For authentication-related vulnerabilities, see [Windows Auth](/exploit/windows-auth.md)
159
+
160
+ ### Kernel
161
+
162
+ - _Device Drivers_
163
+ - Many third-party software with drivers to target
164
+ - Can accept arbitrary user input via the `IOCTL` interface
165
+ - Also performs actions when we `open,close` handles to it
166
+ - _OS_
167
+ - Drivers that handle hardware and user input
168
+ - Intercepts/transitions from user to kernel
169
+ - _Modern Linux interfaces (hotspots)_
170
+ - **io_uring**: SQE size/offset confusions, submission/completion race windows, kernel copy‑sizes derived from user buffers
171
+ - **userfaultfd**: cross‑thread write‑what‑where and TOCTOU primitives during fault handling
172
+ - **seccomp user‑notifier**: confused‑deputy patterns in broker processes; notifier time‑of‑check vs time‑of‑use gaps
173
+ - _Hyper-V & VTL Interfaces_ – On many modern Windows 11 systems (especially 24H2 on supported hardware), Virtualization‑Based Security and VTL1 are enabled or easily enabled by policy. Treat the hypervisor surface (e.g., `hvix64.exe` and synthetic MSRs) as a common kernel target, and verify VBS/HVCI status on the host before assuming defaults.
174
+
175
+ ### Drivers
176
+
177
+ - _DriverEntry_: registers for any callbacks, setup structure, etc
178
+ - _I/O Handlers_: handlers that get called when a process attempts to `open,close,etc` the driver, `IOCTL` allows driver functionality to be called from user processes
179
+ - Practical triage example (CVE‑2025‑8061):
180
+ - IOCTL handlers that accept a fixed‑size struct and pass a user‑controlled `PHYSICAL_ADDRESS` directly to `MmMapIoSpace`
181
+ - then memcpy out/in mapped memory (sometimes via wrappers that swap src/dst) indicate physical memory read/write primitives.
182
+ - Similarly, unguarded MSR read/write paths yield `RDMSR/WRMSR` primitives.
183
+ - See the Lenovo `LnvMSRIO.sys` case study in [windows-kernel.md](/exploit/windows-kernel.md)
184
+
185
+ ### eBPF & XDP
186
+
187
+ - **BPF helpers and verifier**: pointer leaks, verifier bypass, JIT bugs
188
+ - **User‑entry vectors**: `bpf()` syscall, privileged pods in Kubernetes, Cilium datapath
189
+ - **Tooling**: `bpftool`, verifier logs, `bpftrace` scripts for quick triage
190
+ - **CO‑RE skeletons** (`bpftool gen skeleton`) simplify packaging portable tracing probes.
191
+ - **BPF LSM** hooks allow low‑overhead coverage feedback on security‑critical kernel paths; export events with `trace_pipe`.
192
+
193
+ ### Container & Micro‑VM Surface
194
+
195
+ - Namespace/cgroup escapes, device‑mapper abuse, races in snapshotting backends (e.g., overlayfs)
196
+ - Micro‑VM hypercalls in Firecracker, CloudHypervisor, Kata Containers
197
+ - For detailed container exploitation techniques, see [Container](/exploit/container.md)
198
+
199
+ ### Cloud‑Native & IAM Bugs
200
+
201
+ - Misconfigured IAM policies, privilege‑escalating API actions (AWS `sts:AssumeRole`, Azure Golden SAML)
202
+ - SSRF paths into metadata services (`169.254.169.254`, IMDSv2 bypass techniques)
203
+ - Race conditions in managed control‑plane components (Kubernetes API server, AWS Lambda workers)
204
+ - Kubernetes Attack Vectors: look at [kubernetes](/pentest/kubernetes.md) for a deeper checklist
205
+ - **Serverless Vulnerabilities:**
206
+ - Lambda layer poisoning
207
+ - Function URL authentication bypass
208
+ - Event injection through SQS/SNS/EventBridge
209
+ - Cold start race conditions
210
+
211
+ ### Network / Transport Protocol Parsers
212
+
213
+ - **QUIC / HTTP/3**: coalesced frames, reorder/timing corner cases; verify against RFC 9000 (QUIC) and RFC 9114 (HTTP/3)
214
+ - **HTTP/2**: stream state machine desync; flow‑control integer edge cases (RFC 7540)
215
+ - **gRPC / Protobuf**: length truncation across language FFI, map/list coercion; see gRPC framing and protobuf varint rules
216
+ - **GraphQL**: input coercion and resolver recursion limits; check GraphQL spec for type coercion semantics
217
+
218
+ ### WebAssembly Runtimes
219
+
220
+ - WASM JIT optimization bugs in V8, Wasmtime, Wasmer
221
+ - WASI sandbox escapes through host‑call interfaces
222
+ - Typed‑Func‑Refs, GC, Tail‑calls, Memory64 expand type/bounds confusion surface. See the WebAssembly proposals status page for current rollout and engine adoption.
223
+ - **Checklist**:
224
+ - validate table element types/import signatures/hostcall marshalling
225
+ - fuzz mixed 32/64-bit memories.
226
+ - _Fuzzing tip_: compile native libs to WASM for fast, deterministic mutation cycles
227
+
228
+ ### Browser / JS Engine Exploitation
229
+
230
+ #### Modern V8 Architecture (2024-2025)
231
+
232
+ V8 now uses a multi-tier JIT pipeline with distinct exploitation characteristics:
233
+
234
+ - **Ignition (Interpreter):** Bytecode interpreter; rarely targeted directly
235
+ - **Maglev (Mid-tier JIT):** Introduced Chrome 115+; simpler IR than TurboFan
236
+ - **TurboFan (Optimizing JIT):** Aggressive optimization; traditional exploitation target
237
+ - **Turboshaft:** New IR replacing TurboFan internals; different optimization patterns create new bug classes
238
+ - Type lattice changes affecting confusion bugs
239
+ - Maglev → Turboshaft transition paths expose state inconsistencies
240
+ - Node-based to block-based IR transition
241
+
242
+ #### V8 Maglev Exploitation
243
+
244
+ - Integer overflow in Maglev's fast-path arithmetic
245
+ - Corrupted HeapNumber backing store via Maglev bounds check bypass
246
+ - Map/ElementsKind confusion in polymorphic inline caches
247
+
248
+ #### WebAssembly JSPI (JavaScript Promise Integration)
249
+
250
+ - **Stack Heap Spray:** Suspended WASM stacks allocated on heap; predictable layout
251
+ - **Type Confusion:** `WebAssembly.Suspending` wrapper type mismatch
252
+ - **Info Leak:** Stack pointers exposed through Promise resolution chains
253
+ - **Sandbox Escape:** JSPI bridges JS/WASM boundary; bypass traditional WASM isolation
254
+
255
+ #### Spectre-BHB Browser Mitigations
256
+
257
+ - **Chrome 120+:** Site Isolation per-frame; shared array buffer restrictions
258
+ - **Firefox 122+:** Process-per-site with BHI fences in JIT trampolines
259
+ - **Safari 17.4+:** WebKit JIT speculation guards on type checks
260
+
261
+ #### Site Isolation Plus
262
+
263
+ - **Frame-level process isolation:** Each cross-origin frame in separate process
264
+ - **Cross-origin memory protection:** Hardware-backed memory isolation
265
+ - **New IPC attack surface:** Mojo interface exploitation required for escapes
266
+ - **Renderer → Browser requirements:** Need Mojo race or type confusion
267
+ - New Info-Leak Requirements:
268
+ - Traditional `SharedArrayBuffer + Atomics` timing attacks less reliable
269
+ - Need alternative side-channels: CSS timing, WebGL shader execution, AudioContext
270
+ - Cross-origin info leaks require chaining multiple primitives
271
+
272
+ #### Practical Browser Exploitation Workflow
273
+
274
+ 1. **Target Selection:**
275
+ - V8 Maglev for Chrome/Edge (faster development cycle = more bugs)
276
+ - JSC for Safari (less scrutiny than V8)
277
+ - SpiderMonkey for Firefox (IonMonkey/Warp still viable)
278
+
279
+ 2. **Primitive Development:**
280
+ - `addrof`: Leak object addresses (info leak)
281
+ - `fakeobj`: Craft fake object (type confusion)
282
+ - `arbread/arbwrite`: Arbitrary memory access
283
+ - `shellcode`: RWX page or WASM JIT abuse
284
+
285
+ 3. **Sandbox Escape:**
286
+ - Mojo IPC race conditions
287
+ - GPU process exploitation via WebGL
288
+ - Utility process TOCTOU (Chrome's new architecture)
289
+
290
+ 4. **Post-Exploitation:**
291
+ - Chrome: Target browser process via Mojo
292
+ - Safari: XPC service exploitation for sandbox escape
293
+ - Firefox: Target parent process via IPC
294
+
295
+ ### Firmware & Embedded
296
+
297
+ - UEFI DXE driver flaws, BMC web console auth bypass, ECU/CAN message injection
298
+ - BLE & Zigbee stack overflows, heap exploits in `btstack`, `lwIP`
299
+
300
+ ### macOS / Apple‑Silicon Kernel
301
+
302
+ - IOKit user‑client input validation, IOMFB allocator corner‑cases
303
+ - Hypervisor.framework fuzzing with `hv_fuzz`
304
+
305
+ ### Mobile Platforms (iOS/Android)
306
+
307
+ #### iOS 17+ Exploitation
308
+
309
+ - **PAC Bypass:** Pointer Authentication Code bypass via signing gadgets
310
+ - **PPL Bypass:** Page Protection Layer exploitation for kernel r/w
311
+ - **Secure Enclave:** SEP exploitation via malformed Mach messages
312
+ - **Neural Engine:** ANE kernel driver attack surface
313
+
314
+ #### Android 14+ Exploitation
315
+
316
+ - **MTE (Memory Tagging):** Probabilistic bypass with tag collisions
317
+ - **GKI (Generic Kernel Image):** Vendor hooks as attack surface
318
+ - **Scudo Hardening:** Heap exploitation with hardened allocator
319
+ - **Hardware Attestation:** Keymaster/StrongBox TEE attacks
320
+
321
+ #### Cross-Platform Mobile
322
+
323
+ - **Flutter:** Dart VM type confusion, FFI boundary issues
324
+ - **React Native:** JavaScript bridge serialization bugs
325
+ - **Unity:** IL2CPP memory corruption, native plugin vulnerabilities
326
+
327
+ ### Supply Chain Attack Surface
328
+
329
+ #### Package Manager Vulnerabilities
330
+
331
+ - **Dependency Confusion:** Internal vs public package name conflicts
332
+ - **Typosquatting:** Similar package names (numpy vs numpi)
333
+ - **Manifest Manipulation:** Lock file poisoning, version pinning bypass
334
+ - **Build-time Injection:** Malicious install scripts, post-install hooks
335
+
336
+ #### CI/CD Pipeline Analysis
337
+
338
+ - **GitHub Actions:** Workflow poisoning via PR from forked repos
339
+ - **Jenkins:** Groovy script injection, plugin vulnerabilities
340
+ - **Docker:** Build argument exploitation, base image substitution
341
+ - **Secrets Exposure:** Environment variables in build logs, artifact leakage
342
+
343
+ ### AI & LLM Application Security
344
+
345
+ - Prompt‑injection, sandbox boundary escapes, hidden‑channel data exfil
346
+ - See [AI Security](/pentest/ai.md) for a deeper checklist
347
+
348
+ ### Confidential‑Computing / TEE Surface
349
+
350
+ - **Intel TDX**: diff `tdx.ko` or `tdx_psci.c` between kernel LTS branches to spot new GPA→HPA validation checks.
351
+ - **AMD SEV‑SNP**: look for unchecked `VMGEXIT` leafs in PSP firmware; `sevtool --decode` helps locate IDA entry points.
352
+ - **Arm CCA / RMM**: analyze SMC handlers inside Realm Management Monitor (RMM) EL3 firmware.
353
+ - **Cloud offerings (Azure CCE, Google C3)**: focus on paravirtualised MMIO and attestation report flows exposed to guests.
354
+ - For TEE-specific exploitation, see [Secure Enclaves](/exploit/secure-enclaves.md)
355
+
356
+ ### GPU & vGPU Surface
357
+
358
+ - **HGX HMC (verify CVE/advisories)**: research indicates malformed NVLINK‑C2C packets can corrupt HMC register space; confirm against vendor advisories for the specific platform.
359
+ - **vGPU manager IOCTLs**: diff `nvidia‑vgpu‑mgr` monthly; watch `VGPU_PLUGIN_IOCTL_GET_STATE` and similar calls for unchecked buffers.
360
+ - **LeftoverLocals info‑leak**: contiguous VRAM allocations can leak data from prior tenants in multi‑tenant AI clusters.
361
+
362
+ ### Hardware Security Attack Surface
363
+
364
+ #### Side-Channel Analysis
365
+
366
+ - **Power Analysis:** DPA/SPA attacks on cryptographic operations
367
+ - **Electromagnetic (EM):** Near-field probing of processor emissions
368
+ - **Timing Attacks:** Cache timing, branch prediction analysis
369
+ - **Acoustic:** Key extraction via CPU sound emissions
370
+
371
+ #### Fault Injection
372
+
373
+ - **Voltage Glitching:** Brown-out attacks on secure boot
374
+ - **Clock Glitching:** Skip instruction execution
375
+ - **Laser Fault Injection (LFI):** Targeted bit flips
376
+ - **EM Pulse Injection:** Wider area fault induction
377
+
378
+ #### Hardware Implants & Supply Chain
379
+
380
+ - **PCB Modification:** Added components, trace rerouting
381
+ - **Firmware Backdoors:** UEFI/BMC persistent implants
382
+ - **Hardware Trojans:** Malicious logic in ICs
383
+ - **DMA Attacks:** PCIe, Thunderbolt, FireWire exploitation
384
+
385
+ ### EDR Driver Vulnerability Research
386
+
387
+ #### Common vulnerability types in EDR drivers
388
+
389
+ - Authorization bypass issues
390
+ - Memory corruption in IOCTL handlers
391
+ - Race conditions in driver communication
392
+ - Improper input validation
393
+ - For detailed EDR analysis techniques, see [EDR](/exploit/edr.md)
394
+
395
+ #### Research methodology
396
+
397
+ 1. Identify accessible driver interfaces
398
+ 2. Reverse engineer IOCTL/message handlers
399
+ 3. Analyze authorization mechanisms
400
+ 4. Test for input validation flaws
401
+ 5. Look for race conditions and memory corruption
402
+
403
+ #### Tools for driver analysis
404
+
405
+ - IDA Pro / Ghidra for reverse engineering
406
+ - WinDbg for dynamic analysis
407
+ - Process Monitor for behavior analysis
408
+ - Custom fuzzing tools for interface testing
409
+
410
+ #### Quick triage rubric (post‑crash)
411
+
412
+ - Buffer overflow vs UAF: check access type, allocation lifetime, and red‑zones (ASan/KASAN reports)
413
+ - Integer issues: trace size/length and allocation math; look for truncation/casts
414
+ - Logic bugs: unexpected state transitions without memory errors; validate auth/flags
415
+ - Info‑leaks: uninitialized reads, OOB reads, pointer/string formatters
416
+
417
+ #### Coverage‑first recon checklist
418
+
419
+ - Produce one baseline coverage run (e.g., `drcov`, Intel® PT, or Lighthouse import)
420
+ - Identify cold paths reachable from attacker inputs
421
+ - Seed corpus: include minimal valid examples that traverse target parsers
422
+ - Enable lightweight oracles (ASan/UBSan/KASAN) where feasible to maximize signal
423
+
424
+ ## Static Analysis Methods
425
+
426
+ Static analysis examines code without execution to identify potential vulnerabilities.
427
+
428
+ ### Manual Code Review
429
+
430
+ - Installing the target application and examining its structure
431
+ - Enumerating the ways to feed input to it
432
+ - Examine the file formats and network protocols that the application uses
433
+ - Locating logical vulnerabilities or memory corruptions
434
+ - For Windows-specific techniques, see [Windows Kernel](/exploit/windows-kernel.md)
435
+ - For Linux-specific techniques, see [Linux](/exploit/linux.md)
436
+
437
+ ### Patch Diffing
438
+
439
+ Patch diffing compares vulnerable and patched versions of binaries to identify security changes.
440
+
441
+ #### What is Patch Diffing
442
+
443
+ Patch diffing is a technique to identify changes across versions of binaries related to security patches. It compares a vulnerable version of a binary with a patched one to highlight the changes, helping to discover new, missing, and interesting functionality across versions.
444
+
445
+ ##### Benefits
446
+
447
+ - **Single Source of Truth**: Without a CVE blog post or sample POC, a patch diff can be the only source of information to determine changes and deduce the original issue.
448
+ - **Vulnerability Discovery**: While understanding the original issue, you may discover additional vulnerabilities in the troubled code area.
449
+ - **Skill Development**: Patch diffing provides focused practice in reverse engineering and helps build mental models for various vulnerability classes.
450
+
451
+ ##### Challenges
452
+
453
+ - **Asymmetry**: Small source code changes can drastically affect compiled binaries.
454
+ - **Finding Security-Related Changes**: Security patches often include other changes like new features, bug fixes, and performance improvements.
455
+ - **Minimizing Noise**:
456
+ - Diff the correct binaries to avoid analyzing unrelated updates
457
+ - Reduce the time delta between compared versions
458
+ - Use binary symbols when available to add precision to comparisons
459
+
460
+ #### Tools
461
+
462
+ - IDA Pro with plugins like DarunGrim and Diaphora
463
+ - BinDiff Works with analysis output from IDA or Ghidra
464
+ - [Ghidriff](https://github.com/clearbluejar/ghidriff): Ghidra binary diffing engine
465
+ - Radare2 (radiff2)
466
+ - Ghidra Version Tracking Tool
467
+ - Ghidra 11 built-in Partial Match Correlator
468
+
469
+ #### Patch Diffing Workflow
470
+
471
+ The process of patch diffing typically follows these steps:
472
+
473
+ 1. **Preparation**
474
+ - Create a diffing session
475
+ - Load binary versions (vulnerable and patched)
476
+ - Ensure binaries pass preconditions
477
+ - Run auto-analysis on both binaries
478
+
479
+ 2. **Evaluation**
480
+ - Run correlators to find similarities
481
+ - Generate associations between binaries
482
+ - Evaluate matches between functions
483
+ - Accept matching functions
484
+ - Analyze differences until sufficient understanding is reached
485
+
486
+ 3. **Function Analysis**
487
+ - **Identify new functions**: Functions in the patched binary with no match in the original
488
+ - **Identify deleted functions**: Functions in the original binary with no match in the patched version
489
+ - **Identify changed functions**: Functions that exist in both versions but have been modified
490
+ - Focus on functions with security relevance (often indicated by their names or based on CVE descriptions)
491
+
492
+ 4. **Interpreting Results**
493
+ - New functions often indicate added security checks or validation
494
+ - Changed functions may show modified logic for handling edge cases
495
+ - Correlate changes with public CVE information when available
496
+ - Remember that patches are not necessarily atomic - multiple issues may be fixed in one update
497
+
498
+ When using Ghidra's Version Tracking:
499
+
500
+ - Use "Show Only Unmatched Functions" filter to identify new or deleted functions
501
+ - Look for functions with a similarity score below 1.0 to find modified functions
502
+ - Examine the modified functions to understand what security checks were added
503
+
504
+ Starting with Ghidra 11 (December 2024) a built-in _Partial Match Correlator_ covers most PatchDiffCorrelator use-cases; install the plugin only if you need bulk-mnemonics scoring.
505
+
506
+ #### Case Study: 7‑Zip Symlink Path Traversal
507
+
508
+ - Target: 7‑Zip 24.09 (vulnerable) → 25.00 (fixed)
509
+ - File of interest: `CPP/7zip/UI/Common/ArchiveExtractCallback.cpp`
510
+ - High‑signal edits: absolute‑path detection and link‑path validation for WSL/Linux symlinks converted on Windows.
511
+
512
+ ##### Minimal security‑relevant diff (simplified):
513
+
514
+ ```cpp
515
+ -bool IsSafePath(const UString &path)
516
+ +static bool IsSafePath(const UString &path, bool isWSL)
517
+ {
518
+ CLinkLevelsInfo levelsInfo;
519
+ - levelsInfo.Parse(path);
520
+ + levelsInfo.Parse(path, isWSL);
521
+ return !levelsInfo.IsAbsolute
522
+ && levelsInfo.LowLevel >= 0
523
+ && levelsInfo.FinalLevel > 0;
524
+ }
525
+
526
+ +bool IsSafePath(const UString &path);
527
+ +bool IsSafePath(const UString &path)
528
+ +{
529
+ + return IsSafePath(path, false); // isWSL
530
+ +}
531
+
532
+ -void CLinkLevelsInfo::Parse(const UString &path)
533
+ +void CLinkLevelsInfo::Parse(const UString &path, bool isWSL)
534
+ {
535
+ - IsAbsolute = NName::IsAbsolutePath(path);
536
+ + IsAbsolute = isWSL ? IS_PATH_SEPAR(path[0]) : NName::IsAbsolutePath(path);
537
+ LowLevel = 0;
538
+ FinalLevel = 0;
539
+ }
540
+ ```
541
+
542
+ ##### Root cause (logic):
543
+
544
+ - Linux/WSL symlink data containing a Windows‑style path (e.g., `C:\...`) was treated as relative by the Linux absolute‑path check, setting `linkInfo.isRelative = true`.
545
+ - `SetFromLinkPath` prefixed the symlink’s zip‑internal directory when building `relatPath`, letting `IsSafePath(relatPath)` pass despite an absolute Windows target.
546
+ - A subsequent “dangerous link” guard checked `_item.IsDir`; non‑directory symlinks skipped the validation.
547
+ - Result: symlink creation to arbitrary absolute Windows paths; extracted files written into the link target.
548
+
549
+ ##### Practical triage checklist:
550
+
551
+ - Search this file for: `IsSafePath`, `CLinkLevelsInfo::Parse`, `SetFromLinkPath`, `CloseReparseAndFile`, `FillLinkData`, `CLinkInfo::Parse`, `_ntOptions.SymLinks_AllowDangerous`.
552
+ - Verify absolute‑path detection across OS semantics (Linux vs Windows) and that relative/absolute status cannot be desynced by mixed‑style paths.
553
+ - Ensure “dangerous link” checks run for both files and directories; avoid `_item.IsDir` short‑circuiting validation for file symlinks.
554
+ - Confirm `IsSafePath` evaluates the final target path after concatenations; normalize before validation.
555
+
556
+ ##### Quick repro (Windows, developer mode or elevated):
557
+
558
+ - Create zip structure:
559
+ - `data/link` → symlink to `C:\Users\<USER>\Desktop`
560
+ - `data/link\calc.exe` → payload file
561
+ - If `link` is extracted first, subsequent writes follow the symlink into the absolute target directory.
562
+
563
+ #### Apple Patch Diffing
564
+
565
+ - Identify a CVE of interest
566
+ - Download corresponding IPSW and update and N-1
567
+ - use [ipsw.me](https://ipsw.me/) to download those files
568
+ - convert the downloaded `.ipsw` to `.zip`
569
+ - Determine changes for update
570
+ - you can use [IPSW tool](https://github.com/blacktop/ipsw) to download and diff
571
+ - Map binaries to CVE
572
+ - Extract the related file(s)
573
+ - Diff the binaries
574
+ - In Ghidra set Decompiler Parameter ID to true
575
+ - Leverage [IDAObjectTypes](https://github.com/PoomSmart/IDAObjcTypes)
576
+ - Root cause the vulnerability
577
+
578
+ ```bash
579
+ # Downloading the correct IPSWs
580
+ ipsw download --device Macmini9,1 -V -b 23A344
581
+ ipsw download --device Macmini9,1 -V -b 23B74
582
+
583
+ # Comparing two different IPSWs
584
+ ipsw diff UniversalMac_14.0_23A344.ipsw UniversalMac_14.1_23B74.ipsw
585
+
586
+ # What is inside the DSC
587
+ ipsw extract -d IPSW
588
+
589
+ # Extracting files
590
+ ipsw extract -f -p file
591
+
592
+ # Extracting specific architecture file
593
+ ipsw macho lipo Contacts
594
+ ```
595
+
596
+ #### Windows 11 Patch Diffing
597
+
598
+ This checklist mirrors the Apple IPSW workflow but uses Microsoft tooling and build numbers.
599
+
600
+ 1. Identify the target update
601
+ - Open **Settings → Windows Update → Update history** or consult the Windows Release Health dashboard to note the **KB** and **OS build** numbers (e.g., _KB5037778 → build 22631.3525_).
602
+ - Record the previous build you want to diff against (e.g., _22631.3447_).
603
+
604
+ 2. Collect the binaries
605
+
606
+ ```bash
607
+ winbindex download tcpip.sys 10.0.22631.3447 10.0.22631.3525
608
+
609
+ mkdir pre,post
610
+ wget -Uri https://www.catalog.update.microsoft.com/Download.aspx?q=KB5037778 -OutFile kb.msu
611
+ expand -F:* .\kb.msu .\post
612
+ # repeat for the older KB into .\pre
613
+ # Download both *UUP* bundles, then run
614
+ uup_download_windows.cmd --extract
615
+ # and copy changed PE files to *pre* / *post*
616
+ ```
617
+
618
+ 3. Fetch matching symbols
619
+
620
+ ```powershell
621
+ # Requires Debugging Tools for Windows
622
+ foreach ($ver in '3447','3525') {
623
+ symchk /r .\$ver /s SRV*https://msdl.microsoft.com/download/symbols
624
+ }
625
+ ```
626
+
627
+ 4. Load in the disassembler
628
+ - Open _tcpip.sys_ from both **pre** and **post** folders in **IDA 8+** or **Ghidra 11**; ensure PDB symbols resolve.
629
+ - Save the IDA databases (e.g., `tcpip_3447.i64`, `tcpip_3525.i64`).
630
+
631
+ 5. Run the diff
632
+ - **BinDiff 7**: _Tools → BinDiff → Diff Database…_ and select the two IDBs to generate a `.BinDiff` report.
633
+ - **Ghidriff** (headless):
634
+ ```bash
635
+ ghidriff diff pre/tcpip.sys post/tcpip.sys -o tcpip.diff
636
+ ```
637
+
638
+ 6. Triage the results
639
+ - Sort by _Similarity %_ ascending; investigate anything below **95 %**.
640
+ - Focus on functions with names like `Validate`, `Parse`, `Copy`, `Check`, or protocol‑specific handlers (`IppReceiveEsp`, `Ipv6pFragmentReassemble`, etc.).
641
+ - Determine whether changes add bounds checks, size validations, or privilege checks.
642
+
643
+ 7. Validate in a lab VM
644
+ - Snapshot two Windows 11 VMs (build **3447** and **3525**).
645
+ - Attach WinDbg (kernel mode) using `bcdedit /dbgsettings net hostip:<IP> port:<PORT>`.
646
+ - Reproduce the issue against the **pre‑patch** VM; confirm no crash or breakpoint triggers in the **post‑patch** VM.
647
+
648
+ 8. Automate monthly
649
+ - Schedule a PowerShell script that, every Patch Tuesday (second Tuesday), downloads the latest Cumulative Update, extracts changed PE files, retrieves symbols, and launches a headless **Diaphora** diff.
650
+ - Email the generated HTML report to quickly spot new attack surface.
651
+
652
+ > [!TIP]
653
+ > For large modules like **ntoskrnl.exe**, diff only the `.text` section to save RAM:
654
+ > bindiff --primary ntoskrnl_pre.i64 --secondary ntoskrnl_post.i64 --section .text
655
+
656
+ #### Linux Kernel Patch Diffing
657
+
658
+ Patch‑diffing Linux kernels is often faster at the source level, but for binary‑only targets (vendor kernels, modules) function‑level diffing is still practical.
659
+
660
+ 1. Identify target builds
661
+ - Note distro and kernel build (e.g., Ubuntu `6.8.0-47-generic`, RHEL `5.14.0-503`).
662
+ - Capture both pre and post versions (package changelogs or CVE bulletins help).
663
+
664
+ 2. Fetch kernel images and debug info
665
+ - Ubuntu/Debian:
666
+ ```bash
667
+ # Discover versions
668
+ apt list -a linux-image-generic | cat
669
+ # Download image + modules dirs (repeat for both versions)
670
+ apt-get download linux-image-unsigned-<ver>-generic linux-modules-<ver>-generic
671
+ # Debug symbols via debuginfod (preferred to ddebs)
672
+ export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com https://debuginfod.debian.net"
673
+ ```
674
+ - Fedora/RHEL/CentOS:
675
+ ```bash
676
+ dnf download kernel-core-<ver> kernel-debuginfo-<ver>
677
+ rpm2cpio kernel-core-<ver>.rpm | cpio -idmv
678
+ rpm2cpio kernel-debuginfo-<ver>.rpm | cpio -idmv
679
+ ```
680
+
681
+ 3. Extract `vmlinux`
682
+
683
+ ```bash
684
+ # If only vmlinuz is present, use the upstream helper
685
+ /usr/src/linux-headers-<ver>/scripts/extract-vmlinux /boot/vmlinuz-<ver> > vmlinux-<ver>
686
+ # Or take vmlinux directly from debuginfo package tree
687
+ ```
688
+
689
+ 4. Identify changed modules quickly
690
+
691
+ ```bash
692
+ # Compare module trees (pre vs post)
693
+ rsync -rcn --delete /lib/modules/<pre>/ /lib/modules/<post>/ | grep -E "\.ko$" | sed 's/^/chg: /'
694
+ ```
695
+
696
+ 5. Function‑level binary diff
697
+ - Open `vmlinux-<pre>` and `vmlinux-<post>` in Ghidra 11/IDA 8 and run Diaphora/BinDiff/Ghidriff.
698
+ - For hot subsystems (e.g., `io_uring`, `net/ipv6`, `fs/overlayfs`), diff only the relevant `.ko` pairs to reduce noise.
699
+
700
+ 6. Source‑level triage (when sources are available)
701
+
702
+ ```bash
703
+ # Ubuntu example: unpack both source trees, then
704
+ git diff --no-index -- function.c.orig function.c.patched | less
705
+ # Or use diffoscope for enriched reports
706
+ ```
707
+
708
+ 7. Symbolization and crash mapping (cheat‑sheet)
709
+
710
+ ```bash
711
+ # Decode kernel oops backtraces to lines
712
+ ./scripts/decode_stacktrace.sh vmlinux /lib/modules/<ver>/build < dmesg.log
713
+ # Map PC to file:line quickly
714
+ addr2line -e vmlinux-<ver> 0xffffffff81234567
715
+ ```
716
+
717
+ > [!TIP]
718
+ > For modern distros built with Clang: KCFI and fine‑grained CFI thunks create many small stub changes; filter by real function body deltas to focus on security‑relevant logic.
719
+
720
+ > [!NOTE]
721
+ > Syzkaller routinely bisects kernel bugs; consult syzbot reports for reproducers and fix commits, then confirm your diff isolates the same region before deeper RE.
722
+
723
+ #### Kernel network parser identification heuristics (SMB2-inspired, broadly applicable)
724
+
725
+ ##### Cross-field invariants (length/offset/next)
726
+
727
+ - Always validate `(offset + length) <= remaining_buffer` and `<= total_buffer` using a widened type (e.g., `u64`) before arithmetic; reject on overflow with `check_add_overflow()`/`array_size()` helpers.
728
+ - For chained entries with a `next` field, assert: `next >= sizeof(entry_header)`, `next <= remaining_buffer`, and that pointer advancement actually makes progress. For entries carrying sub-lengths (e.g., `name_len`, `value_len`), assert `header + name_len + value_len <= next`.
729
+ - Do not cast to a struct until the full header is present and aligned; gate recasts with a prior `buf_len` check.
730
+
731
+ ##### Fixed-size buffers vs variable-length payloads
732
+
733
+ - Ban unbounded copies/crypto/decompression into fixed-size arrays. Require `len <= sizeof(array)` (or clamp with `min_t()` and bail) when writing into in-struct arrays.
734
+ - Crypto transforms are just writes with extra steps: if using ARC4/AES helpers that copy `len` bytes into a fixed buffer (e.g., session keys), bound `len` against a named maximum constant and prefer allocating a buffer sized from validated `len`.
735
+
736
+ ##### Type/width hazards
737
+
738
+ - Normalize parser math to a wide unsigned type before comparisons; avoid truncating `u32/u64` fields into `u16` for size checks. Favor `size_t/u64` for `offset+len` arithmetic, then compare to `buf_len` of the same width.
739
+
740
+ ##### Loop structure around `next`
741
+
742
+ - Pattern to flag: `e = (struct entry *)((char *)e + next);` without a preceding block that revalidates `buf_len` and the entry’s internal sub-lengths.
743
+ - Ensure a break condition on exhaustion and reject zero/negative progress values to avoid infinite loops or pointer stagnation.
744
+
745
+ ##### Allocation-size correlation
746
+
747
+ - When parser-controlled `len` influences a subsequent write into an object from a fixed SLUB cache (e.g., `kmalloc-512`), ensure the write length is bounded by the destination object field, not just the incoming length.
748
+
749
+ ##### Patch-diff signals to prioritize
750
+
751
+ - Newly added guards like `if (len > CONST) return -EINVAL;`, `if (buf_len < sizeof(struct foo)) return -EINVAL;`, or conversions to `min_t(size_t, len, sizeof(...))`.
752
+ - Insertions of `check_add_overflow(offset, len, &sum)` or `array_size(n, sz)` helpers in hot parse paths.
753
+
754
+ ##### Static query seeds (Semgrep/CodeQL), to tune per codebase
755
+
756
+ - Unbounded copies into struct fields:
757
+ ```yaml
758
+ rules:
759
+ - id: c-fixed-array-unbounded-copy
760
+ languages: [c, cpp]
761
+ patterns:
762
+ - pattern: memcpy($DST, $SRC, $LEN)
763
+ - pattern-inside: |
764
+ struct $S { ... char $BUF[$N]; ... };
765
+ ...
766
+ $DST = &...->$BUF
767
+ - pattern-not: memcpy($DST, $SRC, MIN($LEN, sizeof(*$DST)))
768
+ message: Unbounded copy into fixed-size struct field
769
+ severity: WARNING
770
+ ```
771
+ - Dangerous `next`-driven pointer arithmetic without bounds checks:
772
+ ```yaml
773
+ - id: c-parser-next-missing-bounds
774
+ languages: [c, cpp]
775
+ pattern: |
776
+ $E = (struct $T *)((char *)$E + $NEXT);
777
+ message: Parser advances by user-controlled 'next' without prior buf_len/sizeof checks
778
+ severity: WARNING
779
+ ```
780
+ - Crypto/decompression writes to fixed arrays (seed with function names in your tree, e.g., `*_crypt`, `*_decrypt`, `decompress_*`).
781
+
782
+ ##### Dynamic confirmation (cheap)
783
+
784
+ - Grammar fuzz small invariants: send `next < header`, `next > remaining`, `name_len + value_len > next`, and `len > MAX_CONST` variants; expect `-EINVAL`/reject. If not, investigate.
785
+ - Use TUN/TAP + KCOV to drive packet/SMB request paths; enable KASAN/KMSAN to surface overflows/leaks early.
786
+
787
+ ##### Reference (motivating example)
788
+
789
+ - Lessons distilled from a 2025 ksmbd remote chain writeup combining a fixed-buffer overflow in NTLM auth with an EA `next` validation issue — see Will’s Root: Eternal‑Tux: KSMBD 0‑Click RCE (`https://www.willsroot.io/2025/09/ksmbd-0-click.html`).
790
+
791
+ #### Case Study: EvilESP Vulnerability (CVE-2022-34718)
792
+
793
+ This case study demonstrates real-world patch diffing to identify a Windows TCP/IP RCE vulnerability.
794
+
795
+ ##### Vulnerability Overview
796
+
797
+ - CVE-2022-34718: Critical RCE in `tcpip.sys` discovered in September 2022
798
+ - An unauthenticated attacker could send specially crafted IPv6 packets to Windows nodes with IPsec enabled
799
+ - Affects the handling of ESP (Encapsulating Security Payload) packets in IPv6 fragmentation
800
+
801
+ ##### Patch Diffing Process
802
+
803
+ 1. **Binary Acquisition**
804
+ - Used Winbindex to obtain sequential versions of `tcpip.sys` (pre-patch and post-patch)
805
+ - Loaded both files in Ghidra with PDB symbols
806
+
807
+ 2. **Diff Analysis**
808
+ - Used BinDiff to compare the binaries
809
+ - Identified only two functions with less than 100% similarity: `IppReceiveEsp` and `Ipv6pReassembleDatagram`
810
+
811
+ 3. **Code Analysis**
812
+ - **Ipv6pReassembleDatagram**: Added bounds check comparing `nextheader_offset` against the header buffer length
813
+ - **IppReceiveEsp**: Added validation for the Next Header field of ESP packets
814
+
815
+ 4. **Root Cause Identification**
816
+ - Found an out-of-bounds 1-byte write vulnerability
817
+ - ESP Next Header field is located after the encrypted payload data
818
+ - A malicious packet could cause `nextheader_offset` to exceed the allocated buffer size
819
+
820
+ _(Update: Server 2022 build 20349.2300, May 2024, hardened this code path; the original PoC needs a 2-byte pad tweak to reproduce the crash.)_
821
+
822
+ ##### Exploitation
823
+
824
+ - Required setting up IPsec security association on the victim
825
+ - Created fragmented IPv6 packets encapsulated in ESP
826
+ - Controlled the offset of the out-of-bounds write through payload and padding size
827
+ - Value written is controllable via the Next Header field
828
+ - Limited to writing to addresses that are 4n-1 aligned (where n is an integer)
829
+ - Initially achieved DoS with potential for RCE through further exploitation
830
+
831
+ ##### Lessons Learned
832
+
833
+ - Binary patch diffing effectively identified the vulnerability location and nature
834
+ - Understanding protocol specifications (ESP and IPv6 fragmentation) was critical
835
+ - Simple buffer checks are still overlooked in complex networking code
836
+ - Even limited primitives (single byte overwrite at constrained offsets) can be dangerous
837
+ - For modern exploitation techniques, see [Modern Samples](/exploit/modern-samples.md)
838
+ - For mitigation bypass techniques, see [Modern Mitigations](/exploit/modern-mitigations.md)
839
+
840
+ When applying patch diffing to networking protocols:
841
+
842
+ 1. Understand the protocol specifications thoroughly
843
+ 2. Look for missing bounds checks in data processing
844
+ 3. Pay attention to buffer size calculations
845
+ 4. Check for proper validation of protocol field values and locations
846
+ 5. Consider evasion techniques for exploit deployment - see [EDR](/exploit/edr.md)
847
+ 6. Specs: ESP (RFC 4303) and IPv6 (RFC 8200) are essential references when reasoning about header placement and bounds
848
+
849
+ #### Semi-Automatic Patch Diffing
850
+
851
+ - Use [WinbIndex](https://winbindex.m417z.com/) to download the changed binary and then use [BinDiff](https://www.zynamics.com/bindiff.html) or [Ghidriff](https://github.com/clearbluejar/ghidriff) to actually see the diff itself
852
+ - You can also use [Diaphora](https://github.com/joxeankoret/diaphora) instead of BinDiff
853
+
854
+ #### Manual Patch Diffing
855
+
856
+ - Microsoft releases patches on the second Tuesday of each month
857
+ - For Windows you can go to [update catalog](https://www.catalog.update.microsoft.com/Search.aspx) and search for the product version (for example `2022-10 x64 "Windows 10" 22H2`)
858
+ - Try to look for smaller updates
859
+
860
+ ```shell
861
+ mkdir 2022-09
862
+ mv *.msu 2022-09
863
+ cd 2022-09
864
+ mkdir extract
865
+ mkdir patch
866
+ expand -F:* .\*.msu .\extract
867
+ expand -F:* .\extract\<largest>.cab .\patch
868
+ expand -F:* .\patch\<largest>.cab .\patch
869
+ expand -F:* .\patch\Cab_* .\patch\
870
+ ```
871
+
872
+ You can use [Patch Extract](https://gist.github.com/abzcoding/f6191c3aa9ca6d019f360b429d6b510f) instead
873
+
874
+ ```shell
875
+ gci -Recurse c:\windows\WinSxS\ -Filter ntdll.dll
876
+ # copy the biggest file somewhere
877
+ .\delta_patch.py -i .\NTDLL\ntdll.dll -o ntdll.2020-10.dll .\NTDLL\r\ntdll.dll .\2020-10\x64\ntdll_<stuff>\f\ntdll.dll
878
+ .\delta_patch.py -i .\NTDLL\ntdll.dll -o ntdll.2020-11.dll .\NTDLL\r\ntdll.dll .\2020-11\x64\ntdll_<stuff>\f\ntdll.dll
879
+ ```
880
+
881
+ Open unpatched version in IDA as the primary and the second, after that use BinDiff add-on to find the differences between them
882
+ then right click on a different matched function and see the visual diff in bin diff
883
+ also you can uncheck proximity browsing to see the entire function
884
+ look at red blocks and then yellow blocks
885
+
886
+ With patch clean script you can only see the actual changed files
887
+
888
+ ### Static Analysis Tools
889
+
890
+ #### IDA Pro and Rust Tools for Vulnerability Research
891
+
892
+ - [rhabdomancer](https://github.com/0xdea/rhabdomancer): IDA Pro headless plugin that locates calls to potentially insecure API functions in binary files
893
+ - Helps auditors backtrace from candidate points to find pathways allowing access from untrusted input
894
+ - Generates JSON/SARIF reports containing vulnerable function calls and their details
895
+ - Written in Rust using IDA Pro 9 idalib and Binarly's idalib Rust bindings
896
+
897
+ - [haruspex](https://github.com/0xdea/haruspex): IDA Pro headless plugin that extracts pseudo-code generated by IDA Pro's decompiler
898
+ - Exports pseudo-code in a format suitable for IDEs or static analysis tools like Semgrep/weggli
899
+ - Creates individual files for each function with their pseudo-code
900
+ - Can be used as a library by third-party crates
901
+
902
+ - [augur](https://github.com/0xdea/augur): IDA Pro headless plugin that extracts strings and related pseudo-code from binary files
903
+ - Stores pseudo-code of functions that reference strings in an organized directory tree
904
+ - Helps trace how strings are used within the application
905
+ - Complements other reverse engineering tools
906
+
907
+ #### Modern Static Analysis Tools
908
+
909
+ - **Semgrep Pro** – Cloud-augmented SAST with custom rule sharing, LLM-assisted rule writing
910
+ - **CodeQL** – GitHub's semantic code analysis, excellent for variant analysis
911
+ - **Weggli** – Fast semantic search for C/C++ (better than grep for code patterns)
912
+ - **Joern** – Code property graph analysis for vulnerability discovery
913
+ - **Ghidra 11.2+** – Built-in ML-powered function signature recognition
914
+ - **Binary Ninja 4.0** – Cloud collaboration, improved HLIL decompilation
915
+ - **Cutter** – Rizin GUI with built-in decompiler integration
916
+
917
+ #### Deprecated Tools (Avoid)
918
+
919
+ - **Intel Pin** → Use DynamoRIO or Frida (Pin is sustain-only mode)
920
+ - **WinAFL** → Use AFL++ 4.x (integrated Windows support)
921
+ - **Old BinDiff** → Use BinDiff 8 or Ghidriff
922
+
923
+ For more details about these tools: [Streamlining vulnerability research with IDA Pro and Rust](https://security.humanativaspa.it/streamlining-vulnerability-research-with-ida-pro-and-rust/)
924
+
925
+ ## Dynamic Analysis Methods
926
+
927
+ Dynamic analysis examines code during execution to identify vulnerabilities in real-time operation.
928
+
929
+ ### Hybrid Reverse Engineering (dynamic)
930
+
931
+ Reverse engineering involves analyzing an application while it runs to understand its behavior.
932
+
933
+ #### Network Protocol Analysis Example
934
+
935
+ - Identify ports used by a program
936
+ - Use WinDbg to debug it
937
+ - Set a breakpoint on `bp wsock32!recv`
938
+ - Write a python script to send data to that port
939
+ - After your breakpoint hits, continue execution using `pt` and check `rax` for result and `dd rsp L5` for input buffer
940
+ - `lm m <exe_name>` to identify its location on the disk
941
+ - Open that executable with IDA and rebase module
942
+ - Use the information printed by WinDbg `k` command to find the location you need to investigate
943
+ - Set a hardware breakpoint on your input buffer, only check functions that touches it
944
+ - Dump the callstack when your breakpoint got hit
945
+ - Try to identify the correct packet structure
946
+ - Then try to send proper malformed packets to crash it
947
+
948
+ #### Hypervisor Debugging and Analysis
949
+
950
+ - Debugging Windows Hypervisor (Hyper-V) requires specialized setup and knowledge
951
+ - Setup requirements:
952
+ - Host: Windows 10/11 with WinDbg
953
+ - Guest: Windows VM with Virtualization-based security (VBS) enabled
954
+ - Configure debugging with `bcdedit /hypervisorsettings` commands
955
+
956
+ - Analyzing Hypervisor components:
957
+ - Target `hvix64.exe` (Intel processor hypervisor core)
958
+ - Use bindiff with `winload.efi` and older versions of `hvloader.dll` for insight
959
+ - Leverage Hypervisor Top Level Functional Specification (TLFS) documentation
960
+
961
+ - Inspecting Secure Kernel (SK) Calls:
962
+ - Monitor VTL calls (transitions from VTL0 to VTL1)
963
+ - Use conditional breakpoints on `nt!VslpEnterIumSecureMode`
964
+ - Examine secure service call numbers (SSCN)
965
+ - Use tools like hvext to translate guest virtual addresses
966
+
967
+ - Memory access techniques:
968
+ - Translate Guest Virtual Address (GVA) to Guest Physical Address (GPA)
969
+ - Translate GPA to Host Physical Address (HPA) when needed
970
+ - Understand Second Level Address Translation mechanisms
971
+
972
+ - For mitigation techniques, see [Mitigation](/exploit/mitigation.md) or [Modern Mitigations](/exploit/modern-mitigations.md)
973
+
974
+ ### Binary Instrumentation
975
+
976
+ Binary instrumentation is a prerequisite for advanced dynamic analysis methods.
977
+
978
+ - [Intel Pin](https://www.intel.com/content/www/us/en/developer/articles/tool/pin-a-dynamic-binary-instrumentation-tool.html): is a dynamic binary instrumentation framework
979
+ - It enables you to write modules that execute some program and insert code into it at execution time to track things
980
+ - Can easily hook any function in the program and collect runtime data
981
+ - Can be combined with Ghidra/IDA to provide more information
982
+ > [!NOTE]
983
+ > Intel Pin is now in sustain‑only mode — no new ISA extensions will be added. Prefer **DynamoRIO** or **Frida‑Stalker** for forward‑looking projects.
984
+ - [DynamoRIO](https://github.com/DynamoRIO/dynamorio): more powerful and faster alternative to `Intel Pin`, but harder to setup
985
+ - `Frida`: Slower, better for mobile applications
986
+
987
+ ### Dynamic Taint Analysis
988
+
989
+ - Technique to determine how data flow through a given program and influence its state
990
+ - Done by marking certain bytes of memory and tracking how it flows through program execution
991
+ - Often implemented on top of dynamic binary instrumentation tools like Intel Pin
992
+ - Steps:
993
+ - Define taint sources: data that you want to track
994
+ - Define taint sinks: program locations that we want to check if they get influenced by data from taint sources
995
+ - Tracking input propagation: all instructions handling taint data need to be instrumented
996
+
997
+ ### Symbolic Execution
998
+
999
+ - Transform the program into a mathematical equation that can be solved
1000
+ - Instructions are simulated to maintain a binary formula describing the satisfied conditions for each path
1001
+ - Scan types:
1002
+ - `Static`: [S2E](https://github.com/S2E/s2e) based on source code, not reliant on architecture, very hard to reason about kernel/libraries
1003
+ - `Dynamic`: combine concrete state with symbolic state, scales better
1004
+ - Engine types:
1005
+ - `Full System`: operates on the entire VM by integrating with hypervisors, very powerful but hard to use
1006
+ - `Binary`: [Triton](https://github.com/JonathanSalwan/Triton) based on Pin/Taint Analysis and [Angr](https://github.com/angr/angr) based on `VEX-IR`
1007
+ - `Source Code`: [Klee](https://github.com/klee/klee) based on LLVM
1008
+ - You can augment fuzzers via symbolic execution, [driller](https://github.com/shellphish/driller) is an example
1009
+
1010
+ #### Challenges with Symbolic Execution
1011
+
1012
+ - Memory
1013
+ - Complex data structures are hard to symbolize
1014
+ - Environment
1015
+ - How are library and system calls handled
1016
+ - Symbolically executing massive library functions hurt performance
1017
+ - State/Path Explosion
1018
+ - Biggest issue, loops/nested conditionals exponentially increases execution state
1019
+ - Heuristics are often used to determine with paths to follow
1020
+ - Constraint Solving
1021
+ - Once the formula gets large enough, it gets hard to solve and impacts performance
1022
+
1023
+ ### eBPF‑based Dynamic Tracing
1024
+
1025
+ - **bpftrace** / **BCC**: attach uprobes/kprobes to collect heap, syscall, or scheduler events with minimal overhead
1026
+ - Ideal for pre‑fuzz triage and live coverage measurement on kernels or containerised workloads
1027
+
1028
+ ### Coverage Recon (quick)
1029
+
1030
+ ```bash
1031
+ # Collect light coverage then visualize
1032
+ drrun -t drcov -- ./target @@
1033
+ python3 drcov2lcov.py ./drcov.*.log > coverage.info
1034
+ genhtml coverage.info -o cov_html
1035
+ ```
1036
+
1037
+ - Load into Lighthouse (IDA) or lcov HTML to identify cold paths reachable from attacker input
1038
+ - Use results to select fuzz targets and build a minimal, representative seed corpus
1039
+
1040
+ ## Fuzzing
1041
+
1042
+ Fuzzing is a technique where you feed the application malformed inputs and monitor for crashes or unintended behaviors. See the dedicated [Fuzzing](/exploit/fuzzing.md) document for more detailed techniques.
1043
+
1044
+ ### Fuzzing Overview
1045
+
1046
+ #### What is Fuzzing?
1047
+
1048
+ - Target software parses controllable input
1049
+ - We create and/or mutate input and feed it into program
1050
+ - Find crashes
1051
+
1052
+ #### What a Fuzzer Does
1053
+
1054
+ - Generic but platform/architecture specific
1055
+ - Handles Input Generation/Mutation/Saving (called Corpus)
1056
+ - Instrumenting Target (running, resetting, getting feedback)
1057
+ - Reporting Crashes
1058
+
1059
+ #### What a Harness Does
1060
+
1061
+ - Target Specific
1062
+ - Handles Feeding the input into the target
1063
+
1064
+ #### Fuzzer vs Harness Relationship
1065
+
1066
+ - Find Top Level Callable Functions
1067
+ - Use Harness to Call that Function and Feed Input to it
1068
+ - Fuzzer Generates and Sends the Input to Harness and Collects Coverage and Detects Crashes
1069
+
1070
+ ### Crash Detection Techniques
1071
+
1072
+ - Paged Heap (heap overflows, UAF)
1073
+ - Guard pages between allocations
1074
+ - Address Sanitizer (overflows + more)
1075
+ - Shadow memory (by inserting red zones in-between stack objects)
1076
+ - Memory Sanitizer (uninitialized variable read)
1077
+ - Memory Leak, Used to Break ASLR
1078
+ - Cluster crashes with token‑based Capstone‑hashing or `gdb‑script dedup.py` before manual analysis.
1079
+
1080
+ ### Fuzzing Tools
1081
+
1082
+ #### Modern Fuzzing Frameworks
1083
+
1084
+ - **AFL++ 4.21+** – Unified cross-platform fuzzer with Windows support, CMPLOG, QEMU-mode
1085
+ - **LibAFL 0.13+** – Rust-native, highly customizable, supports in-process and fork-server modes
1086
+ - **Honggfuzz** – Persistent-mode Windows support, hardware-based feedback
1087
+ - **Nyx** – Full-VM snapshot fuzzing with KVM acceleration
1088
+ - **ICICLE** – Fast Windows kernel fuzzing framework
1089
+ - **Syzkaller** – Kernel fuzzer with LLM-guided seed selection (2025)
1090
+
1091
+ #### Instrumentation & Coverage
1092
+
1093
+ - **DynamoRIO** – Used by AFL++, faster than Intel Pin (Note: Intel Pin is now sustain-only)
1094
+ - **Frida Stalker** – Cross-platform dynamic instrumentation
1095
+ - **Intel PT** – Hardware-accelerated coverage collection
1096
+ - **Emerald** – Generates `drcov` data for coverage visualization
1097
+
1098
+ #### Specialized Fuzzers
1099
+
1100
+ - **ChatAFL / LLM-driller** – LLM-guided corpus expansion (+30% coverage on complex targets)
1101
+ - **Reads-From Fuzzer (RFF)** – Concurrency fuzzer for race/TOCTOU bugs
1102
+ - **LibFuzzer** – In-process, coverage-guided fuzzer for source-available targets
1103
+ - **Radamsa** → **Replaced by LibAFL mutators** (more coverage-aware)
1104
+
1105
+ #### Symbolic Execution Engines
1106
+
1107
+ - **Triton** – Dynamic binary analysis framework
1108
+ - **Angr** – Binary analysis platform with symbolic execution
1109
+ - **Manticore** – Dynamic symbolic execution tool
1110
+ - **S2E** – Selective symbolic execution platform
1111
+
1112
+ ### Continuous-Integration Fuzzing
1113
+
1114
+ - **ClusterFuzzLite** – GitHub Actions/CI runner that feeds corpora to AFL++, libFuzzer or honggfuzz and files issues automatically.
1115
+
1116
+ ### Snapshot Fuzzing
1117
+
1118
+ #### VMM Snapshot Fuzzing
1119
+
1120
+ - **QEMU Snapshots:** Fast restoration for stateful targets
1121
+ - **KVM Acceleration:** Dirty page tracking for efficient resets
1122
+ - **Persistent Mode:** Memory-only reset without full VM restore
1123
+
1124
+ ### Fuzzing Types
1125
+
1126
+ #### Dumb Fuzzing
1127
+
1128
+ - Just sending random data to the target
1129
+
1130
+ #### Smart Fuzzing
1131
+
1132
+ - _Mutation Based_: Test cases are obtained by applying mutations to valid, known good samples (e.g., [Radamsa](https://gitlab.com/akihe/radamsa))
1133
+ - _Generation(Grammar) Based_: Test cases are obtained by modeling files or protocol specifications based on models, templates, RFCs, or documentation (e.g., [Peach Fuzzer](https://peachtech.gitlab.io/peach-fuzzer-community/))
1134
+ - _Model Based_: Test cases are obtained by modeling the target protocol/file format (when you want to test the target's ability to accept and process invalid sequences of data)
1135
+ - _Differential Fuzzing_: Comparing outputs of different implementations with the same input
1136
+
1137
+ #### Evolutionary Fuzzing
1138
+
1139
+ - Test cases and inputs are generated based on the response from the program
1140
+ - `AFL` is an example
1141
+ - Or Google ClusterFuzz
1142
+
1143
+ #### Concurrency Fuzzing
1144
+
1145
+ - Systematically permutes thread scheduling to uncover data‑race, atomicity, and TOCTOU vulnerabilities that traditional coverage‑guided fuzzers miss
1146
+
1147
+ #### LLM‑Guided Fuzzing
1148
+
1149
+ - **ChatAFL** – integrates an LLM to propose protocol‑aware mutations; boosts state coverage on network daemons by ~40 %.
1150
+ - **SyzAgent / SyzLLM (2025‑02)** – schedules kernel `syz` programs suggested by an LLM fine‑tuned on the Syzkaller corpus.
1151
+ - **NumSeed** – leverages natural‑language descriptions of inputs to seed generation for binary‑only targets.
1152
+
1153
+ ### Combined Method
1154
+
1155
+ The most effective approach often combines multiple techniques:
1156
+
1157
+ - Reverse engineer first to identify interesting parts
1158
+ - Fuzz those parts to find crashes
1159
+ - Investigate crashes to find exploitable vulnerabilities
1160
+ - For shellcode development, see [Shellcode](/exploit/shellcode.md)
1161
+
1162
+ ## AI/ML-Assisted Vulnerability Discovery
1163
+
1164
+ Modern vulnerability research increasingly leverages machine learning and large language models to accelerate discovery and analysis.
1165
+
1166
+ ### LLM-Powered Triage and Analysis
1167
+
1168
+ - **Automated Crash Analysis:**
1169
+ - GPT-4/Claude for interpreting crash dumps and stack traces
1170
+ - Automated root-cause hypothesis generation from fuzzer output
1171
+ - Natural language queries against large codebases for vulnerability patterns
1172
+ - **Decompilation Enhancement:**
1173
+ - Ghidra's ML-powered function signature recognition (11.2+)
1174
+ - Binary Ninja's HLIL AI improvements for cleaner pseudocode
1175
+ - Automated variable and function renaming based on context
1176
+
1177
+ ### AI-Powered Vulnerability Scanners
1178
+
1179
+ - **ZeroScan:** Deep learning model trained on CVE datasets to identify vulnerability patterns in binaries
1180
+ - **BigCode/StarCoder Models:** Fine-tuned on security-relevant code for pattern recognition
1181
+ - **CodeQL with ML:** GitHub's semantic analysis enhanced with machine learning classifiers
1182
+
1183
+ ### LLM-Assisted Fuzzing
1184
+
1185
+ - **ChatAFL:** Uses LLMs to generate input grammars and seed corpus based on protocol documentation
1186
+ - **HyLLFuzz:** GPT/Llama-3 generates branch-targeted mutations achieving ~1.3× edge coverage improvement
1187
+ - **Grammar Inference:** Automatically derive input structure from example files using transformer models
1188
+
1189
+ ### Practical Integration
1190
+
1191
+ ```python
1192
+ # Example: Using local LLM for crash triage (OPSEC-safe)
1193
+ from transformers import AutoTokenizer, AutoModelForCausalLM
1194
+
1195
+ def analyze_crash_local(crash_log, binary_info):
1196
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3-8b")
1197
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3-8b")
1198
+
1199
+ prompt = f"""Analyze this crash and suggest root cause:
1200
+
1201
+ Binary: {binary_info}
1202
+ Crash Log:
1203
+ {crash_log}
1204
+
1205
+ Provide: 1) Root cause hypothesis 2) Exploitability assessment 3) Suggested exploit primitive"""
1206
+
1207
+ inputs = tokenizer(prompt, return_tensors="pt")
1208
+ outputs = model.generate(**inputs, max_length=1000)
1209
+ return tokenizer.decode(outputs[0])
1210
+ ```
1211
+
1212
+ ### Limitations and Considerations
1213
+
1214
+ - **False Positives:** AI models can hallucinate vulnerabilities; manual verification essential
1215
+ - **Training Data Bias:** Models trained on public CVEs may miss novel vulnerability classes
1216
+ - **OPSEC:** Avoid sending proprietary code to cloud LLM APIs; use local models (Llama, Mistral)
1217
+ - **Context Windows:** Most models have 4K-32K token limits; chunk large binaries/logs appropriately
1218
+
1219
+ ## Quick Reference: Tool Selection Guide
1220
+
1221
+ ### By Target Type
1222
+
1223
+ | Target | Primary Tools | Secondary Tools |
1224
+ | -------------------- | ----------------- | ------------------- |
1225
+ | **Linux Kernel** | Syzkaller, AFL++ | KASAN, KCOV, ftrace |
1226
+ | **Windows Kernel** | ICICLE, WinAFL | Verifier, KFUZZ |
1227
+ | **Browsers** | LibFuzzer, Domato | ClusterFuzz, Dharma |
1228
+ | **Network Services** | AFL++, Boofuzz | Peach, Sulley |
1229
+ | **Mobile Apps** | QARK, Frida | MobSF, Objection |
1230
+ | **Web Apps** | Burp Suite, FFUF | Nuclei, Semgrep |
1231
+ | **Firmware** | Binwalk, EMBA | FACT, Firmwalker |
1232
+ | **Containers** | Trivy, Falco | Grype, Syft |
1233
+
1234
+ ### By Technique
1235
+
1236
+ | Technique | Recommended Tools | Notes |
1237
+ | ----------------------- | -------------------- | ------------------------------ |
1238
+ | **Coverage Fuzzing** | AFL++ 4.21+ | Cross-platform, CMPLOG support |
1239
+ | **Snapshot Fuzzing** | Nyx, QEMU+AFL++ | Stateful target support |
1240
+ | **Concurrency Fuzzing** | RFF, ThreadSanitizer | Race condition detection |
1241
+ | **Symbolic Execution** | Angr, Triton | Path exploration |
1242
+ | **Taint Analysis** | DynamoRIO, Triton | Data flow tracking |
1243
+ | **Binary Diffing** | BinDiff 8, Ghidriff | Patch analysis |
1244
+ | **Static Analysis** | CodeQL, Semgrep | Pattern matching |
1245
+ | **Dynamic Analysis** | Frida, DynamoRIO | Runtime instrumentation |
1246
+
1247
+ ### Tool Migration Path
1248
+
1249
+ | Old Tool | New Alternative | Migration Notes |
1250
+ | --------- | ------------------ | -------------------------- |
1251
+ | Intel Pin | DynamoRIO | Pin is sustain-only |
1252
+ | WinAFL | AFL++ 4.x | Integrated Windows support |
1253
+ | Radamsa | LibAFL mutators | Better coverage awareness |
1254
+ | BinDiff 7 | BinDiff 8/Ghidriff | Improved algorithms |
1255
+ | IDA 7.x | IDA 8.x/Ghidra 11 | Better decompilation |
1256
+