tripwire 架設與管理
Ubuntu 16.04 架設
1. 安裝 tripewire 套件
apt install tripwire
設定 postfix
光溜溜的 Ubuntu 在安裝 tripwire 時,會同時安裝 postfix,還自動引導設定

詢問mail server 用途,towns 選了第三項。不知道衛星系統是什麼呢?

主機名稱,一般來說,如果在架設 Ubuntu 系統時,有設定名稱及 Domain,這個值會自動帶入

towns 選了第三項,所以會有 relay host 設定
設定 tripwire
說明架設需設定的流程,及參考資料

在設定過程中是否同時產生 site key

重建設定檔

重建規則檔

產生 site-key 並建立密碼

再打一次密碼
產生 local-key 並建立密碼
再打一次密碼
完成安裝
2. 建立資料庫檔
tripwire --init 
使用預設的規則檔建立資料庫時,會產生很多的 error 主要是因為預設規則檔有很多不必需要的設定
建立完成
3. 調整規則(選用)
vi /etc/tripwire/twpol.txt
在建立時產生的錯誤,可以用來調整不需要的規則設定
4. 重建資料庫檔(選用)
twadmin --create-polfile -S /etc/tripwire/site.key /etc/tripwire/twpol.txt <== 重建規則加密檔
tripwire --init <== 重建資料庫
這次的重建,就不會出現大量的錯誤了
5. 測試產生報告
tripwire --check > /home/towns/tripwire_test.txt
twprint --print-report -r /var/lib/tripwire/report/towns-test-centos7-20171121-110311.twr > /home/towns/tripwire_test_2.txt
6. 測試發信
tripwire --test --email <email address>
註1:調整 postfix main.cf 檔中 inet_interfaces = 改為 127.0.0.1
註2:如果有仔細看內容(別擔心是英文的),一定看的懂是要設什麼
CentOS 7 架設
1. 安裝 tripwire 套件
yum install tripwire
2. 建立 key、設定檔及規則檔
tripwire-setup-keyfiles
在建立 keyfile 前,tripware 設定檔路徑中,只有這兩個檔案

建立 keyfile 時,會同時要求產生 sit key 及 local key
key 建立後,會建立加密的設定檔及規則檔
建立完成後,在設定路徑中會多出 key 檔及加密的設定檔
3. 建立資料庫檔
tripwire --init
3. 調整規則(選用)
vi /etc/tripwire/twpol.txt
在建立時產生的錯誤,可以用來調整不需要的規則設定
4. 重建資料庫檔(選用)
twadmin --create-polfile -S /etc/tripwire/site.key /etc/tripwire/twpol.txt <== 重建規則加密檔
tripwire --init <== 重建資料庫
這次的重建,就不會出現大量的錯誤了
6. 測試產生報告
tripwire --check > /home/towns/tripwire_test.txt
twprint --print-report -r /var/lib/tripwire/report/towns-test-centos7-20171121-110311.twr > /home/towns/tripwire_test_2.txt
7. 測試發信
tripwire --test --email <email address>
註:安裝 tripwire 必需先安裝 epel 的 repo
常用指令、參數說明
tripwire --test --email <email address> <== 測試 tripwire 發信是否正常
如果正常,收到內容為 If you receive this message, email notification from tripwire is working correctly. 的信件
twprint --print-dbfile <== 查看資料庫內容
twadmin --print-polfile > /etc/tripwire/twpol.txt <== 匯出目前規則檔
twadmin --print-cfgfile > /etc/tripwire/twcfg.txt <== 匯出目前設定檔
twadmin --create-polfile -S /etc/tripwire/site.key /etc/tripwire/twpol.txt <== 重建修改後的規則檔
twadmin --create-cfgfile -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt <== 重建修改後的設定檔
檔案路徑
DBFILE =/var/lib/tripwire/$(HOSTNAME).twd
REPORTFILE =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr
Ubuntu 及 CentOS 設定檔的差異

Ubuntu 的設定檔

CentOS 的設定檔
差別只有發信設定不同,Ubuntu 是登入 SMTP 發信,CentOS 是使用指令發信
寄送信件問題
如果要 tripwire 自動發信,記得在設定檔中(twcfg.txt)加入 GLOBALEMAIL =<mail address> 參數,並確認每日執行檔(/etc/cron.daily/tripwire-check)是否有加 --email-report,這樣 tripwire 在執行後,就會自動發信給指定信箱了
註1:如果要發送給多人可以用 , 或 ; 區隔
註2:預設的設定檔並沒有將這個值寫入,雖然執行檔中有加入 --email-report 仍然是不會寄信的
註3:如果要寄給 root 就在設定檔中這樣寫 GLOBALEMAIL =root
參考資料:
CentOS7 tripwire 執行檔 /etc/cron.daily/tripwire-check
參考資料:
楊中皇先生文章
http://crypto.nknu.edu.tw/netsec/using-Tripwire.htm
CSX -- 詳細教學
https://www-uxsup.csx.cam.ac.uk/pub/doc/redhat/redhat7.3/rhl-rg-en-7.3/ch-tripwire.html
http://www.rocksclusters.org/roll-documentation/area51/4.1/using-tripwire.html
留言
張貼留言