Designing BSD Rootkits

Designing BSD Rootkits

An Introduction to Kernel Hacking
by Joseph Kong
April 2007, 142 pp.

"If you understand C and want to learn how to manipulate the FreeBSD kernel, Designing BSD Rootkits is for you. Peer into the depths of a powerful operating system and bend it to your will!"
Richard Bejtlich, TaoSecurity

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.

Kong's 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.


  • 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!

Visit the book's companion site for additional resources.

Author Bio 

Tinkering with computers has always been a primary passion of author Joseph Kong. He is a self-taught programmer who dabbles in information security, operating system theory, reverse engineering, and vulnerability assessment. He has written for Phrack Magazine and was a system administrator for the City of Toronto.

Table of contents 

Foreword by John Baldwin
Chapter 1: Loadable Kernel Modules
Chapter 2: Hooking
Chapter 3: Direct Kernel Object Manipulation
Chapter 4: Kernel Object Hooking
Chapter 5: Run-Time Kernel Memory Patching
Chapter 6: Putting It All Together
Chapter 7: Detection
Closing Words

View the detailed Table of Contents(PDF).
View the Index (PDF).


"The book is packed with very informative material and it delivers exactly what it promises."
—Help Net Security(Read More)

"If you've ever mucked about with make and /usr/src on a FreeBSD system or wish to learn more about FreeBSD src and kernel modules, [Designing BSD Rootkits] is well worth checking out."
—Dru Lavigne, A Year in the Life of a BSD Guru, June 6, 2008 (Read More)

"Kong writes to the practical programmer in all of us...If you understand how rootkits are written and operate, you have a better chance of detecting them or better yet, preventing them from getting on your system in the first place...If you have a basic programming background and this is your first foray into kernel hacking, scoop this book up and head to the check out stand."
—James Pyles (Read More)

"In writing [Designing BSD Rootkits] Joseph Kong has given us more than code snippets and links to man pages, he's given us a path to understanding more about the operating system we use every day."
—Daemon News (Read More)

"The best way to learn how something works is to break it and then have to fix it. Designing BSD Rootkits takes that idea to the next level."
—Michael Lucas

"If you understand C and want to learn how to manipulate the FreeBSD kernel, Designing BSD Rootkits is for you. Peer into the depths of a powerful operating system and bend it to your will!"
—Richard Bejtlich, TaoSecurity


Page 22, the first bullet point:

The chapter within the FreeBSD Developer's Handbook that the author is referring to is the chapter titled "Kernel Debugging", which at the time of the book's writing was Chapter 10, but is now Chapter 11.

Please note that because the FreeBSD Developer's Handbook is a work in progress, in the future, the chapter about kernel debugging may no longer be Chapter 11.