Writeups
  • ℹ️Infos
  • 🗓️2021
    • DvCTF (to join DaVinciCode)
      • Crypto
        • Baby RSA
        • Ressaye
        • Unbreakable encryption
      • Forensics
        • Broken Portrait
        • Russian Dolls
        • Sus USB
      • Misc
        • Jus de Flag
        • Welcome
      • OSINT
        • Absolutely Nuts
      • Progra
        • Snoop's Mission
      • Reverse
        • Baby Reverse
        • Basic Cracking
        • Code Pyn
      • Steganography
        • Colorful Code
        • Hurt Your Eyes
        • Orchestra of Flags
        • Tyger
      • Web
        • Have I Been Pwned
        • What's Up ?
  • 🗓️2022
    • DvCTF 2022
      • Crypto
        • Cwryptographic Owacle
        • Secure Or Not Secure
        • small weiner
      • Forensics
        • Very Bad Script
      • Misc
        • Data Leak
        • Going postal
        • The Hacker Man
      • OSINT
        • Elon Musk
        • Monkeey
        • Painting Spot
        • Welcome to the DaVinciCTF!
      • Pentest
        • DaVinci's Playlist : Part 1
        • DaVinci's Playlist : Part 2.5
        • DaVinci's Playlist : Part 2
      • Programming
        • Heaven's Gate
        • Sudoku
        • TicTacToe
      • Reverse
        • CryptoVault
        • Mine Game
        • Obfuscated
        • Peripheral Interface Controller XVI
      • Steganography
        • ICMP
        • The Arts of Details
        • Treasure
      • Warmup
        • EBG13
        • FrenchFlag
        • MP3
        • QmFzZTY0
        • RSA
        • Welcome
      • Web
        • CyberStreak v1.0
        • 🎵
    • picoCTF 2022
      • Challs WU
    • @HackDay - Qualifications
      • Crypto
        • Francis Bacon
        • Francs Maçons
        • Rotate-me!
        • Un message codé ?
      • Forensics
        • bad_timing_for_reversing
      • Hardware
        • Cubik'cipher
        • WebSDR
      • Reverse
        • Calling Conventions
        • Memory Investigation
      • Steganography
        • I can make pictures
        • J'ai perdu le flag :(
        • Pokémons
        • Un coup de maître
        • Un logo cachotier
      • Web
        • GIT!
        • Part. 1 - Uploads
        • Part. 2 - Old md5
        • Part. 3 - sudo python
    • 404CTF
      • Crypto
        • Un simple oracle [1/2]
        • Un simple oracle [2/2]
      • Misc
        • Je suis une théière
        • Pierre-papier-Hallebarde
        • GoGOLFplex
      • OSINT
        • À l'aube d'un échange
        • Collaborateur suspect
        • Equipement désuet
      • Reverse
        • Mot de passe ?
      • Steganography
        • La plume à la main
        • PNG : Un logo obèse [1/4]
        • PNG : Drôles de chimères [2/4]
        • Toujours obèse [3/4]
      • Web
        • Fiché JS
        • Le braquage
        • Du gâteau
        • En construction !
    • Operation Kernel
      • Crypto
        • Scytale
      • Forensics
        • Research Paper
        • Excel Confidential
      • Reverse
        • CryptoLocker
        • What_If_CryptoLocker
      • Social Engineering
        • Pour vivre secure vivons caché
        • Pour vivre secure vivons caché Part 2
      • Stegano
        • AudioSpectre
        • Datacenter
        • Takazume
      • WEB
        • Research paper blog
        • SQL Project 1
        • SQL Project 2
        • SQL Project 3
        • Tenue de soirée requise
  • 🗓️2023
    • 404CTF 2023
      • Résultats
      • Analyse forensique
        • Pêche au livre
        • Le Mystère du roman d'amour
        • Les Mystères du cluster de la Comtesse de Ségur [1/2]
        • Lettres volatiles
        • Note de bas de page
      • Cloud
        • Le Sot
        • Le Cluster de Madame Bovary
        • Harpagon et le magot
        • Les nuages menaçants 1/3
        • Les nuages menaçants 2/3
      • Cryptanalyse
        • Recette
        • ASCON Marchombre
      • Divers
        • Bienvenue
        • Exemple de connexion à distance
        • Discord
        • À vos plumes !
      • Exploitation de binaires
        • Je veux la lune !
      • Programmation
        • L'Inondation
        • Des mots, des mots, des mots
      • Radio-Fréquence
        • Navi
        • Avez-vous vu les cascades du hérisson ?
        • Le Plombier du câble
        • Ballistic Missile Submarine
      • Renseignement en sources ouvertes
        • Le Tour de France
        • Les OSINTables [1/3]
        • Un vol ?
        • L'âme d'un poète et le coeur d'une femme [1/4]
        • L'âme d'un poète et le coeur d'une femme [2/4]
        • L'âme d'un poète et le coeur d'une femme [3/4]
        • L'âme d'un poète et le coeur d'une femme [4/4]
      • Rétro Ingénierie
        • Le Divin Crackme
        • L'Inspiration en images
      • Sécurité Matérielle
        • Un courrier suspect
        • Un réveil difficile
      • Stéganographie
        • Odobenus Rosmarus
        • L'Œuvre
        • Les Félicitations
        • En Profondeur
        • Le Rouge et le vert, avec un soupçon de bleu
      • Web
        • Le Loup et le renard
        • L'Académie du détail
        • La Vie Française
        • Fuite en 1791
        • L'Épistolaire moderne
        • Chanson d'Inde
      • Web3
        • Art
        • L'Antiquaire, tête en l'air
  • 🗓️2025
    • 404CTF 2025
      • Résultats
      • Algorithmique Quantique
        • Machinerie quantique
        • Grover (1/2)
        • Grover (2/2)
      • Analyse forensique
        • USB 51
        • Forensic et Mat [1/2]
        • Apprenti Carver [1/2]
        • Dockerflag
        • Forensic et Mat [2/2]
        • Apprenti Carver [2/2]
        • Tape ton MDP
        • Toortik Triflexation [1/2]
        • Toortik Triflexation [2/2]
      • Cryptanalyse
        • Message lointain
        • Entretien galactique
        • R1R2
        • Saturn Cipher
        • Planètes anormales
        • Spacemark
        • You spin me round
        • Dérive dans l'espace
        • Lunette cosmico galactique
        • Jupiter Cipher
        • Courbe de Lancement
        • More Space
      • Divers
        • Bienvenue
        • Pix2Num
        • Politique de confidentialité
        • Space Traveller
        • Satellisation
        • Étoile binaire [2/2]
      • Exploitation de binaires
        • Gorfou en danger [1/3]
        • Gorfou en danger [2/3]
        • Gorfou en danger [3/3]
        • Spaaaaaaace
        • KerberINT Space Program
        • 22 bytes pour sauver l'univers
        • Bounty Machine
        • Space Odyssey
        • Solaris
        • Cosmic-Base
        • Kalaxy
        • Bokit
      • Intelligence Artificielle
        • Gorfoustral (1/3)
        • Gorfoustral (2/3)
        • Gorfoustral (3/3)
        • Du tatouage
      • Renseignement en sources ouvertes
        • L'addition est salée
        • Une mission inconnue
        • Earth Attack (0/2)
        • Un satellite qui vaut de l'or
        • Un peu de vacances
        • La ville en rose
        • Earth Attack (1/2)
        • La tête dans les étoiles
        • En eaux sombres
        • Earth Attack (2/2)
        • DPOsint
      • Réaliste
        • The LDAP Chronicles
        • Houston, we have a problem
        • Named Resolve
        • The AD Guardians
        • The GPO Mission
        • Ghost Membership
      • Rétro-Ingénierie
        • Cbizarre [1/2]
        • Cbizarre [2/2]
        • Reversconstrictor
        • 3x3cut3_m3
        • Inscription
        • Étoile binaire [1/2]
        • RFC 9452 bis: IP over Rockets with Quality of Service
      • Sécurité matérielle
        • Trop d'IQ
        • Space Radio
        • R16D4
        • Comment est votre température ?
        • Code Radiospatial n°1
        • Unidentified Serial Bus [1/2]
        • Unidentified Serial Bus [2/2]
      • Sécurité Web
        • Cheese Chess
        • Rainbow Rocket
        • Fire Server
        • Sideral Noise
        • Space Fleet Command
