|
| 1 | +--- |
| 2 | +id: tutorial-localscan |
| 3 | +title: Tutorial: Local Scan Mode |
| 4 | +--- |
| 5 | + |
| 6 | +sidebar_label: Example Page |
| 7 | + |
| 8 | +# Tutorial: Local Scan Mode |
| 9 | + |
| 10 | +This tutorial will let you scan the vulnerabilities on the localhost with Vuls. |
| 11 | +This can be done in the following steps. |
| 12 | + |
| 13 | +1. Launch CentOS |
| 14 | +1. Install requirements |
| 15 | +1. Deploy go-cve-dictionary |
| 16 | +1. Deploy goval-dictionary |
| 17 | +1. Deploy Vuls |
| 18 | +1. Configuration |
| 19 | +1. Check config.toml and settings on the server before scanning |
| 20 | +1. Scan |
| 21 | +1. Reporting |
| 22 | +1. TUI(Terminal-Based User Interface) |
| 23 | +1. Web UI ([VulsRepo](https://github.com/usiusi360/vulsrepo)) |
| 24 | + |
| 25 | +## Step1. Launch CentOS7 |
| 26 | + |
| 27 | +- We are using the old AMI for this example |
| 28 | +- Add the following to the cloud-init, to avoid auto-update at the first launch. |
| 29 | + |
| 30 | + ``` |
| 31 | + #cloud-config |
| 32 | + repo_upgrade: none |
| 33 | + ``` |
| 34 | +
|
| 35 | + - [Q: How do I disable the automatic installation of critical and important security updates on initial launch?](https://aws.amazon.com/amazon-linux-ami/faqs/?nc1=h_ls) |
| 36 | +
|
| 37 | +## Step2. Install requirements |
| 38 | +
|
| 39 | +Vuls requires the following packages. |
| 40 | +
|
| 41 | +- SQLite3, MySQL, PostgreSQL, Redis |
| 42 | +- git |
| 43 | +- gcc |
| 44 | +- GNU Make |
| 45 | +- go v1.8.3 or later (The latest version is recommended) |
| 46 | + - https://golang.org/doc/install |
| 47 | +
|
| 48 | +```bash |
| 49 | +$ ssh [email protected] -i ~/.ssh/private.pem |
| 50 | +$ sudo yum -y install sqlite git gcc make wget |
| 51 | +$ wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz |
| 52 | +$ sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz |
| 53 | +$ mkdir $HOME/go |
| 54 | +``` |
| 55 | +Add these lines into /etc/profile.d/goenv.sh |
| 56 | + |
| 57 | +```bash |
| 58 | +export GOROOT=/usr/local/go |
| 59 | +export GOPATH=$HOME/go |
| 60 | +export PATH=$PATH:$GOROOT/bin:$GOPATH/bin |
| 61 | +``` |
| 62 | + |
| 63 | +Set the OS environment variable to current shell |
| 64 | +```bash |
| 65 | +$ source /etc/profile.d/goenv.sh |
| 66 | +``` |
| 67 | + |
| 68 | +## Step3. Deploy go-cve-dictionary |
| 69 | + |
| 70 | +[go-cve-dictionary](https://github.com/kotakanbe/go-cve-dictionary) |
| 71 | + |
| 72 | +```bash |
| 73 | +$ sudo mkdir /var/log/vuls |
| 74 | +$ sudo chown centos /var/log/vuls |
| 75 | +$ sudo chmod 700 /var/log/vuls |
| 76 | +$ |
| 77 | +$ mkdir -p $GOPATH/src/github.com/kotakanbe |
| 78 | +$ cd $GOPATH/src/github.com/kotakanbe |
| 79 | +$ git clone https://github.com/kotakanbe/go-cve-dictionary.git |
| 80 | +$ cd go-cve-dictionary |
| 81 | +$ make install |
| 82 | +``` |
| 83 | +The binary was built under `$GOPATH/bin` |
| 84 | +If the installation process stops halfway, try increasing the instance type of EC2. An out of memory error may have occurred. |
| 85 | + |
| 86 | + |
| 87 | +Fetch vulnerability data from NVD. |
| 88 | +It takes about 10 minutes (on AWS). |
| 89 | + |
| 90 | +```bash |
| 91 | +$ cd $HOME |
| 92 | +$ for i in `seq 2002 $(date +"%Y")`; do go-cve-dictionary fetchnvd -years $i; done |
| 93 | +... snip ... |
| 94 | +$ ls -alh cve.sqlite3 |
| 95 | +-rw-r--r--. 1 centos centos 51M Aug 6 08:10 cve.sqlite3 |
| 96 | +-rw-r--r--. 1 centos centos 32K Aug 6 08:10 cve.sqlite3-shm |
| 97 | +-rw-r--r--. 1 centos centos 5.1M Aug 6 08:10 cve.sqlite3-wal |
| 98 | +``` |
| 99 | + |
| 100 | +## Step4. Deploy goval-dictionary |
| 101 | + |
| 102 | +[goval-dictionary](https://github.com/kotakanbe/goval-dictionary) |
| 103 | + |
| 104 | +```bash |
| 105 | +$ mkdir -p $GOPATH/src/github.com/kotakanbe |
| 106 | +$ cd $GOPATH/src/github.com/kotakanbe |
| 107 | +$ git clone https://github.com/kotakanbe/goval-dictionary.git |
| 108 | +$ cd goval-dictionary |
| 109 | +$ make install |
| 110 | +``` |
| 111 | +The binary was built under `$GOPATH/bin` |
| 112 | +If the installation process stops halfway, try increasing the instance type of EC2. An out of memory error may have occurred. |
| 113 | + |
| 114 | + Then fetch OVAL data of RedHat since the server to be scanned is CentOS. [README](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-redhat) |
| 115 | + |
| 116 | +```bash |
| 117 | +$ goval-dictionary fetch-redhat 7 |
| 118 | +``` |
| 119 | + |
| 120 | +If you want to scan other than CentOS 7, fetch OVAL data according to the OS type and version of scan target server in advance. |
| 121 | +- [Alpine](https://github.com/kotakanbe/goval-dictionary#usage-fetch-alpine-secdb-as-oval-data-type) |
| 122 | +- [RedHat, CentOS](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-redhat) |
| 123 | +- [Debian](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-debian) |
| 124 | +- [Ubuntu](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-ubuntu) |
| 125 | +- [Oracle Linux](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-oracle) |
| 126 | +- [SUSE](https://github.com/kotakanbe/goval-dictionary#usage-fetch-oval-data-from-suse) |
| 127 | + |
| 128 | +## Step5. Deploy Vuls |
| 129 | + |
| 130 | +Launch a new terminal and SSH to the ec2 instance. |
| 131 | + |
| 132 | +``` |
| 133 | +$ mkdir -p $GOPATH/src/github.com/future-architect |
| 134 | +$ cd $GOPATH/src/github.com/future-architect |
| 135 | +$ git clone https://github.com/future-architect/vuls.git |
| 136 | +$ cd vuls |
| 137 | +$ make install |
| 138 | +``` |
| 139 | +If you have previously installed vuls and want to update, please do the following |
| 140 | +``` |
| 141 | +$ rm -rf $GOPATH/pkg/linux_amd64/github.com/future-architect/vuls/ |
| 142 | +$ rm -rf $GOPATH/src/github.com/future-architect/vuls/ |
| 143 | +$ cd $GOPATH/src/github.com/future-architect |
| 144 | +$ git clone https://github.com/future-architect/vuls.git |
| 145 | +$ cd vuls |
| 146 | +$ make install |
| 147 | +``` |
| 148 | + |
| 149 | +The binary was built under `$GOPATH/bin` |
| 150 | +If the installation process stops halfway, try increasing the instance type of EC2. An out of memory error may have occurred. |
| 151 | + |
| 152 | +## Step6. Configuration |
| 153 | + |
| 154 | +Create a config file(TOML format). |
| 155 | +``` |
| 156 | +$ cd $HOME |
| 157 | +$ cat config.toml |
| 158 | +[servers] |
| 159 | +
|
| 160 | +[servers.localhost] |
| 161 | +host = "localhost" |
| 162 | +port = "local" |
| 163 | +``` |
| 164 | + |
| 165 | + |
| 166 | +## Step7. Check config.toml and settings on the server before scanning |
| 167 | + |
| 168 | +``` |
| 169 | +$ vuls configtest |
| 170 | +``` |
| 171 | + |
| 172 | +see [Usage: configtest](#usage-configtest) |
| 173 | + |
| 174 | +## Step8. Start Scanning |
| 175 | + |
| 176 | +``` |
| 177 | +$ vuls scan |
| 178 | +
|
| 179 | +... snip ... |
| 180 | +
|
| 181 | +One Line Summary |
| 182 | +================ |
| 183 | +localhost centos7.3.1611 31 updatable packages |
| 184 | +
|
| 185 | +``` |
| 186 | + |
| 187 | +## Step9. Reporting |
| 188 | + |
| 189 | +View one-line summary |
| 190 | + |
| 191 | +``` |
| 192 | +$ vuls report -format-one-line-text -cvedb-path=$PWD/cve.sqlite3 -ovaldb-path=$PWD/oval.sqlite3 |
| 193 | +
|
| 194 | +One Line Summary |
| 195 | +================ |
| 196 | +localhost Total: 109 (High:35 Medium:55 Low:16 ?:3) 31 updatable packages |
| 197 | +
|
| 198 | +``` |
| 199 | + |
| 200 | +View short summary |
| 201 | + |
| 202 | +``` |
| 203 | +$ vuls report -format-short-text |
| 204 | +
|
| 205 | +localhost (centos7.3.1611) |
| 206 | +========================== |
| 207 | +Total: 109 (High:35 Medium:55 Low:16 ?:3) 31 updatable packages |
| 208 | +
|
| 209 | +CVE-2015-2806 10.0 HIGH (nvd) |
| 210 | + Stack-based buffer overflow in asn1_der_decoding in libtasn1 before 4.4 allows |
| 211 | + remote attackers to have unspecified impact via unknown vectors. |
| 212 | + --- |
| 213 | + https://nvd.nist.gov/vuln/detail/CVE-2015-2806 |
| 214 | + https://access.redhat.com/security/cve/CVE-2015-2806 (RHEL-CVE) |
| 215 | + 10.0/AV:N/AC:L/Au:N/C:C/I:C/A:C (nvd) |
| 216 | + 2.6/AV:N/AC:H/Au:N/C:N/I:N/A:P (redhat) |
| 217 | + https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2015-2806 |
| 218 | + 3.3/CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L (redhat) |
| 219 | + https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?name=CVE-2015-2806 |
| 220 | + Confidence: 100 / OvalMatch |
| 221 | +
|
| 222 | +... snip ... |
| 223 | +```` |
| 224 | +
|
| 225 | +View full report. |
| 226 | +
|
| 227 | +``` |
| 228 | +$ vuls report -format-full-text | less |
| 229 | +localhost (centos7.3.1611) |
| 230 | +========================== |
| 231 | +Total: 109 (High:35 Medium:55 Low:16 ?:3) 31 updatable packages |
| 232 | + |
| 233 | +CVE-2015-2806 |
| 234 | +---------------- |
| 235 | +Max Score 10.0 HIGH (nvd) |
| 236 | +nvd 10.0/AV:N/AC:L/Au:N/C:C/I:C/A:C |
| 237 | +redhat 2.6/AV:N/AC:H/Au:N/C:N/I:N/A:P |
| 238 | +redhat 3.3/CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L |
| 239 | +CVSSv2 Calc https://nvd.nist.gov/vuln-metrics/cvss/v2-calculator?name=CVE-2015-2806 |
| 240 | +CVSSv3 Calc https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?name=CVE-2015-2806 |
| 241 | +Summary Stack-based buffer overflow in asn1_der_decoding in libtasn1 before 4.4 allows |
| 242 | + remote attackers to have unspecified impact via unknown vectors. |
| 243 | +Source https://nvd.nist.gov/vuln/detail/CVE-2015-2806 |
| 244 | +RHEL-CVE https://access.redhat.com/security/cve/CVE-2015-2806 |
| 245 | +CWE-119 (nvd) https://cwe.mitre.org/data/definitions/119.html |
| 246 | +Package/CPE libtasn1-3.8-3.el7 - |
| 247 | +Confidence 100 / OvalMatch |
| 248 | + |
| 249 | +... snip ... |
| 250 | +``` |
| 251 | +
|
| 252 | +## Step10. TUI |
| 253 | +
|
| 254 | +Vuls has Terminal-Based User Interface to display the scan result. |
| 255 | +
|
| 256 | +``` |
| 257 | +$ vuls tui |
| 258 | +``` |
| 259 | +
|
| 260 | + |
| 261 | +
|
| 262 | +## Step11. Web UI |
| 263 | +
|
| 264 | +[VulsRepo](https://github.com/usiusi360/vulsrepo) is a awesome Web UI for Vuls. |
| 265 | +Check it out the [Online Demo](http://usiusi360.github.io/vulsrepo/). |
| 266 | +
|
0 commit comments