Fortigate のログを Microsoft Sentinel( 旧Azure Sentinel )へ転送する方法を記述します。
参考
Technical Tip: Integrate FortiGate with Microsoft Sentinel
構成
これには Fortigate と Sentinel との間に syslog( rsyslog または syslog-ng )と Log Analytics Agent がインストールされている Linux サーバが必要です。このサーバを以降はログフォーワーダーと呼びます。
Log Analystics は Sentinel を利用する上で必要なサービスなので Sentinel の一部と考えてください。Sentinel は作成済みの前提で進めます。
ログフォーワーダーの準備
必要なサーバスペックは以下のリンクを参照してください。
ログ フォワーダーをデプロイして Syslog および CEF ログを Microsoft Sentinel に取り込む
Syslogデーモンを起動し、TCPの514ポートを許可しておいてください。
私はAzureで立てました。手順を以下に記述しておきます。
Azure に Ubuntu を立てる
Azure の Virtual Machineを立てたので手順を書きます。仮想ネットワーク作成
仮想ネットワークのホームに行き、「仮想ネットワークの作成」をクリックします。
リソースグループを選択し、インスタンスの詳細の名前、地域に任意の値を設定します。「確認及び作成」をクリックします。
検証が始まるので、終わったら「作成」をクリックします。
仮想ネットワークが作成されました。
Virtual Machines 作成
Virtual Machines のホームに行き、「作成」>「仮想マシン」をクリックします。
リソースグループを選択し、仮想マシン名に任意の名前を設定します。その他はデフォルトです。必要マシンスペック( 4cpu,8Gメモリ )に足りていませんが、これでも動きます。本番利用ではスペックに上げるようにしてください。「確認および作成」をクリックします。
検証が始まるので、終わったら「作成」をクリックします。
秘密鍵をダウンロードしておきます。
デプロイが完了しました。
ssh で接続し apt パッケージを更新しておきます。
$ sudo apt update && sudo apt upgrade -y
TCP 514 ポート開放
Virtual Machine を立てたリソースグループに移動し、ネットワークセキュリティーグループをクリックします。
「受信セキュリティー規則」>「+追加」をクリックします。以下を入力し、「追加」をクリックします。以下を入力し、「追加」をクリックします。
宛先ポート範囲:514
プロトコル:Any or TCP
アクション:許可
名前:任意
データコネクタを作成
Microsoft Sentinel の「データコネクタ」>「Fortinet」>「コネクタページを開く」をクリックします。
手順が右ペインに表示されるので、それに従って Agent をインストールします。
Log Analystics Agent をインストール
インストールには python と sudo 実行権限が必要です。
python
Azure の Ubuntu( Ubuntu 20.04.3 LTS ) は python3 はインストールされていますが python はインストールされていないので、python-is-python3
をインストールし python コマンドで実行できるようにしてます。
$ python --version
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
$ python3 --version
Python 3.8.10
$ sudo apt install python-is-python3
$ python --version
Python 3.8.10
sudo
sudoが使用できない場合は管理者に追加してもらってください。
# sudoが表示されれば使用できます。
$ groups
azureuser adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd
Analystics Agent
$ sudo wget -O cef_installer.py https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/DataConnectors/CEF/cef_installer.py&&sudo python cef_installer.py 87afb840-ce4b-4ab7-8f0c-6b052b67dd3a Z436dK3JXcSIsvDaCB5fLmSpBP7VnswqC+zHbY+fZmUTiW7B1Lht8vS8Mu31AV5vrMtFzG5MZelXQe3XBs2PtA==
Agent のインストールから各種設定までこのコマンドで実行されます。
以下に内部で何が行われているのか記述します。
インストール内容詳細
1.エージェントがインストールされます。
Installed omsagent successfully.
2.syslog が CEF のログを受信した場合、127.0.0.1:25226 へ転送するように設定されます。
Configuration for omsagent downloaded successfully.
Trying to change omsagent configuration
Omsagent configuration was changed to fit required protocol - /etc/opt/microsoft/omsagent/87afb840-ce4b-4ab7-8f0c-6b052b67dd3a/conf/omsagent.d/security_events.conf
Finished changing omsagent configuration
Located rsyslog daemon running on the machine
Creating rsyslog daemon configuration.
Configuration is changed to forward daemon incoming syslog messages into the omsagent.
Every command containing 'CEF' string will be forwarded.
Path:
/etc/rsyslog.d/security-config-omsagent.conf
Rsyslog daemon configuration content:
if $rawmsg contains "CEF:" or $rawmsg contains "ASA-" then @@127.0.0.1:25226
Configuration for rsyslog daemon was changed successfully.
Rsyslog.conf configuration was changed to fit required protocol - /etc/rsyslog.conf
Restarting rsyslog daemon.
sudo service rsyslog restart
Rsyslog daemon restarted successfully
3.OMS Agent も再起動されます。
Trying to restart omsagent
sudo /opt/microsoft/omsagent/bin/service_control restart 87afb840-ce4b-4ab7-8f0c-6b052b67dd3a
Omsagent restarted successfully
OMS Agent syslog field mapping is correct
4.インストールが完了しました。
(ログの重複と容量についての警告が表示されますが、対応が必要なのかちょっとわかりません。。。)
Your machine is auto synced with the portal. In case you are using the same machine to forward both plain Syslog and CEF messages, please make sure to manually change the Syslog configuration file to avoid duplicated data and disable the auto sync with the portal. Otherwise all changes will be overwritten.
To disable the auto sync with the portal please run: "sudo su omsagent -c 'python /opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py --disable'"
For more on how to avoid duplicated syslog and CEF logs please visit: https://docs.microsoft.com/azure/sentinel/connect-cef-agent?tabs=rsyslog
Warning: please make sure your logging daemon configuration does not store unnecessary logs. This may cause a full disk on your machine, which will disrupt the function of the oms agent installed. For more information:
https://www.rsyslog.com/doc/master/configuration/actions.html
Installation completed
設定ファイル
rsyslog は CEF フォーマットを 127.0.0.1:25226 へ転送します。
$ cat /etc/rsyslog.d/security-config-omsagent.conf
if $rawmsg contains "CEF:" or $rawmsg contains "ASA-" then @@127.0.0.1:25226
エージェントは syslog の CEF フォーマットを 25226ポートでlistenしています。
$ sudo cat /etc/opt/microsoft/omsagent/87afb840-ce4b-4ab7-8f0c-6b052b67dd3a/conf/omsagent.d/security_events.conf
<source>
type syslog
port 25226
bind 127.0.0.1
protocol_type tcp
tag oms.security
format /(?<time>(?:\w+ +){2,3}(?:\d+:){2}\d+|\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.[\w\-\:\+]{3,12}):?\s*(?:(?<host>[^: ]+) ?:?)?\s*(?<ident>.*CEF.+?(?=0\|)|%ASA[0-9\-]{8,10})\s*:?(?<message>0\|.*|.*)/
<parse>
message_format auto
</parse>
</source>
<filter oms.security.**>
type filter_syslog_security
</filter>
ポートの確認
$ sudo lsof -i -P | grep "rsyslog\|omsagent"
rsyslogd 11034 syslog 5u IPv4 53625 0t0 UDP *:514
rsyslogd 11034 syslog 6u IPv6 53626 0t0 UDP *:514
rsyslogd 11034 syslog 7u IPv4 53629 0t0 TCP *:514 (LISTEN)
rsyslogd 11034 syslog 8u IPv6 53630 0t0 TCP *:514 (LISTEN)
omsagent 11786 omsagent 13u IPv4 57985 0t0 TCP localhost:25226 (LISTEN)
omsagent 11786 omsagent 15u IPv4 57986 0t0 UDP localhost:25224
Fortigate
Microsoft の Docs にログの設定方法が載っていますが Fortigate はデフォルトで UDP なのでTCPを指定するようにしてください。
Microsoft Sentinel データ コネクタを見つける - Fortinet
config log syslogd setting
set status enable
set format cef
set port 514
set server <ip_address_of_Forwarder>
set mode reliable
end
確認
CommonSecurityLogという名前のテーブルに取り込まれます。
料金
以下の料金が発生します。
- Log Analystics データ投入費用
- Log Analystics データ保管費用
- Linux サーバ運用費用
また、Log Analystics のデータ保管期間の最大は720日なのでそれよりも長く保管したい場合、Azure Blob Storage などのストレージ使用料も発生しする可能性があります。