Skip to content

ygp4ph/AS-REP-Roasting

Repository files navigation

Création du Challenge Kerberos Roasting

Ce document décrit l'infrastructure mise en place pour le challenge CTF "Authentication Service Response", détaille la correction apportée au fichier de capture, et fournit la preuve de sa résolubilité.

1. Infrastructure et Configuration

Le challenge repose sur un serveur Kerberos (KDC) hébergé sur un routeur Alpine Linux et un client Windows 11.

KDC (Alpine Linux)

  • OS : Alpine Linux
  • Paquets : krb5, krb5-server, krb5-server-ldap
  • Fichier de configuration : /etc/krb5.conf
routeur:~# cat /etc/krb5.conf
[libdefaults]
    default_realm = BHACK.LOCAL
    # Indispensable pour autoriser le RC4 (etype 23)
    allow_weak_crypto = true
    # On force l'usage du RC4 pour le challenge
    permitted_enctypes = rc4-hmac
    default_tgs_enctypes = rc4-hmac
    default_tkt_enctypes = rc4-hmac
    rdns = false

[realms]
    BHACK.LOCAL = {
        kdc = 192.168.56.1
        admin_server = 192.168.56.1
    }

[domain_realm]
    .bhack.local = BHACK.LOCAL
    bhack.local = BHACK.LOCAL

et /var/lib/krb5kdc/kdc.conf

routeur:~# cat /var/lib/krb5kdc/kdc.conf
[kdcdefaults]
    kdc_ports = 88
    kdc_tcp_ports = 88

[realms]
    BHACK.LOCAL = {
        database_name = /var/lib/krb5kdc/principal
        admin_keytab = /var/lib/krb5kdc/kadm5.keytab
        acl_file = /etc/krb5kdc/kadm5.acl
        key_stash_file = /var/lib/krb5kdc/.k5.BHACK.LOCAL
        supported_enctypes = rc4-hmac:normal
        # On retire +preauth pour que les nouveaux comptes soient "roastables" par défaut
        # Ou on le laisse et on le retirera par utilisateur
        default_principal_flags = -preauth
    }

La Vulnérabilité (Le Downgrade)

L'objectif est de permettre une attaque AS-REP Roasting.

  1. Utilisateur : jacob
  2. Configuration : Désactivation de la pré-authentification (requires_preauth 0) et autorisation du chiffrement faible (RC4/etype 23).

Commande de création : kadmin.local -q "add_principal -requires_preauth 0 jacob" avec le mdp marty123

Client (Windows 11)

Utilisation du client MIT Kerberos for Windows.

  • Configuration : C:\ProgramData\MIT\Kerberos5\krb5.ini. Notez l'option allow_weak_crypto = true nécessaire pour autoriser l'etype 23.
[libdefaults]
    default_realm = BHACK.LOCAL
    allow_weak_crypto = true

[realms]
    BHACK.LOCAL = {
        kdc = 192.168.56.1
        admin_server = 192.168.56.1
    }

[domain_realm]
    .bhack.local = BHACK.LOCAL
    bhack.local = BHACK.LOCAL
  • Hosts : 192.168.56.1 bhack.local ajouté dans C:\Windows\System32\drivers\etc\hosts.
  • Génération de trafic depuis la GUI de MIT Kerberos

1771026558829

Capture

Le trafic a été capturé sur le routeur Alpine via tcpdump -i any -w Capture_originale.pcap.


2. Correction et Injection du Hash

Lors de la vérification du challenge, le hash capturé initialement était inexploitable. Pour garantir la solvabilité, nous avons régénéré un hash valide et l'avons injecté dans la capture.

Scripts Utilisés

A. Générateur de Hash (generate_hash_impacket.py)

Génère un hash Kerberos 5 AS-REP etype 23 valide (RC4-HMAC) avec une structure ASN.1 correcte via impacket et pyasn1.

B. Injecteur de PCAP (inject_pcap.py)

Utilise scapy pour injecter le hash valide dans le paquet AS-REP du fichier kerberos.pcap original.


3. Preuve de Résolution (Proof of Concept)

