PaperMtn/slack-watchman
GitHub: PaperMtn/slack-watchman
一款通过 Slack API 枚举工作区信息并检测泄露秘密与敏感数据的安全审计工具。
Stars: 402 | Forks: 46
# Slack Watchman



监控和枚举 Slack 中暴露的秘密
## 关于 Slack Watchman
Slack Watchman 是一款应用程序,它利用 Slack API 来查找 Slack 工作区中暴露的潜在敏感数据,并为红队、蓝队和紫队枚举其他有用的信息。
有关 Slack Watchman 的更多信息,请参阅[我的博客](https://papermtn.co.uk/slack-watchman-monitoring-slack-workspaces-for-sensitive-information/)。
### 功能特性
#### 秘密检测
Slack Watchman 会查找:
- API 密钥、令牌和服务账户
- AWS、Azure、GCP、Google API、Slack(密钥和 Webhook)、Twitter、Facebook、GitHub 等
- 通用私钥
- 访问令牌、Bearer 令牌、客户端密钥、私有令牌
- 文件
- 证书文件
- 潜在的受关注/恶意/敏感文件(.docm、.xlsm、.zip 等)
- 可执行文件
- Keychain 文件
- 常用服务的配置文件(Terraform、Jenkins、OpenVPN 等)
- 个人数据
- 泄露的密码
- 护照号码、出生日期、社会安全号码、国民保险号码等
- 财务数据
- Paypal Braintree 令牌、银行卡详细信息、IBAN 号码、CUSIP 号码等
#### 基于时间的搜索
您可以运行 Slack Watchman 来查找以下时间范围内的结果:
- 24 小时
- 7 天
- 30 天
- 所有时间
#### 枚举
它还会枚举以下内容:
- 用户数据
- 所有用户和所有管理员
- 会话数据
- 所有会话,包括外部共享的会话
- 所有包含 Slack Canvas 的会话(通常包含敏感或重要信息)
- 工作区身份验证选项
这意味着在一次深度扫描之后,您可以将 Slack Watchman 安排为定期运行,并且仅返回您所选时间范围内的结果。
#### 未认证探测
您可以在未认证探测模式下运行 Slack Watchman,以枚举工作区上的身份验证选项和其他信息。这不需要令牌,并返回:
- 工作区名称
- 工作区 ID
- 已批准的域名(可用于创建账户)
- OAuth 提供商
- SSO 认证状态
- 双因素认证要求
要运行此模式,请使用带有 `--probe` 标志的 Slack Watchman 并指定要探测的工作区域名:
```
slack-watchman --probe https://domain.slack.com
```
### 签名
Slack Watchman 使用自定义的 YAML 签名来检测 Slack 中的匹配项。这些签名是从中央的 [Watchman Signatures 仓库](https://github.com/PaperMtn/watchman-signatures) 拉取的。Slack Watchman 会在运行时自动更新其签名库,以确保使用最新的签名来检测秘密。
#### 禁用签名
您可以通过将签名 ID 添加到 `watchman.conf` 文件的 `disabled_signatures` 部分,来定义在运行 Slack Watchman 时要禁用的签名。例如:
```
slack_watchman:
token: ...
cookie: ...
url: ...
disabled_signatures:
- tokens_generic_bearer_tokens
- tokens_generic_access_tokens
```
您可以在 [Watchman Signatures 仓库](https://github.com/PaperMtn/watchman-signatures) 中的各个 YAML 文件中找到签名 ID。
### 日志记录
Slack Watchman 提供以下日志记录选项:
- 适合终端的 Stdout
- JSON 格式的 Stdout
如果未指定选项,Slack Watchman 默认使用适合终端的 stdout 日志记录。这被设计为更便于人类阅读。
还提供 JSON 日志记录,非常适合导入到 SIEM 或其他日志分析平台。
JSON 格式的日志可以轻松重定向到文件,如下所示:
```
slack-watchman --timeframe a --all --output json >> slack_watchman_log.json
```
## 身份验证要求
### Slack API 令牌
要运行 Slack Watchman,您需要一个 Slack API OAuth 访问令牌。您可以通过创建一个简单的 [Slack App](https://api.slack.com/apps) 来完成此操作。
该应用需要添加以下 **User Token Scopes**:
```
channels:read
files:read
groups:read
im:read
links:read
mpim:read
remote_files:read
search:read
team:read
users:read
users:read.email
```
**注意**:User Token 代表授权它们的用户执行操作,因此我建议您使用服务账户创建并授权此应用,否则该应用将可以访问您的私人对话和聊天。
#### App Manifest
Slack App 可以从 JSON 清单创建,这些清单定义了应用程序的详细信息和要批准的范围。Slack Watchman 的 App Manifest 可以在 [docs/app_manifest.json](/docs/app_manifest.json) 中找到,您可以使用它来加快创建 Slack App 的速度。
### Cookie 认证
或者,Slack Watchman 也可以使用用户的 `d` Cookie 进行身份验证,该 Cookie 存储在每个登录到工作区的用户的浏览器中。
要使用 Cookie 认证,您需要提供 `d` Cookie 以及目标工作区的 URL。然后在运行 Slack Watchman 时需要使用 `--cookie` 标志。
有关 Cookie 认证的更多信息,请参阅[我的博客](https://www.papermtn.co.uk/retrieving-and-using-slack-cookies-for-authentication/)
#### 提供令牌
Slack Watchman 将首先尝试从环境变量中获取 Slack 令牌(如果选择了 Cookie 认证,还包括 Cookie 令牌和 URL):
- `SLACK_WATCHMAN_TOKEN`
- `SLACK_WATCHMAN_COOKIE`
- `SLACK_WATCHMAN_URL`
如果失败,它将尝试从 `.conf` 文件中加载令牌(见下文)。
#### watchman.conf 文件
配置选项可以在名为 `watchman.conf` 的文件中传递,该文件必须存储在您的主目录中。该文件应遵循 YAML 格式,如下所示:
```
slack_watchman:
token: xoxp-xxxxxxxx
cookie: xoxd-%2xxxxx
url: https://xxxxx.slack.com
disabled_signatures:
- tokens_generic_bearer_tokens
- tokens_generic_access_tokens
```
Slack Watchman 将在运行时查找此文件,并使用其中的配置选项。如果您不使用 Cookie 认证,请将 `cookie` 和 `url` 留空。
如果您的 .conf 文件遇到问题,请通过 YAML Linter 运行它。
示例文件位于 `docs/example.conf`
**注意**:Cookie 和 URL 值是可选的,如果不使用 Cookie 认证则不需要。
## 安装
推荐的安装 Slack Watchman 的方法是通过 [`pipx`](https://pypa.github.io/pipx/),它会将应用程序安装在隔离环境中并使其在您的系统 `PATH` 中可用:
```
pipx install slack-watchman
```
**替代方案:通过 pip 安装**
您也可以使用 pip 安装 Slack Watchman:
```
python3 -m pip install slack-watchman
```
**替代方案:从源码构建**
下载发布版源文件,然后从仓库的顶级目录运行:
```
python3 -m pip build
python3 -m pip install --force-reinstall dist/*.whl
```
## Docker 镜像
Slack Watchman 也可以从 Docker Hub 作为 Docker 镜像获取:
`docker pull papermountain/slack-watchman:latest`
然后,您可以在容器中运行 Slack Watchman,确保传递所需的环境变量:
```
// help
docker run --rm papermountain/slack-watchman -h
// scan all
docker run --rm -e SLACK_WATCHMAN_TOKEN=xoxp... papermountain/slack-watchman --timeframe a --all --output json
docker run --rm --env-file .env papermountain/slack-watchman --timeframe a --all --output stdout
```
## 用法
Slack Watchman 将作为全局命令安装,按如下方式使用:
```
usage: slack-watchman [-h] [--timeframe {d,w,m,a}] [--output {json,stdout}] [--version] [--all] [--users] [--channels] [--pii] [--secrets] [--debug] [--verbose] [--cookie] [--probe PROBE_DOMAIN]
Monitoring and enumerating Slack for exposed secrets
options:
-h, --help show this help message and exit
--timeframe {d,w,m,a}, -t {d,w,m,a}
How far back to search: d = 24 hours w = 7 days, m = 30 days, a = all time
--output {json,stdout}, -o {json,stdout}
Where to send results
--version, -v show program's version number and exit
--all, -a Find secrets and PII
--users, -u Enumerate users and output them to .csv in the current working directory
--channels, -c Enumerate channels and output them to .csv in the current working directory
--pii, -p Find personal data: DOB, passport details, drivers licence, ITIN, SSN etc.
--secrets, -s Find exposed secrets: credentials, tokens etc.
--debug, -d Turn on debug level logging
--verbose, -V Turn on more verbose output for JSON logging. This includes more fields, but is larger
--cookie Use cookie auth using Slack d cookie. REQUIRES either SLACK_WATCHMAN_COOKIE and SLACK_WATCHMAN_URL environment variables set, or both values set in watchman.conf
--probe PROBE_DOMAIN Perform an un-authenticated probe on a workspace for available authentication options and other information. Enter workspace domain to probe
```
您可以运行 Slack Watchman 来查找所有内容,并输出到默认的 stdout:
```
slack-watchman --timeframe a --all
```
## 其他 Watchman 应用程序
您可能对 Watchman 系列中的其他应用程序感兴趣:
- [企业网格版 Slack Watchman](https://github.com/PaperMtn/slack-watchman-enterprise-grid)
- [GitLab Watchman](https://github.com/PaperMtn/gitlab-watchman)
- [GitHub Watchman](https://github.com/PaperMtn/github-watchman)
## 许可证
本项目的源代码在 [GNU 通用公共许可证](https://www.gnu.org/licenses/licenses.html#GPL) 下发布。本项目与 Slack Technologies 或 Salesforce 无关。标签:API密钥检测, ASM, AWS密钥, Azure密钥, DLP, GitHub, GitHub Token, meg, PII, Python, SaaS安全, Slack, Slack API, 个人信息保护, 企业安全, 信息安全, 凭证审计, 威胁情报, 安全助手, 安全合规, 密码泄露, 开发者工具, 开源安全工具, 文件监控, 无后门, 机密数据发现, 紫队, 网络代理, 网络资产管理, 请求拦截, 输入验证, 逆向工具, 逆向工程平台