righettod/toolbox-jwt

GitHub: righettod/toolbox-jwt

一个以 Docker 镜像形式打包的 JWT 安全测试工具箱,集成了多种针对 JWT 令牌的攻击脚本以简化渗透测试环境配置。

Stars: 6 | Forks: 0

# 💻 JWT 工具箱 [![构建并部署工具箱镜像](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/5f8b31f194102955.svg)](https://github.com/righettod/toolbox-jwt/actions/workflows/build_docker_image.yml) ![MadeWitVSCode](https://img.shields.io/static/v1?label=Made%20with&message=VisualStudio%20Code&color=blue&?style=for-the-badge&logo=visualstudio) ![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) ## 🎯 描述 该镜像的目标是提供一个开箱即用的工具箱,其中包含各种脚本,旨在针对 [JWT](https://jwt.io/) token 执行不同类型的攻击。 💡 实际上,一些现有的脚本需要特定的 runtime/package/etc.,因此我们的目标是提供一个快速且开箱即用的沙盒来执行它们,从而获取经过特殊构造的 JWT token。 ## 📦 构建 使用以下命令集来构建该工具箱的 Docker 镜像: ``` git clone https://github.com/righettod/toolbox-jwt.git cd toolbox-jwt docker build . -t righettod/toolbox-jwt ``` 💡 该镜像每周都会构建并推送到 GitHub 镜像仓库。你可以使用以下命令来获取它: `docker pull ghcr.io/righettod/toolbox-jwt:main` ## 👨‍💻 使用说明 使用以下命令来创建该工具箱的容器: ``` docker run --rm -it ghcr.io/righettod/toolbox-jwt:main /bin/zsh # 从这里开始,使用提供的 script 之一... ``` ## 💡 针对 HMAC 密钥的离线暴力破解操作 要对 HMAC 密钥执行离线暴力破解操作,请使用这些 [JohnTheRipper 包](https://github.com/openwall/john-packages) 中的一个。 💻 使用方法: ``` john tokens.txt --wordlist=rockyou.txt --rules=best64 --format="HMAC-SHA256" john tokens.txt --show ``` ## 📋 内容 ### 脚本 'generate-jwt-ecdsa-derivated-public-keys.rb' 该脚本用于从经 ECDSA 签名的 JWT token 中生成派生的 **ECDSA** 公钥。其目的是测试使用 ECDSA 密钥对的 token 是否容易受到算法混淆攻击。 💻 使用方法: `ruby generate-jwt-ecdsa-derivated-public-keys.rb "JWT_ECDSA_SIGNED_TOKEN"` 💻 示例: ``` # 进入 toolbox 的 bash 后 ruby generate-jwt-ecdsa-derivated-public-keys.rb "eyJ0eXA..." [+] Key: -----BEGIN PUBLIC KEY----- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE6mWiWnAqBhDvAWwyiM7+STTq0Csi spjd61v7AtpvgKMyOHVMxMQ6yyrjVKp/syHteGSeltXdfEQ0Dlv0tkZQqg== -----END PUBLIC KEY----- [+] Key: -----BEGIN PUBLIC KEY----- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7zuf4prcB/qW4AL7d20LSb99Zwwl hRSCnHTrpnHUnXoqZVAGwCNpYSJf1rpjZQocwwEL016+OuspiQ67N9EDoA== -----END PUBLIC KEY----- ``` ### 脚本 'generate-jwt-rsa-derivated-public-keys.sh' 该脚本用于从经 RSA 签名的 JWT token 中生成派生的 **RSA** 公钥。其目的是测试使用 RSA 密钥对的 token 是否容易受到算法混淆攻击。 💻 使用方法: `bash generate-jwt-rsa-derivated-public-keys.sh "JWT_RSA_SIGNED_TOKEN_1" "JWT_RSA_SIGNED_TOKEN_2"` 💻 示例: ``` # 进入 toolbox 的 bash 后 bash generate-jwt-rsa-derivated-public-keys.sh "eyJ0eXA..." "eyJ0eXA..." [*] GCD: 0x6b [*] GCD: 0xd7b8aa3... [+] Found n with multiplier 1 : 0xd7b8aa... [+] Written to d7b8aa3fc15ccb45_65537_x509.pem [+] Tampered JWT: b'eyJ0eXAiOiJ...' [+] Written to d7b8aa3fc15ccb45_65537_pkcs1.pem [+] Tampered JWT: b'eyJ0eXAiOiH...' ============================================================== Here are your JWT's once again for your copypasting pleasure ============================================================== eyJ0eXAiOiJKV1Qi... eyJ0eXAiOiJKV1Qj... ``` ### 脚本 'apply-jwt-ticarpi-attack-playbook.sh' 该脚本用于针对 Web 服务测试 [TICARPI 攻击手册](https://github.com/ticarpi/jwt_tool/wiki/Attack-Methodology) ❤。 💻 使用方法: `bash apply-jwt-ticarpi-attack-playbook.sh "ENDPOINT_FULL_URL" "CANARY_WORD" "VALID_JWT_TOKEN"` 📍 **canary word**(金丝雀词)是当 JWT token 被接受时,在 HTTP 响应中必须出现的一个词(区分大小写)。 💬 JWT token 会被添加到这个请求头 `Authorization: Bearer $TOKEN` 中。如果需要,请编辑脚本以更改其位置。 💡 将上述命令与 ` | grep --color=always -F "Response Code: 200"` 结合使用,可以仅显示 JWT token 被接受的请求。 💻 示例: ``` # 进入 toolbox 的 bash 后 bash apply-jwt-ticarpi-attack-playbook.sh "https://righettod.eu/api/profile" "righettod" "eyJ0eXA..." ... ``` ## 🤝 来源与致谢 * * * * * * * * * * * * * *
标签:Docker, JWT, 安全防御评估, 应用安全, 脚本工具箱, 请求拦截