
Ctf Flag Verification
- 29 installs
- 1.6k repo stars
- Updated July 19, 2026
- wgpsec/aboutsecurity
Helps with ai & agent building tasks during AI-assisted development.
About
ctf-flag-verification is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- ctf-flag-verification
- AI & Agent Building
- AI-coding skill
Ctf Flag Verification by the numbers
- 29 all-time installs (skills.sh)
- +2 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #9,417 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/wgpsec/aboutsecurity --skill ctf-flag-verificationAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 29 |
|---|---|
| repo stars | ★ 1.6k |
| Last updated | July 19, 2026 |
| Repository | wgpsec/aboutsecurity ↗ |
What it does
Helps with ai & agent building tasks during AI-assisted development.
Files
CTF Flag 验证方法论
核心原则
LLM 无法可靠地数 hex 字符或拼接长字符串。 所有 flag 的提取、拼接、验证必须用程序(Python)完成,绝不手动拼接。
强制验证流程
1.1 提取 flag 时优先使用程序化方法
SQL 注入(EXTRACTVALUE/UPDATEXML 分段提取):
- ❌ 不要手动复制各段然后在思考中拼接
- ✅ 写 Python 脚本自动发请求、自动分段、自动拼接(参考 sql-injection-methodology 中的 Python 模板)
- ✅ 优先用 UNION SELECT(无截断限制,一次拿完整 flag)
命令执行(RCE / 命令注入):
- ⚠️
cat /flag.txt输出可能含 trailing newline → 用flag.strip()去除 - ⚠️ 命令输出可能被 HTML 编码(
<→<)→ 用 Pythonhtml.unescape()解码 - ⚠️ 如果回显被截断,改用
base64 /flag.txt再解码
文件读取(LFI / 任意文件读取):
- ⚠️ PHP
file_get_contents可能返回 base64 → 先解码 - ⚠️ 通过 php://filter 读取时:
php://filter/convert.base64-encode/resource=flag→ 必须 base64 解码 - ⚠️ 路径大小写敏感:
/flag.txt≠/Flag.txt≠/FLAG.txt
Web 页面解析:
- Flag 可能在 HTML 注释
<!-- flag{...} -->中 - Flag 可能在 HTML 属性
data-flag="flag{...}"中 - Flag 可能在 JavaScript 变量
var flag = "flag{...}"中 - 用 Python
re.search(r'flag\{[a-fA-F0-9_-]+\}', html_text)提取
1.2 长度验证
如果你通过 SQL LENGTH() 或其他方式获知了 flag 的预期长度,用 Python 验证:
flag = "flag{...extracted...}"
expected_length = 70 # 从 LENGTH() 获得
assert len(flag) == expected_length, f"MISMATCH! {len(flag)} != {expected_length}"1.3 格式验证
import re
flag = "flag{...}"
assert re.match(r'^flag\{[a-fA-F0-9_-]+\}$', flag), f"Invalid format: {flag}"
assert flag.endswith('}'), "Missing } — flag 可能被截断"1.4 验证失败的处理
1. 长度不匹配 → 重新提取。EXTRACTVALUE 改用 Python 自动脚本或 UNION SELECT 2. 格式不对 → 检查 HTML 编码、base64 编码、trailing whitespace 3. 多次失败 → 切换提取方法(EXTRACTVALUE → UNION → 盲注 → sqlmap --dump)
1.5 常见错误模式
| 错误 | 原因 | 解决 |
|---|---|---|
| Flag 少 1-2 字符 | EXTRACTVALUE 32 字符截断 + 手动拼接 | Python 自动提取脚本 |
| Flag 多 1-2 字符 | SUBSTRING 起始位置重叠 | 检查 SUBSTRING 参数 |
| Flag 中间有错字符 | LLM 误读 hex 字符 | Python re.search 提取 |
| Flag 含 HTML 实体 | & 未解码 | html.unescape() |
| Flag 有换行/空格 | 命令输出含 whitespace | .strip() |
| Flag 格式不对 | 提取了错误数据 | 重新确认表名/文件路径 |
1.6 字符级验证问题
- Flag 中间丢失字符时,检查位置 29-32 区域,可能存在偏移错误导致遗漏字符
- HTML 实体还原:
<变成<,&变成&,网页显示与源码不同,需解码还原 - 示例:
flag{a3b<c5d&e7f}— 渲染后不同于源码,解码后才是正确 flag
{
"skill_name": "ctf-flag-verification",
"evals": [
{
"id": 1,
"name": "flag-extractvalue-truncation-trap",
"prompt": "你用 EXTRACTVALUE 报错注入提取 flag,LENGTH() 显示 flag 总长 64 字符。你 SUBSTRING(1,32) 得到 'flag{0aa3ada534b6aa7033dddbf624' (28字符含flag{}),SUBSTRING(33,32) 得到 '076c48afd97407bcab9b1d6acb6bc50f'。手动拼接后长度只有 60。问题在哪?如何正确做?",
"expected_output": "EXTRACTVALUE 每段限32字符,中间有4字符丢失(位置29-32)。应该用 Python 自动化分段提取,不要手动拼接。",
"expectations": [
"32字符截断|EXTRACTVALUE限制|报错函数长度限制",
"中间丢失|遗漏字符|位置29-32|偏移错误",
"Python脚本|自动提取|不要手动拼接|程序化",
"UNION SELECT|替代方案|无截断|一次拿完整",
"LLM不可靠|数hex字符|自动化验证"
],
"required_terms": [
"UNION SELECT",
"Python脚本",
"数hex字符"
]
},
{
"id": 2,
"name": "flag-html-entity-decode",
"prompt": "命令执行返回的结果在网页中显示为:flag{a3b<c5d&e7f}。你直接提交了 flag{a3b<c5d&e7f} 但被判定为错误。问题在哪?",
"expected_output": "HTML 实体编码未解码:< → <,& → &。应该用 Python html.unescape() 解码后再提交。",
"expectations": [
"HTML实体|<|&|编码未解码",
"html.unescape|Python解码|实体转换",
"<变成<|&变成&|解码还原",
"网页显示|渲染后不同|源码vs显示",
"flag{a3b<c5d&e7f}|解码后正确flag"
],
"required_terms": [
"flag{a3b<c5d&e7f}",
"html.unescape",
"HTML实体"
]
},
{
"id": 3,
"name": "flag-base64-lfi-scenario",
"prompt": "通过 LFI 漏洞你用 php://filter/convert.base64-encode/resource=/flag.txt 读取到一串 base64 内容 'RkxBR3thYmMxMjN9Cg=='。请描述完整的提取和验证流程。",
"expected_output": "base64 解码 → strip() 去除换行 → 正则验证格式 → 检查长度",
"expectations": [
"base64解码|decode|base64 -d|Python",
"strip()|去除换行|trailing newline|\\n",
"php://filter|base64-encode|LFI编码读取",
"正则验证|flag{|格式检查|完整性",
"Python|程序化|不要手动解码|自动化"
],
"required_terms": [
"flag{",
"strip()",
"php://filter"
]
}
]
}
{
"skill_id": "ctf-flag-verification",
"recall_tests": [
{
"id": 1,
"type": "keyword_positive",
"description": "核心关键词",
"keywords": [
"flag验证",
"flag verification",
"benchmark"
]
},
{
"id": 2,
"type": "keyword_positive",
"description": "场景搜索",
"keywords": [
"靶场",
"capture the flag",
"提交"
]
},
{
"id": 3,
"type": "keyword_negative",
"description": "不应被reverse召回",
"keywords": [
"ghidra",
"ida"
]
}
],
"llm_tests": [
{
"id": 1,
"name": "ctf-flag-verification-scenario",
"scenario": "从 SQL 注入用 EXTRACTVALUE 提取了部分 flag,但长度只有 31 字符,实际应该是 64 字符。请搜索 flag 验证方法论。",
"max_rounds": 2,
"expect_tool_calls": [
{
"tool": "list_skills",
"keyword_contains": "flag|verification|验证|截断"
},
{
"tool": "read_skill",
"id": "ctf-flag-verification"
}
]
}
]
}