x64 rootkits risspa

35
Руткиты для платформы x64: миф или реальность Александр Матросов Евгений Родионов

Upload: risspa

Post on 24-May-2015

1.844 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: X64 rootkits risspa

Руткиты для платформы x64: миф или реальность

Александр Матросов

Евгений Родионов

Page 2: X64 rootkits risspa

Кто мы такие?

Центр вирусных исследований и аналитики ESET- анализ современных руткит угроз- разработка средств лечения и защиты- мониторинг новых вредоносных технологий- анализ активности киберкриминальных

групп

http://www.joineset.com/

Page 3: X64 rootkits risspa

О чем сегодня поговорим

Эволюция руктит-программ

Какие руткит угрозы известны для x64

Какие методы используются для обхода проверки цифровой подписи модулей ядра

Как отлаживать буткит часть при помощи Bochs

TdlFsReader как инструмент криминалистической экспертизы

Page 4: X64 rootkits risspa

Эволюция руткит-программ

Page 5: X64 rootkits risspa

Dropper

Эволюция руткит технологий

bypassing HIPS/AV

x86x64

privilege escalation

installing rootkit driver

Rootkit

self-defense

surviving reboot

injecting payload

Rootkit

Rootkit

self-defense

surviving reboot

injecting payload

bypassing signature check

bypassing MS PatchGuard

User

mod

e

Kern

el m

od

e

Page 6: X64 rootkits risspa

o Kernel-Mode Code Signing Policy

Проблемы с загрузкой неподписанных

модулей ядра

o Kernel-Mode Patch Protection (Patch Guard):

SSDT (System Service Dispatch Table)

IDT (Interrupt Descriptor Table)

GDT ( Global Descriptor Table)

MSRs (Model Specific Registers)

Проблемы разработки х64 руткитов

Page 7: X64 rootkits risspa

TDL3/TDL3+ TDL4

Kernel-mode code representation

Base independent piece of code in hidden file system

PE image in the hidden file system

Surviving after reboot

Infecting disk miniport/random kernel-mode driver

Infecting MBR of the disk

Self-defense Kernel-mode hooks, registry monitoring

Kernel-mode hooks, MBR monitoring

Injecting payload into processes in the system

tdlcmd.dll cmd.dll/cmd64.dll

x64 support Complexity

Эволюция TDL

Page 8: X64 rootkits risspa

Эволюция TDL

TDL3/TDL3+ TDL4

Bypassing HIPS AddPrintProcessorAddPrintProvidor

AddPrintProvidor, ZwConnectPort

Privilege Escalation MS10-092

Installation mechanism

by loading kernel-mode driver

by loading kernel-mode driver

overwriting MBR of the disk

Number of installed modules

4 10

Page 9: X64 rootkits risspa

Установка на x86 vs. x64

Page 10: X64 rootkits risspa
Page 11: X64 rootkits risspa

Этапы установки руткита

exploit payload dropper rootkit

Page 12: X64 rootkits risspa

Dropped modules

Description

mbr original contents of the infected hard drive boot sector

ldr16 16-bit real-mode loader code

ldr32 fake kdcom.dll for x86 systems

ldr64 fake kdcom.dll for x64 systems

drv32 the main bootkit driver for x86 systems

drv64 the main bootkit driver for x64 systems

cmd.dll payload to inject into 32-bit processes

cmd64.dll payload to inject into 64-bit processes

cfg.ini configuration information

bckfg.tmp encrypted list of C&C URLs

Устанавливаемые модули

Page 13: X64 rootkits risspa

Installation on x86

AdjustSeLoadDriver

privilegefail success

Copy itself intoPrintProcessor

director

Check OSversion

Copy itself into%TMP% directory

Set IMAGE_FILE_DLLflag in the PE header

CallDeletePrintProvidorW

API

CallAddPrintProvidorW

API

Vista/Win7

ExploitationMS10-092

successfail

Createmanifest requesting

admin privilege

CallShellExecute

Failinstall

WinXP

Page 14: X64 rootkits risspa

Installation on x64

Write FS image,patch MBR and Adjust

SE_SHUTDOWN_PRIVILEGEfail success

Copy itself into%TMP% directory

ExploitationMS10-092success

fail

Createmanifest requesting

admin privilege

CallZwRaiseHardError

to create BSOD

Prepare hidden FS image

Report to C&C

Restart Dropper

CallShellExecute

fail

success

Page 15: X64 rootkits risspa

TDL буткит или как обойти проверку цифровой подписи

Page 16: X64 rootkits risspa

Types of integrity checks

o PnP устройства должны иметь цифровую подпись

o Kernel-Mode Code Signing Policy

работает на х64 версиях Windows Vista и более поздних

64-bit Windows Vista and later

32-bit Windows Vista and later

Boot-start driver Non boot-start PnP driver

Non boot-start, non-PnP driver

