righettod/toolbox-pentest-web

GitHub: righettod/toolbox-pentest-web

一款基于 Alpine 的轻量级 Docker 渗透测试工具箱,集成了 Web 应用安全评估所需的核心工具、脚本与实战测试素材。

Stars: 184 | Forks: 36

# :factory: 欢迎来到我的数字锻造厂

![MadeWitVSCode](https://img.shields.io/static/v1?label=Made%20with&message=VisualStudio%20Code&color=blue&?style=for-the-badge&logo=textpattern) ![MadeWithDocker](https://img.shields.io/static/v1?label=Made%20with&message=Docker&color=blue&?style=for-the-badge&logo=docker) ![AutomatedWith](https://img.shields.io/static/v1?label=Automated%20with&message=GitHub%20Actions&color=blue&?style=for-the-badge&logo=github) ![AuditedWith](https://img.shields.io/static/v1?label=Audited%20with&message=Snyk&color=blueviolet&?style=for-the-badge&logo=snyk) [![OpenSSFScorecard](https://api.scorecard.dev/projects/github.com/righettod/toolbox-pentest-web/badge)](https://scorecard.dev/viewer/?uri=github.com/righettod/toolbox-pentest-web) 📒 快速访问: * [速查表](docs/README.md)。 * [脚本索引](docs/10-SCRIPTS_INDEX.md)。 🎯 此镜像的目标是提供一个始终保持最新状态的“工具箱”,包含在评估 Web 应用程序(网站、API 等)时非常有用的资料(工具 + 脚本)。 📢 本镜像基于 **[alpine](https://hub.docker.com/_/alpine)** 基础镜像。以前它基于 **[kali-rolling](https://hub.docker.com/r/kalilinux/kali-rolling)** 镜像,但在构建工具箱后,镜像的最终体积实在太大(超过了 14GB)。 📱 最近,我开始添加用于移动端评估的内容,以便将信息/工具集中到一个工具箱中。 🏷️ 带有 `idea` 标签的 [Issues](https://github.com/righettod/toolbox-pentest-web/labels/idea) 包含关于项目/代码/脚本/payload/研究等方面的通用想法,这些想法不一定与工具箱本身直接相关。事实上,由于这个项目是我核心工具箱的锻造厂,我也用它来收集/集中我的想法。 # 🔋 健康状态 ![Check cheat sheet links validity](https://github.com/righettod/toolbox-pentest-web/actions/workflows/check_cheatsheet_external_links.yml/badge.svg?branch=master) ![Check my dictionary of language model prompts](https://github.com/righettod/toolbox-pentest-web/actions/workflows/check_language_model_prompts_dict.yml/badge.svg?branch=master) ![Update OpenSSF scorecard supply-chain security](https://github.com/righettod/toolbox-pentest-web/actions/workflows/update_openssf_scorecard.yml/badge.svg?branch=master) ![Update scripts index](https://github.com/righettod/toolbox-pentest-web/actions/workflows/update_scripts_index.yml/badge.svg?branch=master) ![Update nmap scripts index](https://github.com/righettod/toolbox-pentest-web/actions/workflows/update_nmap_scripts_index.yml/badge.svg?branch=master) ![Build and deploy the toolbox image](https://github.com/righettod/toolbox-pentest-web/actions/workflows/build_docker_image.yml/badge.svg?branch=master) ![Build PostgreSQL extension](https://github.com/righettod/toolbox-pentest-web/actions/workflows/build_pg_extension.yml/badge.svg) ![Build DLL Hijacking library](https://static.pigsec.cn/wp-content/uploads/repos/cas/80/80472acc37c79ecfc8704b09c704344c0f17383b8c70391c9a2c0a49dd6535ef.svg) # 🛠️ 工具箱增强方案 ## 项目 * [SecLists](https://github.com/danielmiessler/SecLists)。 * [Nuclei templates](https://github.com/projectdiscovery/nuclei-templates)。 * [Param-Miner](https://github.com/PortSwigger/param-miner)。 ## 方案 ``` sequenceDiagram participant T as Toolbox participant S as SecLists participant N as Nuclei templates participant P as Param-Miner alt Is a missing discovery dictionary entry T->>S: Propose a PR with the missing element S->>T: Get updates from the GitHub repository once the PR is merged end alt Is a missing detection generic point T->>N: Propose a PR with the missing template N->>T: Get updates from the GitHub repository once the PR is merged end alt Is a missing hidden http parameter/header entry T->>P: Propose a PR with the missing element P->>T: Get updates from the GitHub repository once the PR is merged end alt Is a missing useful existing tool T->>T: Add the tool in a way to always use the latest version end alt Is a missing specific need or without existing tool T->>T: Add a new custom scripts end ``` # 🐳 工具箱生态 我已经创建并维护了几个公开的工具箱(部分作为 Docker 镜像),其中目前的 `toolbox-pentest-web` 是核心工具箱: ``` mindmap root["💻 toolbox-pentest-web"] id1("🔬 toolbox-codescan") id2("📋 toolbox-jwt") id3("🔎 toolbox-regex") id4("🏹 toolbox-patator") id5("🤖 toolbox-ai-assisted-secure-code-review") ``` * [toolbox-pentest-web](https://github.com/righettod/toolbox-pentest-web):用于 Web 应用程序渗透测试的工具箱。 * [toolbox-codescan](https://github.com/righettod/toolbox-codescan):用于对代码库执行**离线**扫描的工具箱。 * [toolbox-jwt](https://github.com/righettod/toolbox-jwt):包含不同脚本的工具箱,旨在对 JWT token 执行各种类型的攻击。 * [toolbox-regex](https://github.com/righettod/toolbox-regex):用于运行 [RegExr](https://github.com/gskinner/regexr) 本地实例以针对敏感/隐私内容创建正则表达式的工具箱。 * [toolbox-patator](https://github.com/righettod/toolbox-patator):用于提供名为 [patator](https://github.com/lanjelot/patator) 工具的且始终保持最新状态的 Docker 镜像的工具箱。 * [toolbox-ai-assisted-secure-code-review](https://github.com/righettod/toolbox-ai-assisted-secure-code-review):包含相关资料的工具箱,用于在编码助手(*claude code*)的帮助下执行安全代码审查。 # 📖 它包含什么? ## 构建 **[build](build)** 文件夹包含用于构建 Docker 镜像的实用内部脚本和资料。 ## 工具 所有工具都安装在文件夹 **/tools** 中,并且通过文件夹 **/tools/reports** 定义了容器与主机之间的传输区。 ## 辅助脚本 **[scripts](scripts)** 文件夹包含了使用内置工具执行某些操作的辅助脚本。 ## 杂项 **[misc](misc)** 文件夹包含可用于测试特定场景的资料,例如当应用程序使用: * [HTTP Signature](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12)。 * [eIDAS 证书和密钥资料](https://digital-strategy.ec.europa.eu/en/policies/eidas-regulation)。 * RSA **弱**密钥对: * [RSA 512 位私钥](misc/rsa-512-private.pem) / [RSA 512 位公钥](misc/rsa-512-public.pem)。 * [RSA 1024 位私钥](misc/rsa-1024-private.pem) / [RSA 1024 位公钥](misc/rsa-1024-public.pem)。 * 接受 Microsoft Office 文档、PDF 文档、SVG 图片等的文件上传功能: * [Excel 97-2003 格式文档](misc/doc-excel-xlsformat-with-vba-macro-exfiltrating-envvars.xls),带有通过 HTTP POST 请求将环境变量外发到指定域名的 VBA 宏。 * [Excel OpenXML 格式文档](misc/doc-excel-openxmlformat-with-vba-macro-exfiltrating-envvars.xlsm),带有通过 HTTP POST 请求将环境变量外发到指定域名的 VBA 宏。 * [Word OpenXML 格式文档](misc/doc-word-openxmlformat-with-vba-macro-exfiltrating-envvars.docm),带有通过 HTTP POST 请求将环境变量外发到指定域名的 VBA 宏。 * [Word 2003 XML 格式文档](misc/doc-word-word2003xmlformat-with-vba-macro-exfiltrating-envvars.xml),带有通过 HTTP POST 请求将环境变量外发到指定域名的 VBA 宏。 * [Word OpenXML 格式文档](misc/doc-word-with-reference-to-doc-template-word-with-vba-macro.docx) (DOCX),引用了一个远程的 [Word OpenXML 格式模板文档](misc/doc-template-word-with-vba-macro.dotm) (DOTM),该模板包含一个用于显示消息框的 VBA 宏。 * 目标是测试在 DOCX 文件上下文中通过引用 DOTM 文件来执行 VBA 宏的能力。 * 子文件 `doc-word-with-reference-to-doc-template-word-with-vba-macro.docx/word/_rels/settings.xml.rels` 中包含以下对 DOTM 文件的引用: ``` ``` * [PDF 文档](misc/doc-pdf-with-link-to-malicious-file.pdf),带有一个被某些防病毒软件或浏览器视为恶意软件的文件链接。 * [PDF 文档](misc/doc-pdf-with-qrcode-to-malicious-file.pdf),带有一个二维码,其中包含被某些防病毒软件或浏览器视为恶意软件的文件链接。 * [PDF 文档](misc/doc-pdf-with-embedded-lazagne-file.pdf),内嵌(附加)了一个被某些防病毒软件或浏览器视为恶意软件的 [LaZagne](https://github.com/AlessandroZ/LaZagne) 构建版本文件。 * [PDF 文档](misc/doc-pdf-with-embedded-netcat-file.pdf),内嵌(附加)了一个被某些防病毒软件或浏览器视为恶意软件的 [NetCat](static-binaries/windows/netcat) 构建版本文件。 * [PDF 文档](misc/doc-pdf-with-embedded-malicious-file.pdf),内嵌(附加)了一个模拟恶意文件的附件。 * [PDF 文档](misc/doc-pdf-with-malicious-files-concatenated.pdf),在分隔符 `[NEWFILE]` 之后拼接了被某些防病毒软件或浏览器视为恶意软件的恶意文件(见下文了解如何从 PDF 中提取该恶意文件)。 * [PDF 文档](misc/doc-pdf-with-js-code.pdf),包含在文档打开时显示警告框的 JS 代码。 * [PDF 文档](misc/doc-pdf-with-js-code-opening-a-url.pdf),包含在文档打开时访问特定 URL 的 JS 代码。 * [PDF 文档](misc/doc-pdf-with-xxe-in-xfa-form.pdf),包含嵌入在 XFA 表单中的 XXE payload(基于 [CVE-2025-54988](https://nvd.nist.gov/vuln/detail/CVE-2025-54988) 和 [POC-CVE-2025-54988](https://github.com/mgthuramoemyint/POC-CVE-2025-54988))。 * [XPS 文档](misc/doc-xps-with-malicious-apps.xps),嵌入了(至少被 [VirusTotal](https://www.virustotal.com/))防病毒软件检测为恶意程序的文件([LaZagne](https://github.com/AlessandroZ/LaZagne) 和 [Mimikatz](https://github.com/gentilkiwi/mimikatz))。 * 带有 XSS payload 的 SVG 图像,不同版本请参见 `misc/doc-test-xss-*.svg` 文件。 * [Java 应用程序](misc/malicious-java-app.jar),编译为支持最低 Java 1.8 运行时的可执行 jar 文件,会向指定域名发送 HTTP GET 请求。 * [Go 应用程序](misc/malicious-go-app.go),作为原生可执行程序,执行向指定域名的 HTTP GET 请求: * [Windows 64 位构建版本](misc/malicious-go-app-windows-amd64.exe)。 * [Linux 64 位构建版本](misc/malicious-go-app-linux-amd64.bin)。 * [VBS 脚本](misc/doc-vbs-exfiltrating-envvars.vbs),通过 HTTP POST 请求将环境变量外发到指定域名。 💻 使用以下代码从 PDF 文件 [doc-pdf-with-malicious-files-concatenated.pdf](misc/doc-pdf-with-malicious-files-concatenated.pdf) 中提取可执行文件([LaZagne.exe](https://github.com/AlessandroZ/LaZagne/releases/tag/v2.4.6)): ``` delimiter = "5b4e455746494c455d" # String "[NEWFILE]" encoded in HEX with open("doc-pdf-with-malicious-files-concatenated.pdf", mode="rb") as f: content_hex = f.read().hex() delimiter_position = content_hex.find(delimiter) bin_file_hex = content_hex[delimiter_position + len(delimiter):] bin_file_bytes = bytes.fromhex(bin_file_hex) with open("malicious-files.exe", mode="wb") as f: f.write(bin_file_bytes[1:]) ``` ## 模板 **[templates](templates)** 文件夹包含多个脚本/文件,可用作自定义脚本的基础,从而加快 POC 的实现。 ## 字典 **[dictionaries](dictionaries)** 文件夹包含多个自制自定义字典,可用于发现(扫描)操作。 ## 技术提示 此**[文件](docs/README.md)**包含针对不同类型上下文/问题/目标的多种技术提示。 💻 这是我自己定制的速查表。 # 🔨 本地构建镜像 使用以下命令集: ``` $ git clone https://github.com/righettod/toolbox-pentest-web.git $ cd toolbox-pentest-web $ docker build . -t righettod/toolbox-pentest-web --file Dockerfile ... ``` # 💡 容器使用方式 ## 在 Docker 主机上直接访问 ### Linux 或 MacOS 上的原生 Docker ``` # 创建 volume 以与 container 共享文件(例如:reports) $ docker volume create --name shared_space $ docker volume inspect shared_space # 运行 container $ docker run -v shared_space:/tools/reports -p 127.0.0.1:80:80 -i -t ghcr.io/righettod/toolbox-pentest-web:master $ docker run -v shared_space:/tools/reports -p 192.168.206.128:80:80 -p 192.168.206.128:443:443 -i -t ghcr.io/righettod/toolbox-pentest-web:master # 将 image 构建到本地缓存 $ docker build -t righettod/toolbox-pentest-web . # 从本地缓存移除 image $ docker rmi -f righettod/toolbox-pentest-web ``` ### Docker for Windows ``` rem Run container and defines a shared folder C:\> docker run -v F:/SharedFolder:/tools/reports -p 127.0.0.1:80:80 -i -t ghcr.io/righettod/toolbox-pentest-web:master ``` ## 远程访问 工具 [ttyd](https://github.com/tsl0922/ttyd) 用于通过浏览器在 TCP `8000` 端口暴露一个 **zsh shell**。当定义了名为 `WEB_SHELL_ACCESS_PASSWORD` 的环境变量时,启动脚本 [container-launcher.sh](container-launcher.sh) 就会使用这种暴露模式。此变量指的是使用用户名 `righettod` 访问容器进行 BASIC 认证时所用的密码。 💡 如果未定义该环境变量,启动脚本将直接启动一个 zsh shell。 ``` $ docker run -p 8000:8000 -e "WEB_SHELL_ACCESS_PASSWORD=MyComplexPassword" ghcr.io/righettod/toolbox-pentest-web:master ttyd 1.7.7 (libwebsockets 4.3.5) tty configuration: ... ``` ``` $ docker run -p 8000:8000 -p 9000:9000 -e "WEB_SHELL_ACCESS_PASSWORD=MyComplexPassword" ghcr.io/righettod/toolbox-pentest-web:master ttyd 1.7.7 (libwebsockets 4.3.5) tty configuration: ... ``` # 📦 容器镜像仓库 镜像每周会通过此[工作流](https://github.com/righettod/toolbox-pentest-web/actions)发布到 [GitHub](https://github.com/righettod/toolbox-pentest-web/pkgs/container/toolbox-pentest-web) 容器镜像仓库中。 🔒 构建证明在[这里](https://github.com/righettod/toolbox-pentest-web/attestations)。 # 🛡️ 安全 * 关于报告漏洞的信息请参考[这里](SECURITY.md)。 * 镜像每周都会由 [Snyk](https://snyk.io/) 进行审计,以检测是否存在任何漏洞。 # 🪟 在 Windows 域环境中进行评估 在此类评估中常用的工具可以通过将以下内容添加到您在此仓库的分支中的脚本 [add-tools.sh](build/add-tools.sh) 中来进行添加: ``` # 添加 NetExec、impacket 和 Responder 工具 python -m pip install impacket aioquic git clone --depth 1 https://github.com/lgandx/Responder.git /tools/Responder python -m pip install git+https://github.com/Pennyw0rth/NetExec CFLAGS="-Wno-int-conversion" python -m pip install netifaces netexec --version python /tools/Responder/Responder.py --version ``` # 🤔 故障排除 ## 在 OpenShift 上的部署问题 ### 遇到的问题及向 ChatGPT 提出的提问 我在一个 OpenShift 实例上部署了一个容器。启动容器的用户并不是 **USER** 指令指定的那个用户。原因是什么? ### ChatGPT 的回答 **根本原因?** OpenShift(与普通的 Docker 或 Kubernetes 不同)**默认情况下不会以镜像中 `USER` 指令指定的用户身份运行容器**。 相反,出于安全原因,**它会在运行时强制使用一个随机的非 root 用户 ID**。 这是因为 **OpenShift 的安全上下文约束(SCC)** —— 尤其是默认名为 **`restricted`** 的 SCC。 **为什么 OpenShift 会覆盖 `USER` 指令?** 在 OpenShift 的 **restricted SCC** 中: * 容器**严禁以 root 身份运行**。 容器**必须以在 pod 启动时动态分配的任意非 root UID 运行**。 * 该 UID **不一定**与您的 Dockerfile(`USER` 指令)中定义的相同。 这种设计确保了: **实际上这意味着什么?** 如果您的 Dockerfile 包含: ``` USER 1001 ``` 并且您将其部署在 OpenShift 上,您的容器可能会以类似 UID `1023840001` 的身份运行。 该 UID: * 在容器内的 `/etc/passwd` 中**没有名称映射**。 * 仍然具有与 `root` 组相同的 **group ID**(GID `0`),除非被覆盖。 * 可以访问属于 `0`(root 组)的文件,这就是为什么许多 OpenShift 镜像在需要可写权限的目录上使用 `chmod g+w` 的原因。 **如何使您的镜像兼容?** 如果您的应用程序需要对某些目录的写入权限,请在您的 Dockerfile 中执行以下操作: ``` # 允许组写入权限 RUN mkdir -p /app && chgrp -R 0 /app && chmod -R g+rwX /app # 切换到非 root 用户 USER 1001 ``` 💡 这可以确保即使 OpenShift 分配了一个任意的 UID,它仍然会属于 group `0`(**root**)并拥有必要的权限。 **总结** | 行为 | 解释 | | -------------------------------------------- | ----------------------------------------------------------------- | | 容器以不同于 `USER` 的用户身份运行 | OpenShift 通过 SCC 强制使用非 root 的随机 UID。 | | 原因 | 安全隔离(防止提权,确保多租户安全)。 | | 解决办法 | 确保文件系统权限为 `g+rwX` 并且归属于 group `0`。 | | 常见的 SCC 名称 | `restricted` |
标签:Cutter, 测试用例, 请求拦截, 逆向工具