Designing BSD Rootkits: An Introduction to Kernel Hacking

Free Download

Authors:

Edition: 1

ISBN: 1-59327-142-5, 1-59327-142-5, 978-1-59327-142-8

Size: 8 MB (8779835 bytes)

Pages: 144/164

File format:

Language:

Publishing Year:

Category: Tags: , , ,

Joseph Kong1-59327-142-5, 1-59327-142-5, 978-1-59327-142-8

Though rootkits have a fairly negative image, they can be used for both good and evil. Designing BSD Rootkits arms you with the knowledge you need to write offensive rootkits, to defend against malicious ones, and to explore the FreeBSD kernel and operating system in the process.
Organized as a tutorial, Designing BSD Rootkits will teach you the fundamentals of programming and developing rootkits under the FreeBSD operating system. Author Joseph Kong’s goal is to make you smarter, not to teach you how to write exploits or launch attacks. You’ll learn how to maintain root access long after gaining access to a computer and how to hack FreeBSD.
Kongs liberal use of examples assumes no prior kernel-hacking experience but doesn’t water down the information. All code is thoroughly described and analyzed, and each chapter contains at least one real-world application.
Included:
The fundamentals of FreeBSD kernel module programming Using call hooking to subvert the FreeBSD kernel Directly manipulating the objects the kernel depends upon for its internal record-keeping Patching kernel code resident in main memory; in other words, altering the kernel’s logic while it’s still running How to defend against the attacks described
Hack the FreeBSD kernel for yourself!

Table of contents :
DESIGNING BSD ROOTKITS……Page 1
Acknowledgments……Page 8
Contents……Page 11
Foreword……Page 15
Introduction……Page 17
Contents Overview……Page 18
Concluding Remarks……Page 19
1: Loadable Kernel Modules……Page 21
1.1 Module Event Handler……Page 22
1.2 The DECLARE_MODULE Macro……Page 23
1.3 “Hello, world!”……Page 24
1.4.1 The System Call Function……Page 26
1.4.2 The sysent Structure……Page 27
1.4.4 The SYSCALL_MODULE Macro……Page 28
1.4.5 Example……Page 29
1.4.7 The modstat Function……Page 30
1.4.9 Executing the System Call……Page 31
1.5 Kernel/User Space Transitions……Page 32
1.5.3 The copystr Function……Page 33
1.6.1 The cdevsw Structure……Page 34
1.6.2 Character Device Functions……Page 35
1.6.3 The Device Registration Routine……Page 36
1.6.4 Example……Page 37
1.6.5 Testing the Character Device……Page 39
1.7 Linker Files and Modules……Page 41
1.8 Concluding Remarks……Page 42
2: Hooking……Page 43
2.1 Hooking a System Call……Page 44
2.2 Keystroke Logging……Page 46
2.3 Kernel Process Tracing……Page 48
2.4 Common System Call Hooks……Page 49
2.5.1 The protosw Structure……Page 50
2.5.2 The inetsw[ ] Switch Table……Page 51
2.6 Hooking a Communication Protocol……Page 52
2.7 Concluding Remarks……Page 55
3.1 Kernel Queue Data Structures……Page 57
3.1.3 The LIST_ENTRY Macro……Page 58
3.2 Synchronization Issues……Page 59
3.2.3 The sx_slock and sx_xlock Functions……Page 60
3.3.1 The proc Structure……Page 61
3.3.2 The allproc List……Page 62
3.3.3 Example……Page 63
3.4 Hiding a Running Process Redux……Page 66
3.4.2 pidhashtbl……Page 67
3.4.4 Example……Page 68
3.5 Hiding with DKOM……Page 71
3.6.1 The inpcb Structure……Page 72
3.6.2 The tcbinfo.listhead List……Page 73
3.6.3 Example……Page 74
3.7 Corrupting Kernel Data……Page 76
3.8 Concluding Remarks……Page 77
4.1 Hooking a Character Device……Page 79
4.1.3 Example……Page 80
4.2 Concluding Remarks……Page 82
5.1 Kernel Data Access Library……Page 83
5.1.2 The kvm_nlist Function……Page 84
5.1.5 The kvm_write Function……Page 85
5.2 Patching Code Bytes……Page 86
5.3.1 Patching Call Statements……Page 90
5.4.1 The malloc Function……Page 93
5.4.4 The FREE Macro……Page 94
5.4.5 Example……Page 95
5.5.1 Example……Page 97
5.6 Inline Function Hooking……Page 101
5.6.1 Example……Page 102
5.7 Cloaking System Call Hooks……Page 108
5.8 Concluding Remarks……Page 110
6.1 What HIDSes Do……Page 111
6.3 Execution Redirection……Page 112
6.4 File Hiding……Page 116
6.5 Hiding a KLD……Page 121
6.5.2 The linker_file Structure……Page 122
6.5.4 The module Structure……Page 123
6.5.5 Example……Page 124
6.6 Preventing Access, Modification, and Change Time Updates……Page 127
6.6.1 Change Time……Page 128
6.6.2 Example……Page 132
6.7 Proof of Concept: Faking Out Tripwire……Page 134
6.8 Concluding Remarks……Page 137
7: Detection……Page 139
7.1.1 Finding System Call Hooks……Page 140
7.2.1 Finding Hidden Processes……Page 143
7.3.2 Finding Code Byte Patches……Page 145
7.4 Concluding Remarks……Page 146
Closing Words……Page 147
Bibliography……Page 149
Index……Page 151
Updates……Page 162

Reviews

There are no reviews yet.

Be the first to review “Designing BSD Rootkits: An Introduction to Kernel Hacking”
Shopping Cart
Scroll to Top