カテゴリー: Vuls

Vagrant上のCentOS6にVulsインストール

Vulsインストール

Vagrant上のCentOS6にインストールを行ったメモ

公式のインストール方法:Vuls: VULnerability Scanner
SSHの設定をする

ローカルホストにSSH接続できるようにする。
SSHキーペアを作成し、公開鍵をauthorized_keysに追加する。

$ ssh-keygen -t rsa
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys

Vulsに必要な以下のソフトウェアをインストールする。
– SQLite3
– git v2
– gcc
– go v1.7.1 or later

※gitはCentOS6のデフォルトだと1.7とかなので、そのまま入れてはいけない

How to Install Git 2.8.1 on CentOS/RHEL 7/6/5 & Fedora 23/22

$ sudo yum -y install sqlite git gcc
$ wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz   <-時間がかかる
$ sudo tar -C /usr/local -xzf go1.7.1.linux-amd64.tar.gz
$ mkdir $HOME/go

/etc/profile.d/goenv.sh を作成し、下記を追加する。

$ sudo vi /etc/profile.d/goenv.sh
$ cat /etc/profile.d/goenv.sh
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

カレントシェルに上記環境変数をセットする。

$ source /etc/profile.d/goenv.sh

go-cve-dictionaryのインストール

$ sudo mkdir /var/log/vuls
$ sudo chown mogu /var/log/vuls
$ sudo chmod 700 /var/log/vuls
$ mkdir -p $GOPATH/src/github.com/kotakanbe
$ cd $GOPATH/src/github.com/kotakanbe
$ git clone https://github.com/kotakanbe/go-cve-dictionary.git
$ cd go-cve-dictionary
$ make install

バイナリは、`$GOPATH/bin`いかに生成される
NVDから脆弱性データベースを取得する。
これは実行ユーザのホームディレクトリに「vuls」というディレクトリを掘ってその中に取得する方がやりやすい。

$ pwd
/home/mogu
$ mkdir vuls
$ cd vuls
$ for i in {2002..2016}; do go-cve-dictionary fetchnvd -years $i; done
$ pwd
/home/mogu/vuls
$ ll
total 680368
-rw-r--r-- 1 mogu mogu 592179200 Oct 21 10:11 cve.sqlite3
-rw-r--r-- 1 mogu mogu     32768 Oct 21 10:11 cve.sqlite3-shm
-rw-r--r-- 1 mogu mogu  22845432 Oct 21 10:11 cve.sqlite3-wal

vulsインストール

$ mkdir -p $GOPATH/src/github.com/future-architect
$ cd $GOPATH/src/github.com/future-architect
$ git clone https://github.com/future-architect/vuls.git
$ cd vuls
$ make install

Config

先ほど作った実行ユーザの「vuls」内に設定ファイルを記載する

$ pwd
/home/mogu/vuls
$ vim config.toml
$ cat config.toml 
[servers]

[servers.127-0-0-1]
host         = "127.0.0.1"
port        = "22"
user        = "mogu"
keyPath     = "/home/mogu/.ssh/id_rsa"

$ vuls configtest
[Oct 21 10:24:09]  INFO [localhost] Validating Config...
[Oct 21 10:24:09]  INFO [localhost] Detecting Server/Contianer OS... 
[Oct 21 10:24:09]  INFO [localhost] Detecting OS of servers... 
[Oct 21 10:24:10]  INFO [localhost] (1/1) Detected: 127-0-0-1: centos 6.7
[Oct 21 10:24:10]  INFO [localhost] Detecting OS of containers... 
[Oct 21 10:24:10]  INFO [localhost] Checking sudo configuration... 
[Oct 21 10:24:10]  INFO [127-0-0-1] sudo ... OK
[Oct 21 10:24:10]  INFO [localhost] SSH-able servers are below...
127-0-0-1 

セットアップ

$ vuls prepare
INFO[0000] Start Preparing (config: /home/mogu/vuls/config.toml) 
[Oct 21 10:24:46]  INFO [localhost] Detecting OS... 
[Oct 21 10:24:46]  INFO [localhost] Detecting OS of servers... 
[Oct 21 10:24:46]  INFO [localhost] (1/1) Detected: 127-0-0-1: centos 6.7
[Oct 21 10:24:46]  INFO [localhost] Detecting OS of containers... 
[Oct 21 10:24:46]  INFO [localhost] Checking sudo configuration... 
[Oct 21 10:24:47]  INFO [127-0-0-1] sudo ... OK
[Oct 21 10:24:47]  INFO [localhost] No need to install dependencies

検査開始

    $ vuls scan -cve-dictionary-dbpath=$PWD/cve.sqlite3 -report-json

TUIで結果確認

$ vuls tui

Ctrl + cで閉じる

脆弱性があったのにtuiでは空で表示された場合はconfig.tomlと同じディレクトリに脆弱性データベースを落としていたか再度確認する。