> For the complete documentation index, see [llms.txt](https://freebsd-journal-cn.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://freebsd-journal-cn.bsdcn.org/20170506-an-quan/book-review-designing-bsd-rootkits.md).

# 书评：Designing BSD Rootkits: An Introduction to Kernel Hacking

作者：Steven Kreuzer

**Designing BSD Rootkits: An Introduction to Kernel Hacking**，Joseph Kong 著

* 出版社：No Starch Press（2007）
* 纸质版定价：29.95
* 电子版定价：23.95
* ISBN-10：1593271425
* ISBN-13：978-1593271428
* 页数：142 页

很难相信，距离我在本地书店偶然发现 Joseph Kong 所著的 **Designing BSD Rootkits** 已经过去 10 年了。这不仅是一本讲述我觉得相当迷人的技术话题的书，而且它还采用 FreeBSD 作为参考平台！由于本期的主题是安全，我觉得翻出收藏的副本重新读一读会很有趣。

读到这里你可能会问，rootkit 究竟是什么？攻击者一旦未经授权访问你的系统，目标通常是避免被发现，并尽可能长时间地控制这台机器。这一般通过部署 rootkit 来实现，rootkit 是一组工具集，用于隐藏入侵痕迹并维持特权访问。本书虽然聚焦 FreeBSD 操作系统，但涵盖的概念同样适用于其他操作系统。即便你日常并不使用 FreeBSD，仍能从中获得关于计算机安全的宝贵见解，这些见解几乎可以应用到任何系统。

我喜欢这本书的一点是直奔主题。第一章直接切入可加载内核模块这一话题，它是把双刃剑：让系统管理员无需重启即可为运行中的系统添加功能，但攻击者也能用它加载恶意代码以掩盖踪迹。Kong 毫不拖泥带水，在本书第四页就给出了一个精简的内核模块，你可以在自己的机器上构建、加载和卸载它。遵循教程式的编排，每一章都在前一章的基础上循序渐进，引入更高级的功能。到本书结尾，你那个只打印“Hello, world!”的简单内核模块，将变成一个完整可用的 rootkit，能够规避 tripwire 等基于主机的入侵检测系统。最后一章从攻击转向防御，专门讨论 rootkit 的检测。有趣的是，这也是全书第二短的章节，示例代码寥寥无几。整体主题是：一旦 rootkit 就位，检测绝非易事。用于检测 rootkit 的软件，同样可能被它要寻找的 rootkit 所颠覆；而内核是个非常庞大的空间，提供了大量藏身之处。不过，既然你现在对底层究竟发生了什么有了更深入的理解，一旦不得不与 rootkit 较量，你将处于更有利的位置。

本书虽然薄，只有 142 页，却设法容纳了丰富的信息和示例代码。要从本书获得最大收益，具备一定的 C 和汇编基础以及对 FreeBSD 内核内部的了解会有所帮助。不过我发现 Kong 的教程式写法加上注释详尽的代码示例，让这些概念变得极易上手。每一章都为他涵盖的每个主题提供了至少一个真实应用场景，这让你更容易在示例的基础上自行实验和扩展。你可以在几个小时内通读全书，但我强烈建议你坐在电脑前，手边放着这本书，亲手摆弄提供的示例。当你不断加载和卸载一个为非作歹而设计的内核模块时，很容易不知不觉就消磨掉好几个小时。

不要因为本书出版于十年前就望而却步。它不仅是 FreeBSD 内核模块编程的出色入门，所介绍的方法和策略至今仍在使用。需要注意的一点是，FreeBSD 已经发生了很大变化，作者写作本书时使用的是 32 位平台上的 FreeBSD 6.0-STABLE。并非所有代码示例都能在较新的系统上正确编译，因此调试和更新这些示例就成了留给读者的练习。综上所述，我强烈建议你在书架上添置一本。•

***

**STEVEN KREUZER** 是 FreeBSD 开发者和 Unix 系统管理员，对复古计算和风冷大众汽车感兴趣。他与妻子、两个女儿和一只狗住在纽约皇后区。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://freebsd-journal-cn.bsdcn.org/20170506-an-quan/book-review-designing-bsd-rootkits.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
