Sophos Central Server ProtectionでAmazon Linux(EC2)を保護する

2017.01.23

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

西澤です。AWS環境のマルウェア対策ソリューションとしてSophos Centralから利用できるServer Proctectionを試す機会がありましたので、ご報告します。前回のWindowsの保護に続いて、今回はAmazon Linuxの保護を試してみます。

Sophos Centralの説明や基本的な使い方については、前回のものと重複する為、まずは下記記事からご覧いただければ理解がスムーズかと思います。

Amazon Linuxをマルウェアから保護する

エージェントのインストール

Sophos Centralにログインして、"デバイスの保護"->"サーバープロテクション"からエージェントのインストーラをダウンロードするところは、Windowsと同様です。

Sophos_Central_001

インストーラを配置したら、スクリプトをroot権限で実行します。

$ sudo sh ./SophosInstall.sh
Installing Sophos Anti-Virus for Linux with arguments: []
Downloading medium installer
Checking we can connect to Sophos Cloud (at https://dzr-mcs-amzn-us-west-2-fa88.upe.p.hmr.sophos.com/sophos/management/ep)...
Finished downloading the medium installer.
Running medium installer (this may take some time)
Starting Sophos Linux Security daemon: [  OK  ]
Updating from your own server.
Extra files updating is disabled. You can change updating settings using /opt/sophos-av/bin/savsetup.

Installing Sophos Linux Security....
Selecting appropriate kernel support...
When Sophos Linux Security starts, it updates itself to try to find a Sophos kernel interface module update. This might cause a significant delay.
Sophos Linux Security starts after installation.

Installation completed.
On-access scanning not available. It was not possible to obtain or build suitable kernel support because gcc is not installed.
Sophos Anti-Virus のアップデートに失敗しました
Saving Sophos Cloud credentials
Registering with Sophos Cloud
Starting Sophos Cloud Management Client
Starting Sophos Management Agent:                          [  OK  ]
Now managed by Sophos Cloud

あっけなく完了しました。Sophos Centralからも確認してみます。

sophos_linux_001

sophos_linux_002

起動スクリプトやサービス状況を確認してみましょう。

$ chkconfig --list | grep sav
sav-protect    	0:off	1:off	2:on	3:on	4:on	5:on	6:off
sav-rms        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

$ ls -la /etc/init.d/sav*
-rwx------ 1 root root 3308 Jan 20 12:03 /etc/init.d/sav-protect
-rwx------ 1 root root 1931 Jan 20 12:03 /etc/init.d/sav-rms

$ sudo service sav-protect
Usage: /etc/init.d/sav-protect {start|stop|restart|status}

$ sudo service sav-protect status
Sophos Linux Security daemon is active

$ sudo service sav-rms
Usage: /etc/init.d/sav-rms {start|stop|restart|status}

$ sudo service sav-rms status
Sophos Remote Management Service is active

起動されるデーモンは以下の通りです。

$ ps auxx | grep sav | grep -v grep
root     26553  0.0  1.7 651932  8844 ?        Sl   12:03   0:00 savd etc/savd.cfg
sophosav 26999  0.0  3.3 193588 17068 ?        S    12:06   0:00 sophosmgmtd -c import sophosmgmtd.sophosmgmtd,sys;sys.exit(sophosmgmtd.sophosmgmtd.main(sys.argv)) --daemon --RMS=0
root     27401  0.0  2.5 326584 12736 ?        Sl   12:06   0:00 savscand --incident=unix://tmp/incident --namedscan=unix://root@tmp/namedscansprocessor.1 --ondemandcontrol=socketpair://49/50

オンラインスキャンの有効化

それでは、エージェント専用のコマンドでバージョン確認と状態確認をしてみます。

$ sudo /opt/sophos-av/bin/savdstatus --version
Copyright 1989-2016 Sophos Limited. All rights reserved.
Sophos Linux Security = 10.0.1
ビルドのリビジョン             = 2629482
脅威検出エンジン              = 3.67.3
脅威データ                 = 5.35
検出脅威数                 = 12593265
脅威データリリース日            = 2017年01月10日 00時00分00秒

バージョン確認は問題ありませんでした。

$ sudo /opt/sophos-av/bin/savdstatus --verbose
Sophos Linux Security デーモンはアクティブです
オンアクセス検索は実行されていません

オンアクセススキャンが動いていないようです。よくよく確認するとAmazon Linuxは、"オンアクセスおよびオンデマンドスキャンに対応するディストリビューション (ソフォスが Talpa バイナリパックを提供していないもの)"という位置付けであることがわかりました。インストーラ実行時にも、"On-access scanning not available."と出力されていましたね。

Talpaバイナリパックのコンパイルはやりたくなかったので、今回は"Fanotify"を利用する方式で変更してみました。

公式ページに載っている手順の通りですが、前後に確認コマンドも追加しています。それぞれパラメータが変更されていることがわかると思います。

$ sudo /opt/sophos-av/bin/savconfig get DisableFanotify
オン
$ sudo /opt/sophos-av/bin/savconfig set DisableFanotify false
$ sudo /opt/sophos-av/bin/savconfig get DisableFanotify
オフ

$ sudo /opt/sophos-av/bin/savconfig get PreferFanotify
オフ
$ sudo /opt/sophos-av/bin/savconfig set PreferFanotify true
$ sudo /opt/sophos-av/bin/savconfig get PreferFanotify
オン

$ sudo /etc/init.d/sav-protect restart
Stopping Sophos Linux Security daemon:                     [  OK  ]
Starting Sophos Linux Security daemon:                     [  OK  ]

無事にオンアクセス検索を有効にすることができました。

$ sudo /opt/sophos-av/bin/savdstatus --verbose
Sophos Linux Security デーモンはアクティブです
オンアクセス検索を実行中です

sophos_linux_003

EICARテストファイルによる検出テスト

それでは、Windowsと同様に、オンラインでの検出テストをやってみます。

$ curl -O http://www.eicar.org/download/eicar.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file eicar.com:
Warning: 許可されていない操作です
100    68  100    68    0     0     75      0 --:--:-- --:--:-- --:--:--    75
curl: (23) Failed writing body (0 != 68)
[ec2-user@ip-10-200-1-247 ~]$
******************** Sophos Linux Security 警告 ********************
脅威 "EICAR-AV-Test" が次のファイルで検出されました
"/home/ec2-user/eicar.com".

ファイルへのアクセスが拒否されました

**********************************************************************

問題なく動作することが確認できました。

まとめ

前回のWindowsの保護に続き、Amazon Linuxの保護も試してみました。WindowsもLinuxもいずれの保護も可能で、管理サーバなしで導入ができるのがとても良いですね。次回は、Auto Scaling環境の保護についてレポートする予定です。

どこかの誰かのお役に立てば嬉しいです。