2017年01月

2017年01月31日
最近、通信ログの取得が重要視される場面がたまにあります。
個人的には、ログの取得は馬鹿にできないほどの負荷になったり、保存先のストレージサイズによってはすぐに枯渇したり。
ログを解析するには結構な手間が必要だったりと、技術的にクリアするべきこともたくさんあるように思っています。

しかしながら、たくさんの期間、なるべく詳細なログが取得できるのは素晴らしいですよね。

そして現実的な解決策としてはsyslogを利用することです。これを利用できる環境であれば、ストレージ容量もあまり心配しなくていいでしょうし、DBなどで管理しているのであれば、管理も検索もラクです。

Yamaha単体の場合。
最近のYamahaでは外部USBメモリにログを保存することができます。そしてそのUSBメモリの容量も結構大きいものまでいけるみたいですね。・・・動作確認のメモリを見ると、8Gとかっぽいのがありました。

参考
外部メモリファイルコピー機能

external-memory syslog filename usb1:rt_syslog.log

ローテートコマンドもあるようなのでこれも指定しておいた方がいいと思います。



2017年01月30日
手順は以下の参考サイトがとても詳しいです!
IISでLet's Encrypt を利用してSSLサイトを構築する (letsencrypt-win-simple クライアントを利用)

ポイントとしては、マニュアルで作成すること、拡張子の無いファイルを参照させようとするので、 web.config の作成が必要なことです。

僕の手順。
コマンドプロンプト
# cd D:\SSL_tool\letsencrypt-win-simple.V1.9.1

※引数なしで実行
# letsencrypt.exe
-- 略 --
Scanning IIS Site Bindings for Hosts
1: IIS XXXX (C:\inetpub\wwwroot\XXXX)

W: Generate a certificate via WebDav and install it manually.
F: Generate a certificate via FTP/ FTPS and install it manually.
M: Generate a certificate manually.
A: Get certificates for all hosts
Q: Quit
Which host do you want to get a certificate for: m

サイトが一つ見つかりました。しかしこれは、Default ではない別のサイトでした。今回はDefaultでホストしているサイトをSSL化したいので、Mを選択しました。

Enter a host name: XXXXXXXX
Enter a site path (the web root of the host for http authentication): C:\inetpub\wwwroot\

デフォルトでは wwwroot ディレクトリを公開対象としているので、上記の通り入力しました。 hostname はいわゆるコモンネームです。

******************************************************************************
The ACME server was probably unable to reach http://XXXXXXXX/.well-kn
own/acme-challenge/XXXXHCTOStd6M50jYG91I

Check in a browser to see if the answer file is being served correctly.

******************************************************************************
参考サイトと同様にエラーが出ました。これは今回のコマンドで作成されたファイルにwebからアクセスできないという内容のようです。
原因は拡張子がないため、IISのデフォルト設定では拒否されてしまいます。
.well-known/acme-challenge/ フォルダにアクセスし、web.config を作成します。記載内容については、一番最初に挙げた参考サイトの通りです。
以下の行が重要なようです。


IISの管理画面からでも可能です。acme-challenge のフォルダまでクリックし、「MIME の種類」をクリック。操作から追加をクリックし、ファイル名の拡張子に "." ドットを入力。MIMEの種類に text/plain と入力します。

上記でエラーが解決したので、もう一度コマンドラインの最初からやりなおしです・・。
とにかくこれでうまくいきました。最後にタスクスケジューラーのユーザー名などを聞かれるので、そのまま入力します。以下のコマンドが毎日9時で登録されていました。
[フルパス]letsencrypt.exe --renew --baseuri "https://acme-v01.api.letsencrypt.org/"

以下のフォルダを開いて確認します。
Saving Certificate to C:\Users\[USERNAME]\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\

IISのサーバー証明書にも追加されていたので、バインドから修正を行うとすぐに利用可能でした。


※その他の引数です。


