mbr rootkit

26
MBR rootkit 노노노 FSK security Co.,Ltd. [email protected]

Upload: keziah

Post on 07-Feb-2016

159 views

Category:

Documents


1 download

DESCRIPTION

MBR rootkit. 노용환 FSK security Co.,Ltd . [email protected]. MBR rootkit ? Bootkit ?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: MBR rootkit

MBR rootkit

노용환FSK security Co.,[email protected]

Page 2: MBR rootkit

MBR rootkit ? Bootkit ?

Page 3: MBR rootkit

A bootkit is a rootkit that is able to load from a master boot record and persist in memory all the way through the transition to protected mode and the startup of the OS. It's a very interesting type of rootkit.

Robert Hensing about bootkits

1987 Stoned, first master boot record (bootkit) virus 1990 Form, common boot sector virus in the early 1990s August 1, 2005 eEye publishes BootRoot & SysRQ2, presented at BH USA 2005 March 29, 2007 Vbootkit was presented at Black Hat Europe 2007 October 30,2007 Mebroot bootkit appears in the wild November 2008 Hibernation File Attack was developed, attacking Win-dows files April 2009 Mebroot is updated to work with Windows Vista (non-public info) May 2009 Kon-Boot is released, a tool to bypass Windows logon March 4, 2009 Vbootkit 2.0 attacks Windows 7 64-bit and goes open source

- The Rise of MBR Rootkits & Bootkits in the Wild by Peter Kleissner

Page 4: MBR rootkit

Bootstrapping

Page 5: MBR rootkit

전원 ON

MainBoard::POST(Power On Self Test)

각 장치들에 전원공급은 문제 없나 ?메모리는 정상적으로 붙어있는가 ?

MainBoard:: 장치 초기화

메인보드에 연결된 장치들을 초기화바이오스 (BIOS) 호출

BIOS::MBR 로딩설정된 부팅장치 (hdd, floppy, cdrom, etc.) 에서MBR (Master Boot Record) 를 검색MBR 을 찾지 못하면 에러처리메모리의 0x7c00 주소에 찾은 MBR 512 byte 를 로드하고 실행

MBR (Master Boot Record)

16 비트 리얼모드 코드와 디스크의 파티션 정보512 byte511, 512 바이트에는 0x55, 0xAA 의 시그너쳐

Page 6: MBR rootkit

http://tinyurl.com/4akp4fu

Page 7: MBR rootkit

초 간단 부트로더 제작

Page 8: MBR rootkit

ORG 0BITS 16CPU 486

jmp 0x07c0:bootsector_entrywelcome db 'welcome to CODEGATE 2011 training course!!',13,10,0bootsector_entry: mov ax, 0x07c0 mov ds, ax; clear screen mov ax, 0x0003 int 0x10; write message mov si, welcomewrite_msg: lodsb ; load byte at ds:si into al or al,al ; test if character is 0 (end) jz done mov ah,0eh ; put character mov bx,0007 ; attribute int 0x10 ; call BIOS jmp write_msg done: nop hlt ; hmm... what's next ??? times 510-($-$$) db 0 dw 0AA55h ; MBR signature

Page 9: MBR rootkit
Page 10: MBR rootkit

다 좋습니다 :-)

그런데 내 윈도우는 언제 부팅되나요 ?

Page 11: MBR rootkit

0x7c00 영역에 Windows 의 MBR 이 로드 되어야 부팅이 되는데…0x7c00 에는 우리의 부트로더가 위치해 있다 !!!

사용 가능한 영역에 실행할 코드를 로드하고 , 0x7C00 영역에 원래의 MBR 코드를 로드 하고 제어권을 넘기면 ?

Page 12: MBR rootkit
Page 13: MBR rootkit

0x7C00

Boot stage #1

Boot stage #2

Original MBR

Boot stage #1 - BIO 가 0x7C00 에 로드하고 제어권이 넘어온 상태 - boot stage #2 를 사용가능한 메모리영역에 로드하고 제어권 이동

Boot stage #2 - HDD 에서 MBR 영역을 읽어서 0x7C00 에 로드 ( 마치 BIOS 처럼 ) - Original MBR 로 제어권 이동

Original MBR - 정상 부팅 !!

Page 14: MBR rootkit

Windows boot process

Page 15: MBR rootkit

By Stoned Bootkit by Peter Kleissner at Black Hat USA 2009 presentation

Page 16: MBR rootkit

Bootkit technique

Page 17: MBR rootkit

Bootkit 코드를 - 어떻게 안전하게 메모리에 상주시킬 것인가 ?- 만일 OS 가 메모리를 덮어쓰지는 않을까 ?

Page 18: MBR rootkit

BIOS 인터럽트 후킹- 별로 특별할 것도 없다 !!!!

Page 19: MBR rootkit
Page 20: MBR rootkit

Runtime code generating…??- 실행시점에 덮어쓸 주소를 계산해서 동적으로 후킹

Page 21: MBR rootkit

BIOS

Install BIOS inter-rupt hook

Patch ntldr(16 bit real

mode)

Patch NT Kernel(32 bit protected

mode)

Make our rootkitResident

INT 12h trick

Page 22: MBR rootkit

Implement how to…빌드 환경 설정 및 이미지 생성

부트 섹터 / 부트 로더 코드 리뷰실행 환경 설정

디버깅 환경 설정

Page 23: MBR rootkit

Attack windows logon

Page 24: MBR rootkit

http://tinyurl.com/4gbc6p2

Page 25: MBR rootkit

1: kd> u msv1_0!MsvpPasswordValidate L3msv1_0!MsvpPasswordValidate:77f197d3 8bff mov edi,edi77f197d5 55 push ebp77f197d6 8bec mov ebp,esp

1: kd> eb msv1_0!MsvpPasswordValidate b0 01 c2 0c 00

1: kd> u msv1_0!MsvpPasswordValidate L3msv1_0!MsvpPasswordValidate:77f197d3 b001 mov al,177f197d5 c20c00 ret 0Ch77f197d8 83ec50 sub esp,50h

Bypassing your testbox's login password by bugcheck (2006) at rootkit.com

Page 26: MBR rootkit

Q & A

감사합니다 .