Ctf Flag Hunting logo

Ctf Flag Hunting

OrganizationPopular
wgpsec
ctf-flag-hunting

CTF 挑战中的 Flag 搜索策略。当通过 RCE/LFI/SQLi/webshell 等方式获得目标访问权限后、使用常规 ls/cat 命令找不到 flag 时使用。覆盖文件系统、数据库、环境变量、源码、内存等所有 flag 可能的存储位置。按成功率排序的搜索优先级——先试标准路径,再搜索全盘

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namectf-flag-hunting
Stars
1.7K
Forks
242
Bundled files
3
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.

  • 3 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 Hunting 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-hunting .claude/skills/ctf-flag-hunting
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ctf Flag Hunting 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 Hunting 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 Hunting 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 搜索策略

⛔ 深入参考(补充读物)


Phase 1: 按权限类型选择搜索策略

你有什么权限?
├─ 命令执行(RCE)→ Phase 2
├─ 文件读取(LFI)→ Phase 3
├─ 数据库访问(SQLi)→ Phase 4
└─ Web 管理后台 → Phase 5

Phase 2: RCE — 文件系统搜索

优先级顺序(按成功率排列):

2.1 标准 flag 路径(先试这些,一次试完)

bash
cat /flag.txt && cat /flag && cat /root/flag.txt && cat /home/*/flag.txt

2.2 非标准路径(标准路径失败后)

bash
cat /var/www/html/flag.txt
cat /var/www/html/flag.php
cat /tmp/flag
cat /tmp/flag.txt
cat /opt/flag.txt
cat /app/flag.txt

也可以看看路径下的文件名

bash
ls /root
ls /tmp

2.3 全盘搜索(路径不确定时)

bash
find / -name "flag*" 2>/dev/null
find / -name "*.txt" -path "*/flag*" 2>/dev/null
grep -r "flag{" / --include="*.txt" --include="*.php" --include="*.html" 2>/dev/null

2.4 环境变量和进程

bash
env | grep -i flag
cat /proc/self/environ | tr '\0' '\n' | grep -i flag
cat /proc/self/cmdline | tr '\0' '\n' | grep -i flag

2.5 数据库配置 → 查库

bash
cat /var/www/html/config.php    # 数据库连接凭据
cat /var/www/html/.env          # 环境变量泄露
cat /app/config.py

找到数据库凭据后:

bash
mysql -u <user> -p<password> -e "SHOW DATABASES; USE <db>; SHOW TABLES; SELECT * FROM flag;"

2.6 进程和网络

bash
ps aux | grep -i flag      # 进程命令行参数
netstat -tlnp              # 内网服务可能有 flag
lsof -i                    # 开放端口对应的服务

Phase 3: LFI — 文件读取搜索

LFI 比 RCE 限制更多——只能读文件,不能执行命令。

路径遍历找 flag 时,对每个深度同时尝试多种文件名变体:

# 每个深度都要批量测试这些变体(不要只试 flag 不试 flag.txt!)
../flag          ../flag.txt        ../.flag         ../flag.md
../../flag       ../../flag.txt     ../../.flag
../../../flag    ../../../flag.txt  ../../../.flag
# 同时测试绝对路径
/flag            /flag.txt          /root/flag.txt   /tmp/flag

⚠️ 常见失败模式:只尝试 ../flag 而忽略 ../flag.txt,导致超时。务必同时发送带后缀和不带后缀的变体。

优先级顺序:

  1. 标准 flag 路径:对每个深度(../../../../../../)同时尝试 flagflag.txt.flagflag.md
  2. 确认可读性/etc/passwd 能读 → 说明 LFI 有效
  3. 配置文件(找更多凭据):
    /var/www/html/config.php
    /var/www/html/.env
    /proc/self/environ
    /proc/self/mounts
  4. 源码文件/var/www/html/index.php/app/app.py — 可能发现 RCE 入口
  5. 日志文件/var/log/apache2/access.log — 日志投毒准备

Phase 4: SQLi — 数据库搜索

sql
-- 1. 列出现有数据库
SHOW DATABASES;

-- 2. 切换后列出表
USE <db>;
SHOW TABLES;

-- 3. 直接查 flag 表
SELECT * FROM flag;
SELECT * FROM flags;
SELECT * FROM secret;
SELECT * FROM secret_table;

-- 4. 不知道表名时搜索
SELECT table_name, column_name FROM information_schema.columns WHERE column_name LIKE '%flag%';

-- 5. 读取文件(需要 FILE 权限)
SELECT LOAD_FILE('/flag.txt');

Phase 5: Web 管理后台搜索

  1. 翻遍所有页面 — flag 可能在非标准页面("关于"、"帮助"、"调试")
  2. 用户相关字段 — notes、bio、email、description 中可能藏 flag
  3. 系统配置页 — 「系统信息」「服务器状态」可能显示 flag
  4. 文件管理/模板编辑 — 可写文件时直接部署 webshell
  5. 源码注释 — 搜索 HTML 注释、JS 注释中的 flag 字符串

Phase 6: 搜不到 flag 时

标准路径都试过仍找不到,尝试以下降级手段:

  1. 切换提取方式
    • RCE 盲注:利用时间延迟或 DNS 外带逐字符提取
    • LFI 配合竞争条件或 PHP session 包含
  2. 扩大搜索范围
    • 数据库其他表:SELECT * FROM users LIMIT 10; — flag 可能泄露在用户数据里
    • 历史命令:history — 之前做过的操作可能遗留 flag 路径
  3. 找其他入口
    • 翻 Jenkins/GitLab/后台管理 — 也许有 flag 公开在那
    • 检查 nginx/apache 配置文件:/etc/nginx/sites-enabled/ — 路径映射可能泄露
  4. 利用题目暗示
    • 题目名称往往暗示 flag 位置(如 baby_pwn → pwn 类题目)
    • 描述中的关键词("database"、"source")指向搜索方向

Flag 格式识别

  • flag{hex_string} — 最常见,32/40/64 字符
  • flag{string}CTF{string} — 小写或其他前缀
  • 纯字符串(题目会说明)

假 flag 陷阱flag{test}flag{this_is_not_the_flag} 是迷惑项。


注意事项

  • 先验证再提交:拿到 flag 后用 ctf-flag-verification 验证格式和长度
  • 假 flag 判断:长度/字符异常,很可能是迷惑项
  • LFI 优先读配置:配置文件能告诉你数据库密码,从数据库找 flag 比猜路径可靠
  • RCE 优先查库:很多 CTF 的 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 Hunting AI skill do?

CTF 挑战中的 Flag 搜索策略。当通过 RCE/LFI/SQLi/webshell 等方式获得目标访问权限后、使用常规 ls/cat 命令找不到 flag 时使用。覆盖文件系统、数据库、环境变量、源码、内存等所有 flag 可能的存储位置。按成功率排序的搜索优先级——先试标准路径,再搜索全盘

Why use Ctf Flag Hunting on TypingMind?

Because you install it once and use it with any model. Ctf Flag Hunting 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 Hunting in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/ctf/ctf-flag-hunting. 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 Hunting?

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 Hunting?

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

Is the Ctf Flag Hunting 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 👇