Ctf Flag Verification logo

Ctf Flag Verification

OrganizationPopular
wgpsec
ctf-flag-verification

CTF/靶场 Flag 强制验证流程。当通过**任何方式**发现疑似 flag 字符串(含 flag{、FLAG{、ctf{ 等格式)时**必须立即**使用此 skill 验证,不要直接提交。防止因字符截断、编码错误、HTML 实体、base64 不完整解码、hex 截断等原因导致提交错误 flag。即使 flag 看起来完整,也可能存在隐藏字符或编码问题。覆盖 SQL 注入分段提取、命令执行输出截断、文件读取编码、Web 页面解析等所有 flag 提取场景。任何时候看到 flag{ 字样都应触发此 skill

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namectf-flag-verification
Stars
1.7K
Forks
242
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the Ctf Flag Verification AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/ctf/ctf-flag-verification .claude/skills/ctf-flag-verification
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ctf Flag Verification in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ctf Flag Verification on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ctf Flag Verification is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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 编码(&lt;<)→ 用 Python html.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 验证:

python
flag = "flag{...extracted...}"
expected_length = 70  # 从 LENGTH() 获得
assert len(flag) == expected_length, f"MISMATCH! {len(flag)} != {expected_length}"

1.3 格式验证

python
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 实体&amp; 未解码html.unescape()
Flag 有换行/空格命令输出含 whitespace.strip()
Flag 格式不对提取了错误数据重新确认表名/文件路径

1.6 字符级验证问题

  • Flag 中间丢失字符时,检查位置 29-32 区域,可能存在偏移错误导致遗漏字符
  • HTML 实体还原:&lt; 变成 <&amp; 变成 &,网页显示与源码不同,需解码还原
  • 示例:flag{a3b<c5d&e7f} — 渲染后不同于源码,解码后才是正确 flag

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Ctf Flag Verification AI skill do?

CTF/靶场 Flag 强制验证流程。当通过**任何方式**发现疑似 flag 字符串(含 flag{、FLAG{、ctf{ 等格式)时**必须立即**使用此 skill 验证,不要直接提交。防止因字符截断、编码错误、HTML 实体、base64 不完整解码、hex 截断等原因导致提交错误 flag。即使 flag 看起来完整,也可能存在隐藏字符或编码问题。覆盖 SQL 注入分段提取、命令执行输出截断、文件读取编码、Web 页面解析等所有 flag 提取场景。任何时候看到 flag{ 字样都应触发此 skill

Why use Ctf Flag Verification on TypingMind?

Because you install it once and use it with any model. Ctf Flag Verification is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ctf Flag Verification in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/ctf/ctf-flag-verification. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Ctf Flag Verification?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ctf Flag Verification?

As many as you like. As long as a model supports skills, you can use Ctf Flag Verification with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ctf Flag Verification AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