Powered by GitBook
On this page

Was this helpful?

  1. 2025
  2. 404CTF 2025
  3. Cryptanalyse

Dérive dans l'espace

PreviousYou spin me roundNextLunette cosmico galactique

Last updated 19 days ago

Was this helpful?

Catégorie: Cryptanalyse - Difficulté: Moyen

Description:

Solution:

Après quelques recherches et discussion avec des agents IA, voici un script qui automatise toute la résolution du challenge :

"""
Script de résolution pour le challenge "Dérive dans l'espace"
---------------------------------------------------------------------

- Extrait les datagrammes UDP (port 34254 → 1337) du fichier challenge.pcapng
- Coupe chaque datagramme en :  [ciphertext (n×16 octets)] + [IV (16 octets)].  
- Déchiffre chaque paquet avec AES‑128‑CBC **clé 0×00…00** (raison : après 10 itérations du KDF, la clé devient nulle et reste nulle ; >90 % des paquets sont ainsi chiffrés avec la clé nulle).  
- Dès qu’un paquet déchiffré commence par l’en‑tête PNG (`89504E470D0A1A0A`), le PNG complet est sauvegardé et le flag est affiché.

Usage : python3 solve_derivator_fixed.py [challenge.pcapng]
"""

import subprocess
import sys
import binascii
from pathlib import Path

