mod_securityのコンソールツールである、AuditConsoleを追加します。
AuditConsole自体の機能などは、公式ページに記載があるので、そちらを参照ください。
https://www.jwall.org/web/audit/console/index.jsp
インストール方法はユーザーズガイドを参照ください。
https://secure.jwall.org/AuditConsole/user-guide/
■インストール対象の環境
Cent7.5
httpd+mod_security
この環境作成については、こちらを参照ください。
■javaのインストール
1.7が必要となります。パッケージを探します。
# yum list|grep jdk
copy-jdk-configs.noarch 3.3-10.el7_5 @updates
java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 @updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.181-3.b13.el7_5 @updates
java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base
java-1.6.0-openjdk-demo.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base
java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base
java-1.6.0-openjdk-src.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base
java-1.7.0-openjdk.x86_64 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.7.0-openjdk-accessibility.x86_64 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.7.0-openjdk-src.x86_64 1:1.7.0.181-2.6.14.8.el7_5 updates
java-1.8.0-openjdk.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-accessibility-debug.x86_64
java-1.8.0-openjdk-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-javadoc-zip-debug.noarch 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src-debug.i686 1:1.8.0.181-3.b13.el7_5 updates
java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.181-3.b13.el7_5 updates
ldapjdk.noarch 4.19-5.el7 base
ldapjdk-javadoc.noarch 4.19-5.el7 base
#
java-1.7.0-openjdk.x86_64をインストールします
# yum install java-1.7.0-openjdk.x86_64
■jwallリポジトリの作成
repoファイルを作成してリポジトリを作成します。
# cd /etc/yum.repos.d/
# vi jwall.repo
[jwall]
name=CentOS-jwall - jwall.org packages for noarch
baseurl=http://download.jwall.org/yum/jwall
enabled=1
gpgcheck=1
protect=1
# rpm --import http://download.jwall.org/chris.gpg
作成したリポジトリ設定を使ってauditconsleをインストールします
# yum install auditconsole 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * remi-safe: ftp.riken.jp * updates: ftp.riken.jp jwall | 2.9 kB 00:00:00
jwall/primary_db | 13 kB 00:00:00
依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ auditconsole.noarch 0:0.4.7-1 を インストール --> 依存性の処理をしています: auditconsole-server のパッケージ: auditconsole-0.4.7-1.noarch --> トランザクションの確認を実行しています。 ---> パッケージ auditconsole-server.noarch 0:0.4-3 を インストール --> 依存性解決を終了しました。 依存性を解決しました ============================================================================================================= Package アーキテクチャー バージョン リポジトリー 容量
============================================================================================================= インストール中: auditconsole noarch 0.4.7-1 jwall 57 M 依存性関連でのインストールをします: auditconsole-server noarch 0.4-3 jwall 6.9 M トランザクションの要約 ============================================================================================================= インストール 1 パッケージ (+1 個の依存関係のパッケージ) 総ダウンロード容量: 64 M インストール容量: 83 M Is this ok [y/d/N]: y Downloading packages: (1/2): auditconsole-server-0.4-3.noarch.rpm | 6.9 MB 00:00:19 (2/2): auditconsole-0.4.7-1.noarch.rpm | 57 MB 00:02:30 ・ (中略) ・ インストール: auditconsole.noarch 0:0.4.7-1 依存性関連をインストールしました: auditconsole-server.noarch 0:0.4-3 完了しました! #
■JAVA_HOMEの追記
vi /etc/default/auditconsole # # The standard port for accepting http connections# # CONSOLE_HTTP_PORT=8080 # The port where the console listens for https connections # CONSOLE_HTTPS_PORT=8443 export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre
ポート番号を変えたい場合にはここの設定で変えておく(デフォルトでは8080と8443)。
# systemctl start auditconsole
http://localhost:8080にアクセスして初期設定をする。
■参考
以下のエラーがでる場合はJAVAのVerが1.7になっていないのが原因です。
JAVA_HOMEの指定で1.7を指定するように修正します。
2018/08/18 21:35:27 org.apache.tomcat.util.modeler.Registry registerComponent
SEVERE: Null component AuditConsole:type=JspMonitor,name=jsp,WebModule=//localhost/,J2EEApplication=none,J2EEServer=none
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.UnsupportedClassVersionError: org/jwall/web/audit/console/AuditConsoleContextListener : Unsupported major.minor version 51.0 (unable to load class org.jwall.web.audit.console.AuditConsoleContextListener)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1854)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:73)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:56)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1068)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4339)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
... 6 more
/
https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi
J2SE 8 = 52, J2SE 7 = 51, J2SE 6.0 = 50, J2SE 5.0 = 49, JDK 1.4 = 48, JDK 1.3 = 47, JDK 1.2 = 46, JDK 1.1 = 45
うまく起動している場合には以下のログが出力されています。
# cat /opt/AuditConsole/logs/tomcat.log
8 18, 2018 9:55:33 午後 org.apache.catalina.core.AprLifecycleListener init
情報: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
8 18, 2018 9:55:33 午後 org.apache.coyote.http11.Http11Protocol init
情報: Coyote HTTP/1.1を http-8080 で初期化します
8 18, 2018 9:55:34 午後 org.apache.coyote.http11.Http11Protocol init
情報: Coyote HTTP/1.1を http-8443 で初期化します
8 18, 2018 9:55:34 午後 org.apache.catalina.startup.Catalina load
情報: Initialization processed in 1047 ms
8 18, 2018 9:55:34 午後 org.apache.catalina.realm.JAASRealm setContainer
情報: Set JAAS app name AuditConsole
8 18, 2018 9:55:34 午後 org.apache.catalina.core.StandardService start
情報: サービス AuditConsole を起動します
8 18, 2018 9:55:34 午後 org.apache.catalina.core.StandardEngine start
情報: Starting Servlet Engine: Apache Tomcat/6.0.20
#
auditcosole画面で、mod_securityのログと連携する設定を入れていきます。
■Sensor設定
[System]→[sensoers]でSensor作成画面に移動し、[add Sensor]ボタンをクリックして、sensoerを作成します。
Sensorの詳細情報を入力します。「Sensor Name」「Sensor Password」はmlogc設定時に必要となります。
■mlogc設定
必要な設定項目とSensor作成時の項目名マッピング
項目 | 説明 | Sensor設定時の項目名 |
ConsolURI | AuditConsoleのセンサーURI | ー |
SensorUsername | 上記URIへアクセスするときのユーザ名 | Sensor Name |
SensorPassword | 上記URIへアクセスするときのパスワード | SensorPassword |
mlogc.confの設定を行います。
# vi /etc/mlogc.conf ########################################################################## # Required configuration # At a minimum, the items in this section will need to be adjusted to # fit your environment. The remaining options are optional. ########################################################################## # Points to the root of the installation. All relative # paths will be resolved with the help of this path. CollectorRoot "/var/log/mlogc" # ModSecurity Console receiving URI. You can change the host # and the port parts but leave everything else as is. #ConsoleURI "https://localhost:8888/rpc/auditLogReceiver" ConsoleURI "http://localhost:8080/rpc/auditLogReceiver" ←ホスト名(IPアドレス)とポート番号部分を変更する # Sensor credentials SensorUsername "username" ←Sensor作成で入力したSensor Name SensorPassword "password" ←Sensor作成で入力したSensor Password # Base directory where the audit logs are stored. This can be specified # as a path relative to the CollectorRoot, or a full path. LogStorageDir "data" # Transaction log will contain the information on all log collector # activities that happen between checkpoints. The transaction log # is used to recover data in case of a crash (or if Apache kills # the process). TransactionLog "mlogc-transaction.log" # The file where the pending audit log entry data is kept. This file # is updated on every checkpoint.
■apache設定
mod_security設定ファイルに以下を追加します。
# vi /etc/httpd/conf.d/mod_security.conf
# Use ReleventOnly auditing
SecAuditEngine RelevantOnly
# Must use concurrent logging
SecAuditLogType Concurrent ←変更
# Send all audit log parts
SecAuditLogParts ABIDEFGHZ
# Use the same /CollectorRoot/LogStorageDir as in mlogc.conf ←追加
SecAuditLogStorageDir /var/log/mlogc/data ←追加
# Pipe audit log to mlogc with your configuration ←追加
SecAuditLog "|/usr/bin/mlogc /etc/mlogc.conf" ←変更
最後にapacheとauditconsoleを再起動します。
# systemctl restart httpd # systemctl restart auditconsole
自動起動設定をします
#chkconfig auditconsole on