(except stream

protected media drivers)

Page 17: X64 rootkits risspa

Load MBR

Load VBR

Load ntldr

Load kernel and boot

start drivers

real mode

real mode

real mode/protected mode

Load MBR

Load VBR

Load bootmgr

Load winload.exe or winresume.exe

real mode

real mode

real mode/protected mode

Load kernel and boot

start drivers

real mode/protected mode

Boot Process of pre Windows Vista OS

Boot Process of post Windows Vista OS

MBR – Master Boot Record

VBR – Volume Boot Record

Boot process of Windows OS

Page 18: X64 rootkits risspa

Code integrity check

Bootmgr OS loader OS kernel dependencies

OS kernel

Boot-start drivers

Non boot-start kernel-mode drivers

Page 19: X64 rootkits risspa

Boot Configuration Data (BCD)

Page 20: X64 rootkits risspa

BCD Elements determining KMCSP (before KB2506014)

BCD option Description

BcdLibraryBoolean_DisableIntegrityCheck(0x16000020)

disables kernel-mode code integrity checks

BcdOSLoaderBoolean_WinPEMode (0x26000022)

instructs kernel to be loaded in preinstallation mode, disabling kernel-mode code integrity checks as a byproduct

BcdLibraryBoolean_AllowPrereleaseSignatures(0x16000049)

enables test signing

Page 21: X64 rootkits risspa

Load infected MBRInfected mbr is

loadedand executed

Load “ldr16” from hidden file system

Hook BIOS int 13h handler and

restore original MBR

“ldr16” is loaded

and executed

Load VBR

Original mbr isloaded

and executed

Load bootmgr

VBR is loaded and executed

read bcd

Bootmgr is loaded and executed

Load winload.exe

Substitute EmsEnabled

option with WinPe

Load ntoskrnl.exe, hal.dll,kdcom.dll,bootvid.dll ant etc

distrort /MININT option

Call KdDebuggerInitialize1 from loaded kdcom.dll

substitute kdcom.dll

with”ldr32” or “ldr64"

Continue kernel initialization

Load ”drv32” or “drv64"

Load bootmgr

Abusing Win PE mode: workflow

Page 22: X64 rootkits risspa

TDL file system

Page 23: X64 rootkits risspa

TDL4 Volume device object

DriverObject

...Vpb

...

TDL4 Physical device object

DriverObject

...

\Driver\PnpManagerDriver object

TDL4Driver object

Volume parameter block

DeviceObject

RealDevice

\Device\XXXXXXXX Unnamed

XXXXXXXX – random 32-bit hexadecimal integer

TDL4 Device Stack

Page 24: X64 rootkits risspa

TDL4 Hidden FS

Growth direction

Disk partitions

One sector

One sectorVariable length Not more than 8 Mb

Infe

cted

MBR

TDL4 File System Layout

Page 25: X64 rootkits risspa

Debugging bootkit with WinDbg

Page 26: X64 rootkits risspa

WinDbgKDCOM.DLLNTOSKRNL

KD_RECV_CODE_OK

Data packet

Data Packet

KdDebuggerInitialize

KdSendPacket

KdReceivePacket

RETURN_STATUS

WinDbg and kdcom.dll

RETURN_CONTROL

Page 27: X64 rootkits risspa

original routine

modified routine

TDL4 and kdcom.dll

Page 28: X64 rootkits risspa

TDL4 and kdcom.dll

original export table modified export table

Page 29: X64 rootkits risspa

TdlFsReader as a forensic tool

Page 30: X64 rootkits risspa

TdlFsReader as a forensic tool

hееp://eset.ru/tools/TdlFsReader.exe

Page 31: X64 rootkits risspa

TdlFileReader

User mode

Kernel mode

TdlFsRecognizer

TdlFsDecryptor

TdlSelfDefenceDisabler

LowLevelHddReader

TdlFsReader architecture

Page 32: X64 rootkits risspa

TdlFsRecognizer

FsCheckVersion

FsStructureParser

TdlFsDecryptor

TdlCheckVersion

TdlDecryptor

TdlSelfDefenceDisabler

TdlUnHooker

HddBlockReader

TdlFsReader architecture

Page 33: X64 rootkits risspa

References

“The Evolution of TDL: Conquering x64”http://www.eset.com/us/resources/white-papers/The_Evolution_of_TDL.pdf

“Rooting about in TDSS”http://www.eset.com/us/resources/white-papers/Rooting-about-in-TDSS.pdf

“TDL3: The Rootkit of All Evil?”http://www.eset.com/us/resources/white-papers/TDL3-Analysis.pdf

Follow ESET Threat Bloghttp://blog.eset.com

Page 34: X64 rootkits risspa

Questions

Page 35: X64 rootkits risspa

Thank you for your attention ;)

Aleksandr [email protected]@matrosov

Eugene [email protected]@vxradius