RTL Chain - s0ngsari

Download Report

Transcript RTL Chain - s0ngsari

RTL Chaining
송상준
[email protected]
서초고등학교
Contents

자기소개

RTL

RTL Chaining

Demo
자기소개




서초고등학교 2학년
Best of the Best 4기 교육생
정보보안팀 HackCat 소속
s0ngsari.tistory.com
RTL Chaining
[*] RTL을 chaining시켜 공격하는 기법
- RTL을 우선적으로 알고있어야함
- Bypass ASLR, NX Bit
ex) 1+2+3과 1*2*3의 차이
Return to Libc
RTL(Return To Libc)
- 프로그램의 리턴값을 라이브러리로 덮어
실행하게함
- ex)system
- 공격 시나리오는?
Return to Libc
[*] First, Get Library Address, Library argument
print libraryname
find &system,+99999999,”/bin/sh”
Return to Libc
[*] Finally, Just Attack!
- Buffer[?] + SFP[4] + system + exit + /bin/sh
system(“/bin/sh”) -> exit(0);
Return to Libc
system = ebp+8을 인자로 받음
exit가아닌 A*4를 넣어도되지만 정상종료를위해 exit사
용
exit가 아닐시, 쉘종료후 Segmentation Fault 메세지
출력
RTL Chaining
[New!!]
* Gadget(pop ret)
- 우리가 필요한 덩어리들
- Gadget을 모아서 하나로 만듬
* PLT(Procedure Linkage Table)
- GOT에 접근해 실제 함수의 주소를 호출
RTL Chaining
[*] First, Find Gadget(pop .. ret)
Usage: objdump –d ./binary
pop ret = 0x0804852f
pop pop ret = 0x0804852e
RTL Chaining
[*] Second, Find 1byte char(/bin/sh)
Usage: objdump –s ./binary | grep “/”
“/” – 0x08048154
(/,b,i,n,s,h,\x00)을 모두 구해야함
RTL Chaining
[*] Third, Find .bss Address
Usage: objdump –h ./binary | grep bss
- insert char(/bin/sh) in .bss (custom stack)
bss = 0x0804a028
bss size = 1028byte
RTL Chaining
[*] Fourth, Find vuln@plt
strcpy@plt = 0x080483a0
jmp ds:offset은 got주소!!
RTL Chaining
[*] pop .. ret
- pop .. ret을 이용해 인자전달후 함수를 리턴한다.
pop ret
pop pop ret
pop pop pop ret
– 인자가 하나일때 ex) gets
– 인자가 두개일때 ex) strcpy
– 인자가 세개일때 ex) fgets
RTL Chaining
Finish!!
I Have..
[Gadget,character,bss,strcpy@plt,system]
Attack Scenario
[*] Payload
strcpy@plt + ppr + .bss + “/” ... System + exit + bss
C Code?
-> strcpy(bss[0], “/”); strcpy(bss[1], “b”); ...
Demo
[Environment]
- Ubuntu 14.04 LTS
- Netcat Remote Server
- gcc –o exploit exploit.c –fno-stack-protector
The End
수고하셨습니다