praetorian-inc/gato

GitHub: praetorian-inc/gato

一款针对 GitHub Actions CI/CD 流水线的枚举与攻击工具,帮助识别 Self-Hosted Runner 配置漏洞及 Artifacts 中的敏感信息泄露,支持从信息收集到漏洞利用的完整攻击链路。

Stars: 732 | Forks: 65

![支持的 Python 版本](https://img.shields.io/badge/python-3.7+-blue.svg) # Gato (Github Attack TOolkit)

gato

Gato,即 GitHub Attack Toolkit,是一款枚举和攻击工具,允许蓝队和进攻性安全从业人员识别并利用 GitHub 组织公开和私有仓库中的 pipeline 漏洞。 除了枚举功能(用于识别公开仓库中的中毒 pipeline 执行漏洞和 Actions artifacts 泄露的 secrets)外,该工具还具备后渗透功能,以利用被泄露的个人访问令牌。 GitHub 建议仅将 self-hosted runners 用于私有仓库,然而,仍有成千上万的组织在使用 self-hosted runners。默认配置通常存在漏洞,Gato 结合工作流文件分析和运行日志分析,能够大规模识别潜在的可利用仓库。 ## 版本 1.7 Gato 版本 1.7 引入了 **Actions Artifacts Secrets Scanner**。 Actions Artifacts Secrets Scanner 会对 [GitHub Actions workflow artifacts](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow) 进行 secrets 枚举。Praetorian 的研究人员利用该扫描器在几个著名的开源项目中识别出了关键漏洞。一旦披露流程完成,这些漏洞的详情将会被发布。这项工作最初受到了 [Palo Alto Networks](https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/) 研究的启发。 Actions Artifacts Secrets Scanner 执行以下操作: 1. 从目标仓库下载 GitHub Actions workflow artifacts 2. 递归解压下载的 artifacts 3. 使用 [NoseyParker](https://github.com/praetorian-inc/noseyparker) 扫描 artifacts 中的 secrets 4. 报告结果 必须在运行 Actions Artifacts Secrets Scanner 的系统 $PATH 中安装 [NoseyParker](https://github.com/praetorian-inc/noseyparker/releases)。 公开 workflow artifacts 中的 secrets 可能包含许多误报。默认情况下,Actions Artifacts Secrets Scanner 会排除与常见误报相关的规则和结果。若要包含所有 secrets 扫描结果,可以使用 `--include_all_artifact_secrets` 标志。 下面是一个命令示例,它对 GitHub 组织列表运行 Actions Artifacts Secrets Scanner,禁用 self-hosted runner 枚举,包含所有 artifact secret 结果,并输出到 JSON 文件。 ``` gato e --enum_wf_artifacts --include_all_artifact_secrets --skip_sh_runner_enum -O testorgs.txt -oJ testorgoutput.json ``` 默认情况下,为了减少在单个仓库上花费的时间,Actions Artifacts Secrets Scanner 施加了以下限制: - 每个名称仅下载一个 artifact - 每个仓库最多下载 50 个 artifacts - 最多下载 10 个大于 536 MB 的文件 - 不下载任何大于 2.68 GB 的文件 这些约束经过了优化,以便 Actions Artifacts Secrets Scanner 可以在 48 小时内扫描前 200 名的 GitHub 组织。如果你想修改这些约束,可以在 `gato/enumerate/repository.py` 的 `scan_wf_artifacts()` 函数中更新它们。 ## 新功能 - 新增 Actions Artifacts Secrets Scanner - 支持对 GitHub 组织列表运行模块 - 能够禁用 self-hosted runner 枚举 - 禁用 sleep 的选项 - 在输出中区分公开和私有仓库 - 若干 bug 修复 - 对 GitHub App Installation tokens 的枚举支持 ## 适用人群? - 希望了解被泄露的经典 PAT 能为攻击者提供何种访问权限的安全工程师 - 希望针对 self-hosted runner 攻击建立检测机制的蓝队 - 红队成员 - 希望在利用 self-hosted runner 的组织上尝试证明 RCE 的漏洞猎人 ## 功能 * GitHub Classic PAT 权限枚举 * 基于 GitHub Code Search API 的枚举 * SourceGraph 搜索枚举 * GitHub Action 运行日志解析以识别 Self-Hosted Runners * 批量仓库稀疏克隆功能 * GitHub Action Workflow 解析 * 自动创建命令执行的 Fork PR * 自动创建命令执行的 Workflow * 自动 workflow secrets 窃取 * SOCKS5 代理支持 * HTTPS 代理支持 * GitHub Actions Workflow Artifacts Secrets 扫描 ## 快速开始 ### 安装 Gato 支持 OS X 和 Linux,要求至少 **Python 3.7**。 要安装该工具,只需克隆仓库并使用 `pip install`。我们建议在虚拟环境中执行此操作。 ``` git clone https://github.com/praetorian-inc/gato cd gato python3 -m venv venv source venv/bin/activate pip install . ``` Gato 还要求安装 `git` 版本 `2.27` 或更高版本,并将其添加到系统的 PATH 中。为了运行 fork PR 攻击模块,还必须安装 `sed` 并将其存在于系统路径中。 #### 开发分支 我们维护着一个开发分支,其中包含尚未添加到 main 分支的较新 Gato 功能。遇到 bug 的几率会增加;然而,我们仍然在 `dev` 分支上运行集成测试套件,因此不应该存在 _明显的_ bug。 如果你想使用 `dev` 分支,只需在运行 pip install 之前将其检出——就这样! 如果你确实在特定用例中遇到了任何 bug,请务必提出 issue! ### 使用 安装该工具后,可以通过运行 `gato` 或 `praetorian-gato` 来启动它。 我们建议使用 `gato -h` 查看基础工具的参数,并通过运行以下命令查看工具各模块的参数: * `gato search -h` * `gato enum -h` * `gato attack -h` 该工具需要 GitHub classic 或 app installation token 才能运行。要创建一个,请登录 GitHub 并转到 [GitHub Developer Settings](https://github.com/settings/tokens),选择 `Generate New Token`,然后选择 `Generate new token (classic)`。 创建此 token 后,通过运行 `export GH_TOKEN=` 在 shell 中设置 `GH_TOKEN` 环境变量。或者,将 token 存储在安全的密码管理器中,并在应用程序提示时输入。 如果创建 GitHub App Installation token,该 app 需要至少具有 `Actions:read` 和 `Contents:read` 权限才能执行枚举模块。 有关故障排除和更多详细信息,例如以开发者模式安装或运行单元测试,请参阅 [wiki](https://github.com/praetorian-inc/gato/wiki)。 ## 文档 请参阅 [wiki](https://github.com/praetorian-inc/gato/wiki) 获取详细文档,以及该工具各种模块的 [OpSec](https://github.com/praetorian-inc/gato/wiki/opsec) 注意事项! ## Bugs 如果你认为在软件中发现了 bug,请打开一个 issue,其中包含工具的输出以及你试图执行的操作。 如果你不确定该行为是否是 bug,请改用讨论区! ## 许可证 Gato 根据 [Apache License, Version 2.0](LICENSE) 获得许可。 ``` Copyright 2023 Praetorian Security, Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```
标签:CI/CD安全, DevSecOps, GitHub Actions, GitHub安全, Llama, PaaS安全, Python, StruQ, 上游代理, 协议分析, 工件扫描, 无后门, 机密泄露检测, 权限提升, 枚举工具, 管道攻击, 网络安全研究, 自动笔记, 自托管Runner