Nosey Parker是一个命令行程序,可以在文本数据和Git历史中找到秘密和敏感信息。
作者:Sec-Labs | 发布时间:
项目地址
https://github.com/praetorian-inc/noseyparker
Nosy Parker:在文本数据中寻找秘密
Nosy Parker 是一个命令行工具,可以在文本数据中查找秘密和敏感信息。它对于进攻性和防御性安全测试都很有用。
主要特征:
- 它支持扫描文件、目录和 Git 存储库的整个历史
- 它使用正则表达式与一组 90 种模式进行匹配,这些模式是根据攻击性安全活动的经验和反馈选择的高信噪比
- 它将共享相同秘密的匹配分组在一起,进一步强调信号而不是噪声
- 速度很快:它可以在单核上以每秒数百兆字节的速度进行扫描,并且能够在较旧的 MacBook Pro 上在不到 2 分钟的时间内扫描 100GB 的 Linux 内核源代码历史记录
Nosy Parker 的这个开源版本是内部版本的重新实现,该版本经常用于Praetorian的进攻性安全活动。内部版本具有额外的误报抑制功能和基于机器学习的替代检测引擎。在此处和此处的博客文章中阅读更多内容。
从源头构建
1.(在 x86_64 上)为您的系统安装Hyperscan库和头文件
在使用 Homebrew 的 macOS 上:
brew install hyperscan pkg-config
在 Ubuntu 22.04 上:
apt install libhyperscan-dev pkg-config
1.(在非 x86_64 上)从源代码构建Vectorscan
您将需要几个依赖项,包括cmake、boost、ragel和pkg-config。
下载并提取Vectorscan 5.4.8 版本的源代码:
wget https://github.com/VectorCamp/vectorscan/archive/refs/tags/vectorscan/5.4.8.tar.gz && tar xfz 5.4.8.tar.gz
使用 cmake 构建:
cd vectorscan-vectorscan-5.4.8 && cmake -B build -DCMAKE_BUILD_TYPE=Release . && cmake --build build
设置HYPERSCAN_ROOT环境变量,以便 Nosy Parker 针对您的 Vectorscan 源代码构建进行构建:
export HYPERSCAN_ROOT="$PWD/build"
注意: Nosy ParkerDockerfile从源代码构建 Vectorscan 并对其进行链接。
2. 安装 Rust 工具链
cargo build --release
这将在target/release/noseyparker.
Docker使用
预构建的 Docker 映像可用于 x86_64 的最新版本:
docker pull ghcr.io/praetorian-inc/noseyparker:latest
预构建的 Docker 映像可用于 x86_64 的最新提交:
docker pull ghcr.io/praetorian-inc/noseyparker:edge
对于其他架构(例如 ARM),您需要自己构建 Docker 镜像:
docker build -t noseyparker .
使用已安装的卷运行 Docker 映像:
docker run -v "$PWD":/opt/ noseyparker
注意: Docker 映像的运行速度明显低于本机二进制文件,尤其是在 macOS 上。
使用快速入门
数据存储
大多数 Nosy Parker 命令都使用数据存储。这是 Nosy Parker 用来记录其发现并维护其内部状态的特殊目录。如果需要,命令将隐式创建数据存储scan。您还可以使用该命令显式创建数据存储datastore init -d PATH。
扫描文件系统内容以查找机密
Nosy Parker 内置支持扫描文件、递归扫描目录和扫描 Git 存储库的整个历史记录。
例如,如果您在本地有一个CPythoncpython.git的 Git 克隆,您可以使用scan命令扫描它的整个历史记录。Nosy Parker 将创建一个新的数据存储np.cpython并将其发现保存在那里。
$ noseyparker scan --datastore np.cpython cpython.git
Found 28.30 GiB from 18 plain files and 427,712 blobs from 1 Git repos [00:00:04]
Scanning content ████████████████████ 100% 28.30 GiB/28.30 GiB [00:00:53]
Scanned 28.30 GiB from 427,730 blobs in 54 seconds (538.46 MiB/s); 4,904/4,904 new matches
Rule Distinct Groups Total Matches
───────────────────────────────────────────────────────────
PEM-Encoded Private Key 1,076 1,192
Generic Secret 331 478
netrc Credentials 42 3,201
Generic API Key 2 31
md5crypt Hash 1 2
Run the `report` command next to show finding details.
按 URL、GitHub 用户名或 GitHub 组织名称扫描 Git 存储库
Nosy Parker 还可以扫描尚未克隆到本地文件系统的 Git 存储库。、和选项允许您指定感兴趣的存储库--git-url URL。--github-user NAME``--github-org NAME``scan
例如,要扫描 Nosy Parker 存储库本身:
$ noseyparker scan --datastore np.noseyparker --git-url https://github.com/praetorian-inc/noseyparker
例如,扫描属于以下的可访问存储库octocat:
$ noseyparker scan --datastore np.noseyparker --github-user octocat
如果在环境变量中可用,这些输入说明符将使用可选的 GitHub 令牌NP_GITHUB_TOKEN。提供访问令牌可提供更高的 API 速率限制,并可能使您可以访问其他存储库。
noseyparker help scan有关详细信息,请参阅。
总结调查结果
Nosy Parker 在完成扫描后打印出其发现的摘要。您也可以单独运行此步骤:
$ noseyparker summarize --datastore np.cpython
Rule Distinct Groups Total Matches
───────────────────────────────────────────────────────────
PEM-Encoded Private Key 1,076 1,192
Generic Secret 331 478
netrc Credentials 42 3,201
Generic API Key 2 31
md5crypt Hash 1 2
通过选项支持其他输出格式,包括 JSON 和 JSON 行--format=FORMAT。
报告详细调查结果
要查看 Nosy Parker 发现的详细信息,请使用report命令。这将打印出一份专为人类消费而设计的基于文本的报告:
$ noseyparker report --datastore np.cpython
Finding 1/1452: Generic API Key
Match: QTP4LAknlFml0NuPAbCdtvH4KQaokiQE
Showing 3/29 occurrences:
Occurrence 1:
Git repo: clones/cpython.git
Blob: 04144ceb957f550327637878dd99bb4734282d07
Lines: 70:61-70:100
e buildbottest
notifications:
email: false
webhooks:
urls:
- https://python.zulipchat.com/api/v1/external/travis?api_key=QTP4LAknlFml0NuPAbCdtvH4KQaokiQE&stream=core%2Ftest+runs
on_success: change
on_failure: always
irc:
channels:
# This is set to a secure vari
Occurrence 2:
Git repo: clones/cpython.git
Blob: 0e24bae141ae2b48b23ef479a5398089847200b3
Lines: 174:61-174:100
j4 -uall,-cpu"
notifications:
email: false
webhooks:
urls:
- https://python.zulipchat.com/api/v1/external/travis?api_key=QTP4LAknlFml0NuPAbCdtvH4KQaokiQE&stream=core%2Ftest+runs
on_success: change
on_failure: always
irc:
channels:
# This is set to a secure vari
...
(注意:上面的发现是合成的、无效的秘密。)通过该选项支持其他输出格式,包括 JSON 和 JSON 行--format=FORMAT。
从 GitHub 枚举存储库
要列出属于 GitHub 用户或组织的存储库的 URL,请使用github repos list命令。此命令使用 GitHub REST API 枚举属于一个或多个用户或组织的存储库。例如:
$ noseyparker github repos list --user octocat
https://github.com/octocat/Hello-World.git
https://github.com/octocat/Spoon-Knife.git
https://github.com/octocat/boysenberry-repo-1.git
https://github.com/octocat/git-consortium.git
https://github.com/octocat/hello-worId.git
https://github.com/octocat/linguist.git
https://github.com/octocat/octocat.github.io.git
https://github.com/octocat/test-repo1.git
可以通过环境变量提供可选的 GitHub 个人访问令牌NP_GITHUB_TOKEN。提供访问令牌可提供更高的 API 速率限制,并可能使您可以访问其他存储库。
通过选项支持其他输出格式,包括 JSON 和 JSON 行--format=FORMAT。
noseyparker help github有关详细信息,请参阅。
获得帮助
运行noseyparker不带参数的二进制文件会打印顶级帮助并退出。您可以通过运行获得特定命令的缩写帮助noseyparker COMMAND -h。
help提示:使用命令或长格式--help选项可以获得更详细的帮助。