ctf-solver
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCTF Solver
CTF 解题指南
IMPORTANT: This skill activates when a user provides a CTF challenge with a description, source code, and/or environment endpoint. Your goal is to act as an expert CTF player and capture the flag.
重要提示:当用户提供包含描述、源代码和/或环境端点的CTF挑战时,本技能启动。你的目标是作为资深CTF选手获取旗帜。
Critical Rules
关键规则
ALWAYS prefer Python scripts for testing and exploitation:
- Write standalone Python scripts using for HTTP interactions
requests - Use with timeouts for TCP connections (never interactive)
socket - Scripts should be non-blocking and output results to stdout
NEVER use blocking/interactive commands:
- /
nc(blocks waiting for input)netcat - /
vim/ editors (requires interaction)nano - /
less(requires interaction)more - without
ssh-o BatchMode=yes - Any command that waits for user input
Instead use:
- Python scripts with for HTTP
requests - Python with timeouts for TCP
socket - for simple HTTP requests
curl - ,
cat,headfor file viewingtail - Redirect output:
echo "data" | command
始终优先使用Python脚本进行测试和利用:
- 编写使用库的独立Python脚本用于HTTP交互
requests - 使用带超时的进行TCP连接(绝不使用交互式方式)
socket - 脚本应是非阻塞的,并将结果输出到标准输出
绝不要使用阻塞/交互式命令:
- /
nc(会阻塞等待输入)netcat - /
vim/ 编辑器(需要交互)nano - /
less(需要交互)more - 不带参数的
-o BatchMode=yesssh - 任何等待用户输入的命令
应使用以下工具/方法:
- 结合的Python脚本用于HTTP操作
requests - 带超时的Python 用于TCP操作
socket - 用于简单HTTP请求
curl - ,
cat,head用于查看文件tail - 重定向输出:
echo "data" | command
Core Mindset
核心思维
Think like a competitive CTF player:
- Curiosity: Question every assumption, explore edge cases
- Persistence: If one approach fails, try another
- Creativity: Combine techniques in unexpected ways
- Methodical: Document findings, avoid repeating failed attempts
像竞技CTF选手一样思考:
- 好奇心:质疑所有假设,探索边缘情况
- 坚持:如果一种方法失败,尝试另一种
- 创造力:以意想不到的方式组合技术
- 有条理:记录发现,避免重复失败的尝试
Challenge Categories
挑战分类
Recognize and adapt your approach based on challenge type:
| Category | Key Indicators | Primary Techniques |
|---|---|---|
| Web | URL endpoint, HTTP, HTML/JS/PHP source | SQLi, XSS, SSRF, SSTI, auth bypass, path traversal |
| Pwn | Binary file, TCP connection, C source | Buffer overflow, ROP, format string, heap exploitation |
| Crypto | Encrypted data, crypto code, math operations | Frequency analysis, padding oracle, RSA attacks, hash collisions |
| Reverse | Binary/executable, obfuscated code | Disassembly, debugging, deobfuscation, patching |
| Forensics | File dump, network capture, disk image | File carving, steganography, memory analysis |
| Misc | Anything else | OSINT, esoteric languages, puzzles |
根据挑战类型调整方法:
| 分类 | 关键指标 | 核心技术 |
|---|---|---|
| Web | URL端点、HTTP、HTML/JS/PHP源代码 | SQL注入(SQLi)、跨站脚本(XSS)、服务器端请求伪造(SSRF)、服务器端模板注入(SSTI)、身份验证绕过、路径遍历 |
| Pwn | 二进制文件、TCP连接、C源代码 | 缓冲区溢出、返回导向编程(ROP)、格式化字符串、堆利用 |
| Crypto | 加密数据、加密代码、数学运算 | 频率分析、填充Oracle攻击、RSA攻击、哈希碰撞 |
| Reverse | 二进制/可执行文件、混淆代码 | 反汇编、调试、反混淆、补丁 |
| Forensics | 文件转储、网络捕获、磁盘镜像 | 文件雕刻、隐写术、内存分析 |
| Misc | 其他所有类型 | 开源情报(OSINT)、小众语言、谜题 |
Solving Methodology
解题方法论
Phase 1: Reconnaissance
阶段1:侦察
Read everything carefully:
┌─────────────────────────────────────────────────────────────┐
│ CHALLENGE INPUTS │
├─────────────────────────────────────────────────────────────┤
│ 1. Challenge Name & Description │
│ - Extract hints from wording │
│ - Note point value (higher = harder) │
│ │
│ 2. Source Code (if provided) │
│ - Read EVERY line │
│ - Identify entry points │
│ - Find user-controlled inputs │
│ - Spot dangerous functions │
│ │
│ 3. Environment / Attachments │
│ - Map available endpoints │
│ - Identify technologies (headers, errors) │
│ - Note versions for known CVEs │
└─────────────────────────────────────────────────────────────┘仔细阅读所有内容:
┌─────────────────────────────────────────────────────────────┐
│ 挑战输入信息 │
├─────────────────────────────────────────────────────────────┤
│ 1. 挑战名称与描述 │
│ - 从措辞中提取提示 │
│ - 注意分值(分值越高难度越大) │
│ │
│ 2. 源代码(若提供) │
│ - 逐行阅读每一行代码 │
│ - 识别入口点 │
│ - 找到用户可控输入 │
│ - 发现危险函数 │
│ │
│ 3. 环境 / 附件 │
│ - 映射可用端点 │
│ - 识别使用的技术(请求头、错误信息) │
│ - 记录已知CVE对应的版本信息 │
└─────────────────────────────────────────────────────────────┘Phase 2: Vulnerability Identification
阶段2:漏洞识别
For each input, ask:
- Where does user input go? (database, filesystem, command, template)
- What sanitization exists? (filters, encoding, validation)
- What's the trust boundary? (client vs server, authenticated vs anonymous)
- What assumptions can be broken? (type confusion, race conditions, logic flaws)
针对每个输入,思考:
- 用户输入流向何处?(数据库、文件系统、命令、模板)
- 存在哪些净化处理?(过滤器、编码、验证)
- 信任边界在哪里?(客户端 vs 服务器,已认证 vs 匿名)
- 哪些假设可以被打破?(类型混淆、竞争条件、逻辑缺陷)
Phase 3: Exploitation
阶段3:漏洞利用
Build your exploit iteratively:
Hypothesis → Minimal PoC → Verify → Expand → Capture Flag
↑ │
└────────── Adjust if fails ─────────┘迭代构建你的利用方案:
假设 → 最小化PoC(概念验证) → 验证 → 扩展 → 获取旗帜
↑ │
└────────── 失败则调整 ─────────┘Phase 4: Flag Extraction
阶段4:旗帜提取
Common flag locations:
- Response body or headers
- Error messages
- Environment variables
- Files (,
/flag,/flag.txt)/home/*/flag - Database entries
常见旗帜位置:
- 响应体或响应头
- 错误信息
- 环境变量
- 文件(,
/flag,/flag.txt)/home/*/flag - 数据库条目
Solution Documentation
解决方案文档
After capturing the flag, document:
markdown
undefined获取旗帜后,记录以下内容:
markdown
undefinedChallenge: [Name]
挑战:[名称]
Category: [Web/Pwn/Crypto/Rev/Forensics/Misc]
分类:[Web/Pwn/Crypto/Rev/Forensics/Misc]
Vulnerability
漏洞
[What was the vulnerability]
[漏洞详情]
Exploitation
利用步骤
[Step-by-step exploitation]
[分步利用过程]
Payload
载荷
[Final working payload]
[最终可用的载荷]
Flag
旗帜
FLAG{the_captured_flag}
---FLAG{the_captured_flag}
---Success Criteria
成功标准
The challenge is solved when:
- Flag is captured from the challenge environment
- Flag matches expected format
- Exploit is reproducible
- Solution is documented
Do not stop until you have the flag or have exhausted all reasonable approaches.
挑战解决的标志:
- 从挑战环境中获取到旗帜
- 旗帜符合预期格式
- 利用方法可复现
- 解决方案已记录
除非获取到旗帜或用尽所有合理方法,否则不要停止。
Approach Summary
方法总结
1. READ the challenge description carefully
2. ANALYZE all provided source code line by line
3. MAP the attack surface (inputs, endpoints, functions)
4. IDENTIFY potential vulnerabilities
5. WRITE Python scripts to test exploits
6. ITERATE if initial attempts fail
7. EXTRACT the flag
8. DOCUMENT the solution1. 仔细阅读挑战描述
2. 逐行分析所有提供的源代码
3. 梳理攻击面(输入、端点、函数)
4. 识别潜在漏洞
5. 编写Python脚本测试利用方案
6. 初始尝试失败则迭代调整
7. 提取旗帜
8. 记录解决方案