<?xml version="1.0" encoding="UTF-8" ?><oembed><version>1.0</version><provider_name>Jui-Nan Lin&#039;s Blog</provider_name><provider_url>https://jnlin.org</provider_url><author_name>jnlin</author_name><author_url>https://jnlin.org/author/jnlin/</author_url><title>FreeBSD 系統的 auditd</title><html>上個月的 17 日，&lt;a href=&quot;http://www.freebsd.org/news/2012-compromise.html&quot;&gt;FreeBSD.org cluster 中的兩台機器被入侵&lt;/a&gt;，起因是擁有這兩台機器 root 權限的人的 ssh private key 外洩，導致這兩台主機被不明人士登入。由於這兩台主機上有開啟 &lt;a href=&quot;http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/audit.html&quot;&gt;Audit&lt;/a&gt; 機制，因此管理員發現了 root 有異常存取 file system 的行為。今天剛好有空，於是也來幫主機加上 audit 的機制。

步驟非常簡單，&lt;a href=&quot;http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/audit-install.html&quot;&gt;只要根據 handbook 重新編譯 Kernel&lt;/a&gt;，設定 &lt;code&gt;/etc/security&lt;/code&gt; 下的設定檔，再把 &lt;code&gt;auditd&lt;/code&gt; 跑起來就可以了。不過一開始跑起來之後並沒有紀錄 Log，花了一點時間找資料，才發現原來是 &lt;code&gt;auditd&lt;/code&gt; 跑起來之後，必須要重新登入，才會開始紀錄。

auditd 產生的紀錄大概長這樣：
&lt;code&gt;
header,84,11,sudo(1),0,Tue Dec 25 00:00:38 2012, + 49 msec
subject_ex,jnlin,root,wheel,jnlin,1001,93339,93339,42554,192.168.128.100
exec arg,ls,-al
return,success,0
trailer,84
&lt;/code&gt;

參考資料：&lt;a href=&quot;https://blog.delphij.net/2012/12/freebsdorg-2.html&quot;&gt;FreeBSD 這次的入侵事件&lt;/a&gt;</html><type>rich</type></oembed>