Skip to content

Commit 11c9cb5

Browse files
committed
feat: enhance catalog generation with sub-tool extraction and URL handling
- Added mapping for batch flags to entry functions in generate_catalog.py. - Implemented extraction of sub-tools from batch functions, including their names and URLs. - Introduced a warning for missing URLs in sub-tools during catalog generation. - Updated the catalog version to 3. - Enhanced the HTML index to support displaying included tools for batch categories with toggle functionality. - Improved search functionality to include sub-tools in the filtering process.
1 parent 744a25e commit 11c9cb5

4 files changed

Lines changed: 1683 additions & 8 deletions

File tree

.github/skills/f8x-tool-maintenance/SKILL.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ f8x (`/Users/f0x/pte-project/infra-plat/f8x/f8x`) 是一个 12800+ 行的 Bash
99

1010
## 架构概览
1111

12-
新增或修改一个工具涉及**最多 5 个位置**
12+
新增或修改一个工具涉及**最多 6 个位置**
1313

1414
```
1515
① 版本变量 (行 93-435 区域)
1616
② 安装函数 (行 3305-6990 区域)
1717
③ 安装组调用 (行 10502-10950 区域)
1818
④ F8X_TOOL_LIST 注册 (行 10957+)
1919
⑤ Arsenal 投递物 [可选] (行 11359+)
20+
⑥ catalog.json 重新生成 (python3 generate_catalog.py)
2021
```
2122

22-
其中 ①②④ 是必须的,③ 看工具分类决定,⑤ 仅适用于需要投递到目标机执行的工具。
23+
其中 ①②④ 是必须的,③ 看工具分类决定,⑤ 仅适用于需要投递到目标机执行的工具。
2324

2425
## 新增工具流程
2526

@@ -124,6 +125,41 @@ xxx|Pentest_xxx_Install|0
124125

125126
详见 `references/arsenal-guide.md`
126127

128+
### Step 6: 更新 catalog.json(目录元数据)
129+
130+
`generate_catalog.py` 自动从 f8x 脚本提取工具目录信息,供 redc-gui 软件商店和 f8x 官网使用。
131+
132+
**新增工具后必须重新生成**
133+
```bash
134+
cd /Users/f0x/pte-project/infra-plat/f8x
135+
python3 generate_catalog.py ./f8x ./catalog.json
136+
```
137+
138+
**URL 自动提取机制**
139+
- 优先从安装函数体中提取 `github.com/xxx/yyy` URL(git clone / wget 等)
140+
- 无法提取时,fallback 到 `KNOWN_TOOL_URLS` 字典(`generate_catalog.py` 中硬编码)
141+
- 都没有时 URL 为空字符串,不会报错,但生成时会打印 warning
142+
143+
**何时需要手动添加 `KNOWN_TOOL_URLS`**
144+
- 工具通过 `Install_Switch`(apt/yum)安装,函数体里没有 GitHub URL
145+
- 工具的项目主页不是 GitHub(如 nmap.org, mitmproxy.org)
146+
-`generate_catalog.py``KNOWN_TOOL_URLS` 字典中添加 `"工具名": "URL"`
147+
148+
**`includes` 子工具**
149+
- 对 batch 类 flag(如 `-k`, `-ad`),catalog.json 会自动生成 `includes` 字段
150+
- 列出该 flag 包含的所有子工具名称和项目 URL
151+
- 数据来自递归追踪入口函数(`BATCH_ENTRY_FUNCTIONS`)的调用链
152+
153+
**新增 batch flag 时**
154+
-`BATCH_ENTRY_FUNCTIONS` 字典中添加 `"-flag": ["入口函数名"]`
155+
- 重新运行 `generate_catalog.py`
156+
157+
**验证**
158+
```bash
159+
# 检查某个 flag 的 includes 数量
160+
python3 -c "import json; d=json.load(open('catalog.json')); m=[x for x in d['modules'] if x['flag']=='-k'][0]; print(len(m.get('includes',[])), 'tools')"
161+
```
162+
127163
## 更新工具版本
128164

129165
版本更新有独立的 skill,详见 `f8x-version-update`。以下是快速参考:
@@ -173,6 +209,8 @@ xxx|Pentest_xxx_Install|0
173209
| `/Users/f0x/pte-project/infra-plat/f8x/f8x` | f8x 安装器主脚本(12800+ 行) |
174210
| `/Users/f0x/pte-project/infra-plat/f8x/f8x_version.sh` | 版本覆盖配置(source 加载,可选) |
175211
| `/Users/f0x/pte-project/infra-plat/f8x/check_releases.py` | 批量检查工具版本更新 |
212+
| `/Users/f0x/pte-project/infra-plat/f8x/generate_catalog.py` | 自动生成 catalog.json(提取 flag、子工具、URL) |
213+
| `/Users/f0x/pte-project/infra-plat/f8x/catalog.json` | 工具目录元数据(供 redc-gui 和 f8x 官网使用) |
176214
| `/Users/f0x/pte-project/infra-plat/f8x/doc/ai-friendly-tool-install-design.md` | AI 友好化改造设计文档 |
177215

178216
## 端到端示例:添加 httpx
@@ -226,13 +264,22 @@ httpx|Pentest_httpx_Install|0
226264

227265
**Step 5** — Arsenal(可选):httpx 是静态二进制,但通常在攻击机本地使用做 HTTP 探测,不需要投递到目标机 → 跳过。
228266

267+
**Step 6** — 重新生成 catalog.json:
268+
```bash
269+
python3 generate_catalog.py ./f8x ./catalog.json
270+
# 检查输出,确认无 "missing URL" 警告
271+
```
272+
httpx 的安装函数里有 `github.com/projectdiscovery/httpx`,URL 会自动提取,无需手动添加 `KNOWN_TOOL_URLS`
273+
229274
## 常见错误
230275

231276
- **版本号不同步**:改了 `xxx_Ver` 但忘了改 `xxx_bin_amd64` 里的版本号 → 下载 404。这是最高频的错误
232277
- **写了函数但忘记注册**:安装函数写好了,但没有在 F8X_TOOL_LIST 里添加条目 → `-install xxx` 找不到工具
233278
- **工具名大小写不匹配**:F8X_TOOL_LIST 里工具名是小写(`nuclei|...`),搜索时也用小写匹配,不要写成大写
234279
- **Arsenal case 块缺 `;;`**:bash case 语法必须以 `;;` 结尾,漏了会导致穿透到下一个分支
235280
- **release 文件名变了没跟进**:上游项目改了 release 命名格式(比如从 `_amd64` 变成 `-amd64`),但 f8x 变量还是旧格式
281+
- **新增工具后忘了重新生成 catalog.json**:redc-gui 软件商店和 f8x 官网不会显示新工具 → 运行 `python3 generate_catalog.py ./f8x ./catalog.json`
282+
- **apt/pip 安装的工具缺 URL**:通过包管理器安装的工具不会自动提取 URL,需要在 `KNOWN_TOOL_URLS` 里手动添加项目地址
236283
- **已安装检测用了 `test -d` 但目录在下载前就创建了**:如果安装函数先 `mkdir -p "$dir"` 再下载,网络失败后目录已存在,重试时 `test -d $dir` 误判为已安装。对于安装到 `$P_Dir/xxx` 目录的工具,应该用 `test -x "$dir/二进制名"` 检查实际二进制文件是否存在,而不是检查目录
237284

238285
## 参考文件

0 commit comments

Comments
 (0)