Boot Root
Boot Root
Derek Soeder
Ryan Permeh
Introduction
Explores the capabilities of custom boot sector code on
NT-family Windows
What can it do? Anything its privileged code on the CPU
The trick is keeping control while allowing the OS to function
Overview
BIOS boot process and Windows startup
eEye BootRoot: how it works, capabilities and shortcomings
Demo: eEye BootRootKit backdoor
Required Knowledge
x86 real and protected modes, some Windows kernel
eEye BootRoot:
A
Basis
for
Bootstrap-Based
CLICK TO ADD MASTERWindows
TITLEKernel
ALLCode
CAPS
Booting Up
Booting Up Summary
BIOS transfers execution to code from some other medium
Disk drive (fixed or removable)
CD-ROM
Network boot
Windows startup from a hard drive installation
Hard drive Master Boot Record
Windows bootstrap loader
NTLDR
OSLOADER.EXE
NTDETECT.COM
NTOSKRNL.EXE, HAL.DLL, boot drivers
0000
xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx
0010
xx xx xx xx xx xx xx xx-xx xx xx xx xx xx xx xx
...
01B0
xx xx xx xx xx xx xx xx-xx xx xx xx xx xx BI SH
01C0
SS SC ID EH ES EC L0 L1-L2 L3 S0 S1 S2 S3 BI SH
01D0
SS SC ID EH ES EC L0 L1-L2 L3 S0 S1 S2 S3 BI SH
01E0
SS SC ID EH ES EC L0 L1-L2 L3 S0 S1 S2 S3 BI SH
01F0
SS SC ID EH ES EC L0 L1-L2 L3 S0 S1 S2 S3 55 AA
+00
BYTE
Boot Indicator
+01
BYTE
Starting Head
+02
BYTE
BYTE
+04
BYTE
+05
BYTE
Ending Head
+06
BYTE
+07
BYTE
+08
DWORD
+0C
DWORD
Booting Up CD-ROM
Differences from disks and diskettes
Sector size is 800h bytes (2KB)
Data format is more complicated (ECMA-119 / ISO 9660)
Bootable CD format dictated by El Torito Specification
Boot sector (only first 200h bytes) loads at 07C0h:0000h
Executes in real mode
SS:SP = 0000h:0400h, DS = 0040h (BIOS data area)
Additional disc contents are accessed via INT 13h
Boot catalog entry indicates emulation mode (floppy or HD)
(unused)
8000
Primary Volume
8800
Boot Catalog
A000
Boot Code
A800
8000 BYTE
8001 [5]
8006 BYTE
8050 DWORD
8054 DWORD
8078 WORD
807A WORD
807C WORD
807E WORD
8080 WORD
8082 WORD
809C [22h]
809C BYTE
80B5 BYTE
80B8 WORD
80BA WORD
80BB BYTE
80BC [1]
Source: ECMA-119: Volume and File Structure of CDROM for Information Interchange.
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
Source: El Torito Bootable CD-ROM Format Specification, Version 1.0.
http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf
0000
(unused)
8000
8800
8801
8806
8807
BYTE
[5]
BYTE
[20h]
8847
DWORD
9000
9001
9006
BYTE
[5]
BYTE
Primary Volume
8800
Boot Catalog
A000
Boot Code
A800
Source: ECMA-119: Volume and File Structure of CDROM for Information Interchange.
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
Source: El Torito Bootable CD-ROM Format Specification, Version 1.0.
http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf
(unused)
8000
Primary Volume
8800
Boot Catalog
A000
Boot Code
A800
Source: ECMA-119: Volume and File Structure of CDROM for Information Interchange.
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
Source: El Torito Bootable CD-ROM Format Specification, Version 1.0.
http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf
10
11
Port
67
67
67
67
(client IP)
(var)
TFTP Read Req
-> (server IP)
69
[File: (boot file name); Mode: "octet"; "tsize" = 0; "blksize" = (block size)]
(client IP)
(var) <- TFTP Option ACK
(server IP)
69
["tsize" = (size of boot file); "blksize" = (supported block size)]
(client IP)
(var)
TFTP ACK
-> (server IP)
69
[Block: 0]
(client IP)
(var) <- TFTP Data
(server IP)
69
[Block: 1; file data]
(client IP)
(var)
TFTP ACK
-> (server IP)
69
[Block: 1]
...
12
14
13
Windows Startup
15
16
Limit=FFFFFFFF
Limit=FFFFFFFF
Limit=FFFFFFFF
Limit=FFFFFFFF
Limit=00000077
Limit=00001000
Limit=00000FFF
Limit=0000FFFF
(reserved)
Limit=0000006F
Limit=0000FFFF
Limit=0000FFFF
Limit=00003FFF
Limit=00003FFF
Limit=0000FFFF
Limit=0000FFFF
Limit=00000000
Base=00000000
Base=00000000
Base=00000000
Base=00000000
Base=00024460
Base=00000000
Base=00000000
Base=00000400
DPL=0
DPL=0
DPL=3
DPL=3
DPL=0
DPL=0
DPL=3
DPL=3
Base=00023B7E
Base=00020000
Base=00022F30
Base=000B8000
Base=FFFF7000
Base=80400000
Base=80400000
Base=00000000
DPL=0
DPL=0
DPL=0
DPL=0
DPL=0
DPL=0
DPL=0
DPL=0
Task Gate
P=1 A=0 Code16
P=1 A=0 Data16
P=1 A=0 Data16
P=1 A=0 Data16
P=1 A=0 Data16
P=1 A=0 Data16
P=1 A=0 Data16
KGDT_R0_CODE
KGDT_R0_DATA
KGDT_R3_CODE
KGDT_R3_DATA
KGDT_TSS
KGDT_R0_PCR
KGDT_R3_TEB
KGDT_VDM_TILE
KGDT_LDT
KGDT_DF_TSS
(NTLDR code)
(NTLDR data)
(text memory)
(NTOSKRNL code)
(NTOSKRNL data)
17
18
19
Phase 1 initialization
Phase1Initialization executes as a separate system thread
Boot drivers execute during this phase
Finishes kernel initialization and starts user-mode SMSS.EXE
20
21
NTOSKRNL.EXE!Phase1Initialization
HAL.DLL!HalInitSystem
MmInitSystem (2) (makes executive pageable)
PoInitSystem (1)
PoInitSystem (0)
PsInitSystem (locates certain NTDLL exports)
ObInitSystem
ExInitSystem
KeInitSystem
SeInitSystem
MmInitSystem (1)
CmInitSystem
FsRtlInitSystem
PpInitSystem
LpcInitSystem
ExInitSystemPhase2
IoInitSystem (IopInitializeSystemDrivers runs boot drivers, PsLocateSystemDll loads NTDLL.DLL)
22
eEye BootRoot
23
24
25
26
27
Length
000000000009F800
0000000000000800
0000000000002000
0000000000004000
000000000001C000
0000000007DF0000
000000000000C000
0000000000004000
0000000000100000
0000000000010000
0000000000001000
0000000000020000
Type
1 Available
2 (Reserved)
2 (Reserved)
2 (Reserved)
2 (Reserved)
1 Available
3 (ACPI Reclaimable)
4 (ACPI NVS)
1 Available
2 (Reserved)
2 (Reserved)
2 (Reserved)
System memory map generated using INT 15h/AX=E820h on a VMWare 4.5 system with 128MB RAM.
28
30
29
eEye BootRootKit
31
8B
85
74
80
F0
F6
21
...
seg:ofs32
DWORD PTR
is 7 bytes
[ofs32] is 6 bytes perfect for this patch site
32
33
[[_BlLoaderBlock]+0]
MOV
MOV
EAX, [_BlLoaderBlock]
LIST_ENTRY
[10h]
PTR
PTR
DWORD
UNICODE_STRING
UNICODE_STRING
Format of loaded module list nodes used by OSLOADER and based at [[_BlLoaderBlock]+0].
Structure is identical to that used by NTOSKRNL in PsLoadedModuleList.
34
35
50
53
C7 46 10 0E 00 00 00
E8 xx xx xx xx
PUSH
PUSH
MOV
CALL
EAX
ECX
DWORD PTR [ESI+10h], 0Eh
ethFilterDprIndicateReceivePacket
36
38
Demonstration
From a floppy disk
From a CD-RW
Via network boot
37
39
To-Do
Adapt for more traditional rootkit functionality
Explore other methods of retaining execution potential
besides INT 13h hook-based patching
Investigate bootable USB storage and other bootable media
40
Bonus Material!
A little something extra for those who thought this talk
would be entirely boring... (you may still be right)
Did you know:
You can perform raw disk operations without entering the
kernel?
Its not an NT kernel vulnerability!
Its...
42
41
IOPL Technique
43
So what?
44
46
Questions?
45
References