Rootkit 102 - Kernel-Based Rootkit

24
Rootkit 102 cmj @ 2015 1

Transcript of Rootkit 102 - Kernel-Based Rootkit

Page 1: Rootkit 102 - Kernel-Based Rootkit

Rootkit 102

cmj @ 2015

1

Page 2: Rootkit 102 - Kernel-Based Rootkit

Kernel-Level Rootkit

2

Page 3: Rootkit 102 - Kernel-Based Rootkit

concept

Cheat and Robust enough

3

Page 4: Rootkit 102 - Kernel-Based Rootkit

Program Bugs

User-Space rootkit

• process hand, not workable or dead

• no one find abnormal

Kernel-Space rootkit

• system crash

• reboot

• … etc

4

Page 5: Rootkit 102 - Kernel-Based Rootkit

Robust is more important than you expected

5

Page 6: Rootkit 102 - Kernel-Based Rootkit

Otherwise, you are attacking the system

6

Page 7: Rootkit 102 - Kernel-Based Rootkit

Linux Kernel

from linux-2.6.x to linux-3.17.x

1. You should know the target kernel version

2. method may significant difference between version and platform

7

Page 8: Rootkit 102 - Kernel-Based Rootkit

Trivial Kernel-Based Rootkit

8

Page 9: Rootkit 102 - Kernel-Based Rootkit

Flow

1. Create a loadable-kernel-module)

2. Decide which syscall you what to hook

3. Implement and debug

9

Page 10: Rootkit 102 - Kernel-Based Rootkit

Flow

1. Create a loadable-kernel-module) - Overcome by yourself

2. Decide which syscall you what to hook

3. Implement and debug - Overcome by yourself

10

Page 11: Rootkit 102 - Kernel-Based Rootkit

Hook Syscall

Concept

1. Find the address of the sys_call_table or syscall

2. Replace the registered syscall

11

Page 12: Rootkit 102 - Kernel-Based Rootkit

sys_call_table

1. Easily way

2. Normal way

3. Violent way

12

Page 13: Rootkit 102 - Kernel-Based Rootkit

sys_call_table

1. Easily way - Find it out in System.map

2. Normal way

3. Violent way

13

Page 14: Rootkit 102 - Kernel-Based Rootkit

System.map

14

Page 15: Rootkit 102 - Kernel-Based Rootkit

sys_call_table

1. Easily way - Find it out in System.map

2. Normal way - Dump on /proc/kallsyms

3. Violent way

15

Page 16: Rootkit 102 - Kernel-Based Rootkit

/proc/kallsyms

16

Page 17: Rootkit 102 - Kernel-Based Rootkit

sys_call_table

1. Easily way - Find it out in System.map

2. Normal way - Dump on /proc/kallsyms

3. Violent way - Force search all kernel-level memory

17

Page 18: Rootkit 102 - Kernel-Based Rootkit

Brust-Force Search

18

Page 19: Rootkit 102 - Kernel-Based Rootkit

Memory usage in kernel-space

• 0xC0000000 - 0xF0000000

• Using export syscall function

• Not always, need to consider the linux version …

19

Page 20: Rootkit 102 - Kernel-Based Rootkit

Hook getdent64

20

Page 21: Rootkit 102 - Kernel-Based Rootkit

MileStone

• Should we always need to replace the syscall - clue in kallsyms

• Should LKM can modified the memory - write protect

21

Page 22: Rootkit 102 - Kernel-Based Rootkit

New tricks,New rootkit

22

Page 23: Rootkit 102 - Kernel-Based Rootkit

You also can hijack

• callback fn - syscall hijack

• data - link-list struct used in kernel

• memory - direct modify data online

• … etc

23

Page 24: Rootkit 102 - Kernel-Based Rootkit

Thanks for your attention ~

24