LoginSignup
33
37

More than 5 years have passed since last update.

ファイル改ざん検知ツール OSSEC

Last updated at Posted at 2016-08-21

OSSEC

https://ossec.github.io/
OSSEC は inotify を利用したリアルタイムのファイル改ざん検知ができる HIDS である。
OSSEC は Daniel B. Cid によって書かれ2004年に公開された。その後2008年に Third Brigade 社が取得し、2009年にさらにそれを Trend Micro 社が買収した。

HIDS

OSSEC 以外の主な HIDS は以下の通り。

  • AFICK 3.6.0 (2017/12/08) - SourceForge に rpm パッケージがある。
  • AIDE 0.16 (2016/07/25) - CentOS の Base リポジトリにある。
  • OSSEC 3.0.0 (2018/07/17) - inotify 対応。Atomic リポジトリにある。
  • Samhain 4.3.1 (2018/09/25) - inotify 対応。要コンパイル。
  • Tripwire 2.4.3.7 (2018/03/31)- EPEL リポジトリにある。

インストール

OSSEC HIDS Server のインストール

yum install -y epel-release wget && curl -s http://www.atomicorp.com/installers/atomic | sh && yum install -y ossec-hids-server

inotify-tools は EPEL リポジトリの方が新しい。
また Atomic リポジトリはスクリプト内で wget を使用しているのでコマンドがないとエラー出力なしでこける。
ossec-hids パッケージは指定しないでも依存関係でインストールされる。

ossec-configure

/var/ossec/bin/ossec-configure

ossec-hids パッケージに含まれる ossec-configure コマンドで、対話式による設定ファイルの更新ができる。

OSSEC Configuration utility v0.1

1- What kind of installation do you want? (server, agent, local) [Default: server]: local

2- Setting up the configuration environment.

3- Configuring the OSSEC HIDS.

  3.1- Do you want e-mail notification? (y/n) [Default: y]:
   - What's your e-mail address? root@localhost
   - What's your SMTP server ip/host? localhost

  3.2- Do you want to run the integrity check daemon? (y/n) [y]:

  3.3- Do you want to run the rootkit detection engine? (y/n) [y]:

  3.4- Active response allows you to execute a specific
       command based on the events received. For example,
       you can block an IP address or disable access for
       a specific user.
       More information at:
       http://www.ossec.net/en/manual.html#active-response


   - Do you want to enable active response? (y/n) [y]: n

  3.5- Do you want to enable remote syslog (port 514 udp)? (y/n) [y]:

    -- /var/log/messages (syslog)
    -- /var/log/secure (syslog)
    -- /var/log/maillog (syslog)
    -- /var/log/httpd/error_log (apache log)
    -- /var/log/httpd/access_log (apache log)
Configuration complete.

/var/ossec/etc/ossec.conf が更新され、旧ファイルは /var/ossec/etc/ossec.conf.bak として保存される。
一般的にサーバー/クライアント型として紹介されるが、最初の質問で local と回答すると単独で動作する。

リアルタイム監視の有効化

sed -i.org '/directories check_all/s/"yes"/"yes" realtime="yes"/' /var/ossec/etc/ossec.conf
systemctl start ossec-hids && systemctl enable $_
tailf /var/ossec/logs/ossec.log

ログに Real time file monitoring started. と出力されるまでリアルタイム監視は開始されない。検証環境では開始まで10分程度かかった。

http://ossec-docs.readthedocs.io/en/latest/manual/syscheck/#realtime-options
http://ossec-docs.readthedocs.io/en/latest/manual/syscheck/#real-time-monitoring

OSSEC Web UI

https://github.com/ossec/ossec-wui
README には「OSSEC Web UI は現在メンテナンスされておらず、非推奨。アラート監視には Kibana か Splunk または同様のプロジェクトを使用することを勧める」との記載。

Atomic リポジトリに ossec-wui パッケージが一応あるが、あまりパッケージのメリットがないので GitHub から最新を取得する。

yum -y install php{,-gd}
sed -i.org 's|;date.timezone =|date.timezone = Asia/Tokyo|' /etc/php.ini
curl -L https://github.com/ossec/ossec-wui/archive/master.tar.gz -o ossec-wui.tar.gz
tar vzxf ossec-wui.tar.gz --strip=1 -C /var/www/html && cd /var/www/html
./setup.sh
Setting up ossec ui...

Username: <username>
New password: <password>
Re-type new password: <password>
Adding password for user ossec
Enter your web server user name (e.g. apache, www, nobody, www-data, ...)
apache
You must restart your web server after this setup is done.

Setup completed successfully.
chown apache. -R /var/www/html
chcon -t httpd_sys_content_t /var/ossec
chcon -R -t httpd_sys_content_t /var/ossec/{logs,stats,queue/{agent-info,syscheck}}
systemctl start httpd && systemctl enable $_
firewall-cmd --permanent --add-service=http{,s} && firewall-cmd --reload

セキュリティ関連記事

33
37
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
37