--baseuri (Default: https://acme-v01.api.letsencrypt.org/) The address of the ACME server to use.
--accepttos Accept the terms of service.
--renew Check for renewals.
--test Overrides BaseUri setting to
https://acme-staging.api.letsencrypt.org/
--manualhost A host name to manually get a certificate for.
--webroot must also be set.
--webroot (Default: %SystemDrive%\inetpub\wwwroot) A web root for
the manual host name for authentication.
--script A script for installation of non IIS Plugin.
--scriptparameters Parameters for the script for installation of non IIS
Plugin.
--centralsslstore Path for Centralized Certificate Store (This enables
Centralized SSL). Ex. \\storage\central_ssl\
--hidehttps Hide sites that have existing HTTPS bindings
--san Certificates per site instead of per host
--keepexisting Keep existing HTTPS bindings, and certificates
--help Display this help screen.
--version Display version information.


2017年01月29日
MySQLではレプリケーション機能があります。
マスター / スレーブですね。

ということで、以下の方法で構築しました。

1. マスター / スレーブで Server-id の設定
マスター: server-id=1
スレーブ: server-id=2

マスター側では一緒に log-bin も入れておきます。
log-bin

2. レプリケーションユーザーの作成(マスター)
phpmyadmin で行ってしまいました。

select Host, User, Password from mysql.user;
+-------------+------+-------------------------------------------+
| Host | User | Password |
+-------------+------+-------------------------------------------+
| X.X.X.% | repl | XXXX

とりあえず、/24 の範囲で許可しておきます。

3. データのコピーを行う
・マスター側作業
テーブルをロックし、更新されないようにする
FLUSH TABLES WITH READ LOCK;

ログのポジションを確認する(Change Masterコマンドで利用します)
SHOW MASTER STATUS;

バックアップの取得(パスワードなどは適宜指定)
# mysqldump --all-databases --master-data > dbdump.db

テーブルのロックを解除する
mysql> UNLOCK TABLES;

上記で取得したバックアップファイルを、スレーブ側にコピー。

・スレーブ側作業
データインポート
mysql < fulldb.dump

以下のコマンドを実行し、マスターに接続するように設定する
CHANGE MASTER TO
MASTER_HOST='X.X.X.X',
MASTER_USER='repl',
MASTER_PASSWORD='XXXXXXX',
MASTER_LOG_FILE='mysqld-bin.000001',
MASTER_LOG_POS=344; ※上記で確認したログのポジション

スレーブの開始
mysql> START SLAVE;

状態の確認
mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: X.X.X.X
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqld-bin.000001
Read_Master_Log_Pos: 1661
Relay_Log_File: mysqld-relay-bin.000005
Relay_Log_Pos: 420
Relay_Master_Log_File: mysqld-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:

とりあえず以下の行が出力されていればOKのようです。
Slave_IO_State: Waiting for master to send event


参考
MySQL レプリケーションの設定
MySQL入門 レプリケーション編

2017年01月28日
会社でWebカメラを利用しています。監視・防犯カメラとかそういう用途だと思います。
ルーターのログを別件で見ていたところ、なにやら見慣れないポートで外部と通信しているのを見つけました。

114.55.218.176 ポート番号 32100 UDP

で、調べてみると、以下のサイトで記載がありました。(アマゾンです)
lvshan ワイヤレスIPカメラ(C7838WIP)

どのような用途なのか分かりませんが、気をつけないといけませんね。




2017年01月27日
先日の記事ではうまくいきませんでした。

# service splx start
Loading splx kernel module: [FAILED]
Starting vsapiapp: [FAILED]

こんな感じです。

なので、モジュールを作成しました。
※4台サーバーを借りている環境ですが、1台のサーバーで .o ファイルを作成すればあとは他のサーバーにコピーして利用できます。

カーネルソースのインストール
# yum install kernel-devel

確認
# rpm -qa |grep kernel-devel
kernel-devel-2.6.32-642.13.1.el6.centos.plus.x86_64

make してモジュールの作成
# cd /opt/TrendMicro/SProtectLinux/SPLX.module/src/module
# make

make[2]: Leaving directory `/usr/src/kernels/2.6.32-642.13.1.el6.centos.plus.x86_64'
make[1]: Leaving directory `/opt/TrendMicro/SProtectLinux/SPLX.module/src/module/bin'

たくさんのログがでて、 bin フォルダに作成されました。
cd /opt/TrendMicro/SProtectLinux/SPLX.module/src/module/bin

# ls -lFa splxmod-2.6.32-642.13.1.el6.centos.plus.x86_64.x86_64.o
-rw-r--r-- 1 root root 1772552 XXX XX XX:XX splxmod-2.6.32-642.13.1.el6.centos.plus.x86_64.x86_64.o

コピー
# cp splxmod-2.6.32-642.13.1.el6.centos.plus.x86_64.x86_64.o /opt/TrendMicro/SProtectLinux/SPLX.module/

実行権限付与
# chmod +x /opt/TrendMicro/SProtectLinux/SPLX.module/splxmod-2.6.32-642.13.1.el6.centos.plus.x86_64.x86_64.o

サービス再起動
# service splx restart

# service splx restart
Shutting down ServerProtect for Linux:
Shutting down splxcore:
Shutting down vsapiapp [ OK ]
Unloading splx kernel module: [ OK ]
Shutting down entity: [ OK ]
ServerProtect for Linux core stopped normally.
[ OK ]
Shutting down splxhttpd:
Shutting down splxhttpd: [ OK ]
ServerProtect for Linux httpd stopped normally.
[ OK ]
ServerProtect for Linux stopped normally.
Starting ServerProtect for Linux:
Checking configuration file: [ OK ]
Starting splxcore:
Starting Entity: [ OK ]
Loading splx kernel module: [ OK ]
Starting vsapiapp: [ OK ]
ServerProtect for Linux core started.
[ OK ]
Starting splxhttpd:
Starting splxhttpd: [ OK ]
ServerProtect for Linux httpd started.
[ OK ]
ServerProtect for Linux started.

上記のとおりログがでて問題無くできました。

2017年01月26日
昨日の記事で、ServerProtect をインストールしました。
リアルタイムスキャンをするには、さらにKHMをインストールする必要があるようです。

ダウンロード
# wget http://files.trendmicro.com/products/kernel/SPLX%203.0/CentOS%206/splx_kernel_module-3.0.1.0016.centos6_2.6.32-642.13.1.el6.x86_64.x86_64.tar.gz

ファイルの解凍
#tar xzvf splx_kernel_module-3.0.1.0016.centos6_2.6.32-642.13.1.el6.x86_64.x86_64.tar.gz

MD5 の確認
# md5sum splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o
fe573526c93624a10cefb2a6d1f20f70 splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o

#cat splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o.md5
fe573526c93624a10cefb2a6d1f20f70 splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o
値が同じ事を確認


# modinfo splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o
filename: splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o
license: GPL
description: Kernel Hooking Module for ServerProtect for Linux
version 3.0.1.0016 2017-01-19 10:57:41
Other Linux X86_64
author: Trend Micro Incorporated
srcversion: 020214FE79E7B7D34DA0FE1
depends:
vermagic: 2.6.32-642.13.1.el6.x86_64 SMP mod_unload modversions
parm: splxmod_debug:int
parm: splxmod_addr:charp
parm: splxmod_execve_addr:charp
parm: splxmod_compat_do_execve_addr:charp
parm: splxmod_ia32_addr:charp
parm: splxmod_ret_addr:charp

コピー
# cp splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o /opt/TrendMicro/SProtectLinux/SPLX.module/

実行権限付与
# chmod +x /opt/TrendMicro/SProtectLinux/SPLX.module/splxmod-2.6.32-642.13.1.el6.x86_64.x86_64.o

サービス再起動
# service splx restart

で、どうやら僕の環境では、Kernel が独自?っぽいので、うまくいきませんでした・・・。続きはまた書きます。



参考
CentOS6にTrend Micro ServerProtectのKHMをインストールする。

2017年01月25日
参考
ServerProtect for Linux 3.0 インストール

上記ページと全く同じでした。

ダウンロードします。
#wget http://files.trendmicro.com/products/splx/SPLX30_CentOS6.tgz

ファイルの解凍
# tar xzvf SPLX30_CentOS6.tgz

実行
# ./SProtectLinux-3.0.bin

エラー。
Installing ServerProtect for Linux:
Dependency failed:
Please install compat-libstdc++ package

必要なパッケージのインストール
# yum install compat-libstdc++-296

もう一度やったら次は下記エラーが。
Installing ServerProtect for Linux:
Unpacking...
Installing rpm file...
error: Failed dependencies:
libz.so.1 is needed by SProtectLinux-3.0-1362.x86_64
libuuid.so.1 is needed by SProtectLinux-3.0-1362.x86_64
/usr/bin/perl is needed by SProtectLinux-3.0-1362.x86_64

もう一度追加のパッケージをインストール。
# yum install zlib.i686 libuuid.i686 perl

以下の通り進みました。

Installing ServerProtect for Linux:
Unpacking...
Installing rpm file...
Preparing... ########################################### [100%]
1:SProtectLinux ########################################### [100%]
Do you wish to connect this SPLX server to Trend Micro Control Manager? (y/n) [y] n

Trend Micro Control Manager に接続するか聞かれます。今回はスタンドアロンで管理するのでnを選択。


続いて、アクティベーションについてアナウンスされます。
Activate ServerProtect to continue scanning and security updates.
Activation is a two-step process that you can complete during or after installation.

Step 1. Register
Use the Registration Key that came with your product to register online
(https://olr.trendmicro.com/redirect/product_register.aspx).
(Please skip this step if the product is already registered.)

Step 2. Activate
Type the Activation Code received after registration to activate ServerProtect.
(Press [Ctrl+D] to abort activation.)

Activation Code:

今回は Ctrl+D で飛ばします。
ここで Ctrl+C してしまうと、中途半端な状態になってしまいます。その場合には、参考サイトの通りですが、 -e でアンインストールします。
-------------
# rpm -qa |grep SP
SProtectLinux-3.0-1362.x86_64

#rpm -e SProtectLinux-3.0-1362.x86_64
-------------


続いてトレンドマイクロに各種情報を投げるか聞かれます。ウイルス情報を共有するみたいですね。
Yesを選択しました。
Yes, I would like to join the World Virus Tracking Program.
I understand that when a virus is detected on my system, aggregated
detection information, including virus names and number of detections,
will be sent to the World Virus Tracking Program. It will not send out
company names, individual names, machine names, site names, IP addresses,
or any other identifying information. I understand that I can disable
this automatic reporting function at any time by changing the
configuration to "No" within the product's management console.

Please input your choice [Yes] : yes


続いてサービスが起動します。アクティベーションコードを入れていないので、一部エラーになりまます。
Starting services...
Starting ServerProtect for Linux:
Checking configuration file: [ OK ]
Starting splxcore:
Starting Entity: [ OK ]
Loading splx kernel module: [FAILED]
Starting vsapiapp: [FAILED]
ServerProtect for Linux core started.
[ OK ]
Starting splxhttpd:
Starting splxhttpd: [ OK ]
ServerProtect for Linux httpd started.
[ OK ]
ServerProtect for Linux started.

ServerProtect has not been activated.
You must activate your product to enable scanning and security updates.

The virus notification program is not started. This program only starts in
K Desktop Environment (KDE). Start this program using the Quick Access
console in KDE.

ServerProtect for Linux installation completed.


続いてカーネルフックモジュールをインストールします。