Voici la preuve que le challenge Bhack2TheFuture.pcap est solvable avec Hashcat v7.1.2 en mode 18200.

venv ~/Documents/Ynov/yday/kerberos $ hashcat -m 18200 hash.txt hash/rockyou.txt --potfile-disable
hashcat (v7.1.2) starting

HIP API (HIP 7.2.26043)
=======================
* Device #01: AMD Radeon Graphics, 7607/7611 MB, 6MCU

OpenCL API (OpenCL 2.1 AMD-APP.dbg (3581.0)) - Platform #1 [Advanced Micro Devices, Inc.]
=========================================================================================
* Device #02: AMD Radeon Graphics, skipped

Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 256
Minimum salt length supported by kernel: 0
Maximum salt length supported by kernel: 256

Hashes: 1 digests; 1 unique digests, 1 unique salts
Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
Rules: 1

Optimizers applied:
* Zero-Byte
* Not-Iterated
* Single-Hash
* Single-Salt

ATTENTION! Pure (unoptimized) backend kernels selected.
Pure kernels can crack longer passwords, but drastically reduce performance.
If you want to switch to optimized kernels, append -O to your commandline.
See the above message to find out about the exact limits.

Watchdog: Temperature abort trigger set to 90c

Host memory allocated for this attack: 564 MB (8227 MB free)

Dictionary cache built:
* Filename..: hash/rockyou.txt
* Passwords.: 14344391
* Bytes.....: 139921497
* Keyspace..: 14344384
* Runtime...: 1 sec

$krb5asrep$23$jacob@BHACK.LOCAL:261f17155772ee636cf16310deefba7f$e7452a1cc8611e4a489b121e9e30ab681600f41683ebcaff2441ef7762d1769042a28ec670770c58b33e2a6d70792d4e37066abdd68ce09700d08c20730e666b2a55202133ee98c62291b60953819b0eecffe871bba7610adc6bd8fc69ecdc476d9bae90a933c0809d096964e63e2e9a7bea06e9e267ac8b5fcb817135b108758438477e92314f0cb55719cc3a40768ead61dc27b737d710ff35872e5bde929f52c5f4450b80c44b9454c8c4966b9c:marty123
                                                    
Session..........: hashcat
Status...........: Cracked
Hash.Mode........: 18200 (Kerberos 5, etype 23, AS-REP)
Hash.Target......: $krb5asrep$23$jacob@BHACK.LOCAL:261f17155772ee636cf...966b9c
Time.Started.....: Sat Feb 14 00:21:57 2026 (0 secs)
Time.Estimated...: Sat Feb 14 00:21:57 2026 (0 secs)
Kernel.Feature...: Pure Kernel (password length 0-256 bytes)
Guess.Base.......: File (hash/rockyou.txt)
Guess.Queue......: 1/1 (100.00%)
Speed.#01........: 10187.5 kH/s (9.95ms) @ Accel:1024 Loops:1 Thr:32 Vec:1
Recovered........: 1/1 (100.00%) Digests (total), 1/1 (100.00%) Digests (new)
Progress.........: 196608/14344384 (1.37%)
Rejected.........: 0/196608 (0.00%)
Restore.Point....: 0/14344384 (0.00%)
Restore.Sub.#01..: Salt:0 Amplifier:0-1 Iteration:0-1
Candidate.Engine.: Device Generator
Candidates.#01...: 123456 -> piggy!
Hardware.Mon.#01.: Temp: 57c Fan:  0% Util: 99% Core:2200MHz Mem: 800MHz Bus:16

Started: Sat Feb 14 00:21:55 2026
Stopped: Sat Feb 14 00:21:58 2026

4. Solution (Writeup)

5. Format du Flag

Le flag est au format : MartyMcFlag{UserPrincipalName:Password}

  • UserPrincipalName : Sensible à la casse (ex: user@REALM.LOCAL)
  • Password : Le mot de passe trouvé

MartyMcFlag{jacob@BHACK.LOCAL:marty123}

About

Un challenge de CTF de réseau dans lequel il faut cracker une authentification kerberos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages