【参考】
https://sys-guard.com/post-15162/
(ここほぼそのまま)
【作業メモ】
rootkithunterのセキュリティデータベースアップデート
以下に示す
rkhunter --propupd rkhunter --update
を実行したらエラーが出たりしたので、/etc/rkhunter.confファイルで回避した。
cp -p /etc/rkhunter.conf /etc/rkhunter.conf.org vi /etc/rkhunter.conf →(中略) →変更後変更内容確認 diff /etc/rkhunter.conf /etc/rkhunter.conf.org 587c587 < # SCRIPTWHITELIST=/usr/bin/GET --- > SCRIPTWHITELIST=/usr/bin/GET 590d589 < XINETD_ALLOWED_SVC=/etc/xinetd.d/xproftpd
→設定ファイルを編集したら、「rkhunter --propupd」を実行
システムファイルの情報アップデート
rkhunter --propupd
[ Rootkit Hunter version 1.4.2 ] File created: searched for 170 files, found 144
検知対象情報アップデート
rkhunter --update
[ Rootkit Hunter version 1.4.2 ] Checking rkhunter data files... Checking file mirrors.dat [ No update ] Checking file programs_bad.dat [ Updated ] Checking file backdoorports.dat [ No update ] Checking file suspscan.dat [ Updated ] Checking file i18n/cn [ No update ] Checking file i18n/de [ Updated ] Checking file i18n/en [ No update ] Checking file i18n/tr [ Updated ] Checking file i18n/tr.utf8 [ Updated ] Checking file i18n/zh [ Updated ] Checking file i18n/zh.utf8 [ Updated ]
初回チェック
rkhunter -c --rwo --sk
-c チェック --sk エンターキー要求をスキップ --rwo 警告のみ表示
定期実行スクリプトの設置
vi /hoge/rkhunter.sh
#!/bin/sh ## ------------------------------- MAILTO=hoge@fugafuga.com ## ------------------------------- MAILBODY=`mktemp /tmp/temp.XXXXXX` # rootkit判定データベース更新 /usr/bin/rkhunter --update > /dev/null 2>&1 # チェック実行 異常があればメールを行う /usr/bin/rkhunter -c --sk --cronjob --rwo 2>&1 > $MAILBODY if [ -s $MAILBODY ]; then mail -s "[Rootkit Hunter] `hostname` `date +%Y-%m-%d`" $MAILTO < $MAILBODY fi rm -f $MAILBODY
実行権限をつけて実行
chmod +x /hoge/rkhunter.sh sh /hoge/rkhunter.sh
# 証明書の自動更新 1日1回
crontab -e
10 4 * * * /srv/bin/rkhunter.sh > /dev/null 2>&1
# 初回実行後にアカウントを追加したりしていると以下のようなメールが来る
[Rootkit Hunter] hogehoge.jp 2018-08-27 Warning: User 'zabbix' has been added to the passwd file. Warning: Group 'zabbix' has been added to the group file.