36
25

More than 5 years have passed since last update.

マルウェア検出ツール Linux Malware Detect

Last updated at Posted at 2016-08-10

Linux Malware Detect (maldetect)

https://www.rfxn.com/projects/linux-malware-detect/
Linux Malware Detect (maldetect) は共有ホスト環境の脅威に対応するために作られたマルウェアスキャナー。
最新版は 2017/03/17 リリースの 1.6 になる。

機能

  • 迅速に脅威を識別するためのMD5ファイルハッシュ検出
  • 脅威の変異体を識別するためのHEXベースのパターンマッチング
  • 難読化された脅威の検出のための統計的分析コンポーネント(例: base64)
  • パフォーマンス向上のためスキャナーエンジンとして使用する ClamAV の検出を統合
  • integrated signature update feature with -u|–update
  • integrated version update feature with -d|–update-ver
  • scan-recent option to scan only files that have been added/changed in X days
  • scan-all option for full path based scanning
  • checkout option to upload suspected malware to rfxn.com for review / hashing
  • full reporting system to view current and previous scan results
  • quarantine queue that stores threats in a safe fashion with no permissions
  • quarantine batching option to quarantine the results of a current or past scans
  • quarantine restore option to restore files to original path, owner and perms
  • quarantine suspend account option to Cpanel suspend or shell revoke users
  • cleaner rules to attempt removal of malware injected strings
  • cleaner batching option to attempt cleaning of previous scan reports
  • cleaner rules to remove base64 and gzinflate(base64 injected malware
  • ユーザーのホームディレクトリー内の直近24時間のすべての変更の cron ベースの日次スキャン
  • Red Hat 系システム、Cpanel、Ensim と互換性のある日次 cron スクリプト
  • 作成、更新、移動されたファイルを kernel ベースの inotify でリアルタイムスキャン
  • 標準入力またはファイルからパス情報を取得できる kernel inotify モニター
  • システムユーザーを監視するための便利な機能の kernel inotify モニター
  • kernel inotify モニターは設定可能なユーザーの html ルートに制限することができる
  • 最適なパフォーマンスのための動的な sysctl 制限のある kernel inotify モニター
  • 日次および週次のレポートでの kernel inotify アラート
  • 手動および日次のスキャン実行ごとのメールアラートレポート
  • path, extension and signature based ignore options
  • 自動スキャン操作のためのバックグラウンドスキャナーオプション
  • 全てのアクションの詳細なログと出力

インストール

パッケージ

yum install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm
yum install maldetect

Lux リポジトリにのみパッケージが存在する。
このパッケージでインストールされるのは 2013/02/25 リリースの 1.4.2 になる。
現状 2017/03/13 時点の git 最新版(?)が 1.6 相当としてインストールされる模様。

アップデート

maldet --update

maldet -u でも同様。

ソースからインストールした場合は maldet -d で本体をバージョンアップできるようだが、パッケージでインストールした場合はうまくいかないようだ。

スキャン

設定変更

sed -i.org '/quar_hits=/s/0/1/' /etc/maldetect/conf.maldet

検疫の有効化。

検出サンプル

curl -O http://www.eicar.org/download/eicar.com

スキャン実施

maldet --scan-all ~
出力例
Linux Malware Detect v1.4.2
            (C) 2002-2013, R-fx Networks <proj@r-fx.org>
            (C) 2013, Ryan MacDonald <ryan@r-fx.org>
inotifywait (C) 2007, Rohan McGovern <rohan@mcgovern.id.au>
This program may be freely redistributed under the terms of the GNU GPL v2

maldet(9499): {scan} signatures loaded: 10904 (8987 MD5 / 1917 HEX)
maldet(9499): {scan} building file list for /root, this might take awhile...
maldet(9499): {scan} file list completed, found 28 files...
maldet(9499): {scan} found ClamAV clamscan binary, using as scanner engine...
maldet(9499): {scan} scan of /root (28 files) in progress...
maldet(9499): {scan} processing scan results for hits: 1 hits 0 cleaned
maldet(9499): {scan} scan completed on /root: files 28, malware hits 1, cleaned hits 0
maldet(9499): {scan} scan report saved, to view run: maldet --report 081016-2242.9499

maldet -a ~ でも同様。

スキャン結果

maldet --report 081016-2242.9499
出力例
malware detect scan report for localhost.localdomain:
SCAN ID: 081016-2242.9499
TIME:  8月 10 22:42:42 +0900
PATH: /root
TOTAL FILES: 28
TOTAL HITS: 1
TOTAL CLEANED: 0

FILE HIT LIST:
{HEX}EICAR.TEST.10 : /root/eicar.com => /var/lib/maldetect/quarantine/eicar.com.2524
===============================================
Linux Malware Detect v1.4.2 < proj@rfxn.com >

マルウェア判定されたファイルが /var/lib/maldetect/quarantine/ へ検疫(移動)されている。

デフォルト設定

設定ファイル

/etc/maldetect/conf.maldet
email_alert=0
email_subj="maldet alert from $(hostname)"
email_addr="you@domain.com"
email_ignore_clean=0
quar_hits=0
quar_clean=1
quar_susp=0
quar_susp_minuid=500
maxdepth=15
minfilesize=32
maxfilesize="768k"
hexdepth=61440
hex_fifo_scan=1
hex_fifo_depth=524288
clamav_scan=1
public_scan=0
string_length_scan="0"      # [ 0 = disabled, 1 = enabled ]
string_length="150000"      # [ max string length ]
inotify_base_watches=15360
inotify_stime=30
inotify_minuid=500
inotify_webdir=public_html
inotify_nice=10

cron

/etc/cron.daily/maldet
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
export LMDCRON=1
inspath='/usr/local/maldetect'
intcnf="$inspath/internals/internals.conf"
if [ -f "$intcnf" ]; then
    source $intcnf
else
    echo "\$intcnf not found."
    exit 1
fi
if [ -f "$cnf" ]; then
    source $cnf
    if [ -f "$compatcnf" ]; then
            source $compatcnf
    fi
else
    echo "could not find \$cnf, fatal error, bye."
    exit 1
fi
if [ -f "/etc/sysconfig/maldet" ]; then
    . /etc/sysconfig/maldet
elif [ -f "/etc/default/maldet" ]; then
    . /etc/default/maldet
fi
if [ -f "$cron_custom_conf" ]; then
    . $cron_custom_conf
fi
if [ -z "$scan_days" ]; then
    scan_days=1
fi
if [ "$find" ]; then
    tmpdirs="$tmpdir $varlibpath/sess $varlibpath/quarantine $varlibpath/pub"
    for dir in $tmpdirs; do
     if [ -d "$dir" ]; then
      $find $dir -type f -mtime +7 -print0 | xargs -0 rm -f >> /dev/null 2>&1
     fi
    done
fi
if [ "$autoupdate_version" == "1" ] || [ "$autoupdate_signatures" == "1" ]; then
    sleep $(echo $RANDOM | cut -c1-3) >> /dev/null 2>&1
fi
if [ "$autoupdate_version" == "1" ]; then
    $inspath/maldet -d >> /dev/null 2>&1
fi
if [ "$autoupdate_signatures" == "1" ]; then
    $inspath/maldet -u >> /dev/null 2>&1
fi
if [ "$(ps -A --user root -o "cmd" | grep maldetect | grep inotifywait)" ]; then
        $inspath/maldet --monitor-report >> /dev/null 2>&1
else
    if [ -d "/home/virtual" ] && [ -d "/usr/lib/opcenter" ]; then
            $inspath/maldet -b -r /home/virtual/?/fst/var/www/html/,/home/virtual/?/fst/home/?/public_html/ $scan_days >> /dev/null 2>&1
    elif [ -d "/etc/psa" ] && [ -d "/var/lib/psa" ]; then
        $inspath/maldet -b -r /var/www/vhosts/?/ $scan_days >> /dev/null 2>&1
        elif [ -d "/usr/local/directadmin" ]; then
                $inspath/maldet -b -r /home?/?/domains/?/public_html/,/var/www/html/?/ $scan_days >> /dev/null 2>&1
    elif [ -d "/var/www/clients" ]; then
                $inspath/maldet -b -r /var/www/clients/?/web?/web,/var/www $scan_days >> /dev/null 2>&1
    elif [ -d "/etc/webmin/virtual-server" ]; then
                $inspath/maldet -b -r /home/?/public_html/,/home/?/domains/?/public_html/ $scan_days >> /dev/null 2>&1
    elif [ -d "/usr/local/ispmgr" ]; then
        $inspath/maldet -b -r /var/www/?/data/,/home/?/data/ $scan_days >> /dev/null 2>&1
    elif [ -d "/var/customers/webs" ]; then
        $inspath/maldet -b -r /var/customers/webs/ $scan_days >> /dev/null 2>&1
        elif [ -d "/usr/local/vesta" ]; then
                $inspath/maldet -b -r /home/?/web/?/public_html/,/home/?/web/?/public_shtml/,/home/?/tmp/,/home/?/web/?/private/ $scan_days >> /dev/null 2>&1
        elif [ -d "/usr/share/dtc" ]; then
                if [ -f /var/lib/dtc/saved_install_config ]; then
                    . /var/lib/dtc/saved_install_config
                fi
                $inspath/maldet -b -r ${conf_hosting_path:-/var/www/sites}/?/?/subdomains/?/html/ $scan_days >> /dev/null 2>&1
    else
            $inspath/maldet -b -r /home?/?/public_html/,/var/www/html/,/usr/local/apache/htdocs/ $scan_days >> /dev/null 2>&1
    fi
fi
if [ -f "$cron_custom_exec" ]; then
    . $cron_custom_exec
fi

セキュリティ関連記事

36
25
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
36
25