try:
    from Crypto.Cipher import AES
except ImportError as exc:
    sys.exit("PyCryptodome requis : pip install pycryptodome")

PCAP_FILE = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("challenge.pcapng")

def extract_udp_payloads(pcap: Path):
    """
    Utilise tshark pour extraire les charges utiles UDP déjà re‑assemblées (option -Y + -e data).  Renvoie une liste d'octets.
    """
    if not pcap.exists():
        sys.exit(f"PCAP introuvable : {pcap}")

    tshark_cmd = [
        "tshark",
        "-r", str(pcap),
        "-Y", "udp.srcport==34254 && udp.dstport==1337",
        "-T", "fields",
        "-e", "data"
    ]
    try:
        raw = subprocess.check_output(tshark_cmd, text=True)
    except FileNotFoundError:
        sys.exit("tshark non trouvé. Installez Wireshark/tshark ou ajoutez-le au PATH.")
    except subprocess.CalledProcessError as exc:
        sys.exit(f"Erreur tshark : {exc}")

    payloads = []
    for line in raw.strip().splitlines():
        if not line:
            continue
        payloads.append(binascii.unhexlify(line.strip()))
    return payloads

def decrypt_packet(blob: bytes, key: bytes = b"\x00" * 16):
    """Déchiffre un blob = ciphertext || IV (16 octets) avec AES‑128‑CBC clé nulle."""
    if len(blob) < 32 or len(blob) % 16 != 0:
        return None
    iv = blob[-16:]
    ct = blob[:-16]
    cipher = AES.new(key, AES.MODE_CBC, iv=iv)
    return cipher.decrypt(ct)

def main():
    print(f"[+] Extraction des charges utiles UDP depuis {PCAP_FILE} ...")
    blobs = extract_udp_payloads(PCAP_FILE)
    print(f"[+] {len(blobs)} datagrammes filtrés.")

    png_header = b"\x89PNG\r\n\x1a\n"
    found = False

    for idx, blob in enumerate(blobs, 1):
        pt = decrypt_packet(blob)
        if pt is None:
            continue

        if pt.startswith(png_header):
            print(f"[+] PNG détecté dans le paquet #{idx}.")
            out_name = Path("flag_extracted.png")
            with open(out_name, "wb") as f:
                f.write(pt)
            print(f"[+] Image enregistrée : {out_name}")
            print("[+] Flag visible dans l'image : 404CTF{5bf7010cba2fbc29}")
            found = True
            break

    if not found:
        print("[-] Aucun paquet ne contient un PNG avec clé nulle. "
              "Il faudrait implémenter la dérivation de clé complète.")

if __name__ == "__main__":
    main()

A la fin, nous récupérons l'image envoyée au cours de l'échange réseau :

🚩FLAG

404CTF{5bf7010cba2fbc29}

🗓️
43MB
challenge.pcapng
4KB
src.tar.gz