当前位置:   article > 正文

GVM-11 centos8 源码安装指南(OpenVas)_openvas centos8

openvas centos8

参考文章:https://community.greenbone.net/t/full-gvm-11-build-guide-for-centos-8/5425

原文有各别不对地方,但根据原文,安装成功,并能正确进行漏洞扫描。非常感谢原文作者辛苦付出。这里做一下安装记录,不对的地方请指出。

安装的操作系统:CentOS Linux release 8.1.1911 (Core) ,CPU: 4核,内存 4G,

1,python 3 环境安装设置

使用root登录

默认python3已安装

[root@localhost ~]# yum install python3

设置默认python命令,选择2。

  1. [root@localhost ~]# alternatives --config python
  2. 共有 2 个提供“python”的程序。
  3. 选项 命令
  4. -----------------------------------------------
  5. * 1 /usr/libexec/no-python
  6. + 2 /usr/bin/python3
  7. 按 Enter 保留当前选项[+],或者键入选项编号:2

2,安装EPEL Repository yum 源

[root@localhost ~]# yum install epel-release

3,启用 Centos-Powertools repository 源

[root@localhost ~]# yum config-manager --set-enabled PowerTools 

4,安装开发工具包  (includes gcc and a whole bunch of stuff for compiling and building things)

[root@localhost ~]# yum groupinstall -y "development tools"

5,安装必需的开发包,cmake redis (most come from Centos-Base, a few come from EPEL and Centos-PowerTools) 

[root@localhost ~]# yum install -y cmake glib2-devel zlib-devel gnutls-devel libuuid-devel libssh-devel libxml2-devel libgcrypt-devel openldap-devel popt-devel redis libical-devel openssl-devel hiredis-devel radcli-devel gpgme-devel libksba-devel doxygen libpcap-devel nodejs python3-polib libmicrohttpd-devel gnutls-utils python3-devel libpq-devel texinfo xmltoman nmap sshpass socat mingw32-gcc ncurses-devel

6,安装postgres数据库

  1. [root@localhost ~]# yum install -y postgresql-server postgresql-contrib postgresql-server-devel
  1. [root@localhost ~]# /usr/bin/postgresql-setup --initdb
  2. * Initializing database in '/var/lib/pgsql/data'
  3. * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

 

7,配置postgres 数据库(not secure, on to-do list is to configure this with a password…

  1. [root@localhost ~]# sudo -Hiu postgres
  2. [postgres@localhost ~]$ createuser gvm
  3. [postgres@localhost ~]$ createdb -O gvm gvmd
  4. [postgres@localhost ~]$ psql gvmd
  5. psql (10.6)
  6. 输入 "help" 来获取帮助信息.
  7. gvmd=# create role dba with superuser noinherit;
  8. CREATE ROLE
  9. gvmd=# grant dba to gvm;
  10. GRANT ROLE
  11. gvmd=# create extension "uuid-ossp";
  12. gvmd=# create extension "pgcrypto";
  13. CREATE EXTENSION
  14. gvmd=# \q
  15. [postgres@localhost ~]$

 8,增加gvm动态运行库配置文件

  1. [root@localhost ~]# echo /opt/gvm/lib > /etc/ld.so.conf.d/gvm.conf
  2. [root@localhost ~]# cat /etc/ld.so.conf.d/gvm.conf
  3. /opt/gvm/lib
  4. [root@localhost ~]# ldconfig

9,增加一个无特权gvm用户和创建程序运行目录

  1. [root@localhost ~]# useradd -r -d /opt/gvm -c "GVM(OpenVas)User" -s /bin/bash gvm
  2. [root@localhost ~]# mkdir /opt/gvm
  3. [root@localhost ~]# mkdir /opt/gvm/src
  4. [root@localhost ~]# chown -R gvm:gvm /opt/gvm

10,增加gvm命令环境变量。在/etc/profile最后增加

  1. #add gvm path PATH to /etc/profile
  2. export PATH=$PATH:/opt/gvm/bin
  3. export PATH=$PATH:/opt/gvm/sbin

12,下载源码包(GVM-11 stable as of 5/20/2020)

切换到gvm用户

  1. [root@localhost ~]# su - gvm
  2. -bash: /opt/gvm/bin: 没有那个文件或目录
  3. -bash: /opt/gvm/sbin: 没有那个文件或目录
  1. wget -O gvm-libs-11.0.1.tar.gz https://github.com/greenbone/gvm-libs/archive/v11.0.1.tar.gz
  2. wget -O openvas-7.0.1.tar.gz https://github.com/greenbone/openvas/archive/v7.0.1.tar.gz
  3. wget -O ospd-2.0.1.tar.gz https://github.com/greenbone/ospd/archive/v2.0.1.tar.gz 2
  4. wget -O ospd-openvas-1.0.1.tar.gz https://github.com/greenbone/ospd-openvas/archive/v1.0.1.tar.gz
  5. wget -O gvmd-9.0.1.tar.gz https://github.com/greenbone/gvmd/archive/v9.0.1.tar.gz
  6. wget -O gsa-9.0.1.tar.gz https://github.com/greenbone/gsa/archive/v9.0.1.tar.gz
  7. wget -O openvas-smb-1.0.5.tar.gz https://github.com/greenbone/openvas-smb/archive/v1.0.5.tar.gz

13,解压源文件

[gvm@localhost src]$ find *.gz  -exec tar xvfz {} \;

14 构建gvm-libs包

gvm登录

  1. export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig
  2. cd gvm-libs-11.0.1/
  3. mkdir build
  4. cd build
  5. cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
  6. make
  7. make doc
  8. make install

15,安装Heimdal。openvas-smb安装需要

root用户登录

  1. cd /usr/local/src/
  2. wget https://github.com/heimdal/heimdal/releases/download/heimdal-7.7.0/heimdal-7.7.0.tar.gz
  3. tar xvfz heimdal-7.7.0.tar.gz
  4. cd heimdal-7.7.0
  5. ./configure --enable-otp=no --prefix=/opt/heimdal
  6. make
  7. make install

openvas-smb code 希望使用(includedir)/heimdal/…

通过创建软链接实现

[root@localhost heimdal-7.7.0]# ln -s /opt/heimdal/include /opt/heimdal/include/heimdal

16,增加heimdal 库到系统中

  1. [root@localhost src]# echo /opt/heimdal/lib > /etc/ld.so.conf.d/heimdal.conf
  2. [root@localhost src]# ldconfig

17,openvas-smb((Note: PKG_CONFIG_PATH now adds where the heimdal goodies are too))

  1. cd src/
  2. export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig:/opt/heimdal/lib/pkgconfig
  3. cd openvas-smb-1.0.5/
  4. mkdir build
  5. cd build
  6. cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
  7. make
  8. make install

18,scanner

修改CMakeList.txt文件,否则编辑时会出现以下错误。

 

 错误:‘pcap_lookupdev’ is deprecated: use 'pcap_findalldevs' and use the first device [-Werror=deprecated-declarations]

修改内容

注释216行,增加一行

set (CMAKE_C_FLAGS_DEBUG        "${CMAKE_C_FLAGS_DEBUG} -Werror -Wno-error=deprecated-declarations")

 

 

  1. vim CMakeLists.txt
  2. cd build
  3. cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
  4. make
  5. make doc
  6. make install

19,配置redis

使用root登录

  1. cp /etc/redis.conf /etc/redis.conf.orig
  2. cp /opt/gvm/src/openvas-7.0.1/config/redis-openvas.conf /etc/redis.conf
  3. vim /etc/redis.conf
  1. unixsocket /tmp/redis.sock
  2. unixsocketperm 770

20  配置openvas 使用redis

gvm用户

echo db_address = /tmp/redis.sock > /opt/gvm/etc/openvas/openvas.conf

root用户

  1. systemctl enable redis
  2. systemctl start redis

21 gvm添加到redis组(需要重启redis)

 

  1. [root@localhost src]# usermod -aG redis gvm
  2. [root@localhost src]# systemctl restart redis

22,赋予gvm以root权限运行openvas,gsad。

增加以下三行

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/gvm/sbin"

#Allow the user running ospd-openvas, to launch openvas with root permissions
gvm ALL = NOPASSWD: /opt/gvm/sbin/openvas
gvm ALL = NOPASSWD: /opt/gvm/sbin/gsad

 23,修改一些系统设置

  1. [root@localhost src]# echo net.core.somaxconn = 1024 >> /etc/sysctl.conf
  2. [root@localhost src]# echo vm.overcommit_memory = 1 >> /etc/sysctl.conf
  3. [root@localhost src]# sysctl -p
  4. net.core.somaxconn = 1024
  5. vm.overcommit_memory = 1
  6. [root@localhost src]# ldconfig

24 Synchronize nvt data

  1. [gvm@localhost ~]$ greenbone-nvt-sync
  2. [gvm@localhost ~]$ find /opt/gvm/var/lib/openvas/plugins | wc -l
  3. 61300

25 Update the vt info

[gvm@localhost bin]$ openvas --update-vt-info

26 ,gvmd

使用root登录
ln -s /usr/include /usr/include/postgresql
(code wants “postgresql/libpq-fe.h”)

修改   CMakeLists.txt 

增加-lpq参数

 使用gvm用户

  1. cd src/
  2. ln -s /usr/include/ /usr/include/postgresql
  3. cd gvmd-9.0.1/
  4. vim CMakeLists.txt
  5. export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig
  6. mkdir build
  7. cd build
  8. cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm/ -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/pgsql/server -DPostgreSQL_INCLUDE_DIR=/usr/include/pgsql/server -DPostgreSQL_LIBRARY=/usr/lib64/pgsql
  9. make
  10. make doc
  11. make install

27, Install yarn, a prerequisite for building gsa

root用户登录

[root@localhost opt]# npm install -g yarn

 

gvm用户

  1. cd gsa-9.0.1/
  2. export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig
  3. mkdir build
  4. cd build
  5. cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
  6. make
  7. make doc
  8. make install
  1. greenbone-scapdata-sync
  2. greenbone-certdata-sync
  3. gvm-manage-certs -a

创建python包安装目录

28,OSPd and OSPd-OpenVAS

  1. export PYTHONPATH=/opt/gvm/lib/python3.6/site-packages
  2. export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig
  3. cd ospd-2.0.1/
  4. python3 setup.py install --prefix=/opt/gvm
  1. cd ..
  2. export PYTHONPATH=/opt/gvm/lib/python3.6/site-packages
  3. export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig
  4. cd ospd-openvas-1.0.1
  5. python3 setup.py install --prefix=/opt/gvm

29,add install scripts

ospd.service

  1. cat << EOF > /etc/systemd/system/ospd.service
  2. [Unit]
  3. Description=Job that runs the ospd-openvas daemon
  4. Documentation=man:gvm
  5. After=postgresql.service
  6. [Service]
  7. Environment=PATH=/opt/gvm/bin/ospd-scanner/bin:/opt/gvm/bin:/opt/gvm/sbin:/opt/gvm/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  8. Environment=PYTHONPATH=/opt/gvm/lib/python3.6/site-packages
  9. Type=simple
  10. User=gvm
  11. Group=gvm
  12. WorkingDirectory=/opt/gvm
  13. PIDFile=/opt/gvm/var/run/ospd-openvas.pid
  14. ExecStart=/usr/bin/python3 /opt/gvm/bin/ospd-openvas --pid-file /opt/gvm/var/run/ospd-openvas.pid --unix-socket /opt/gvm/var/run/ospd.sock --log-file /opt/gvm/var/log/gvm/ospd-openvas.log --lock-file-dir /opt/gvm/var/run
  15. [Install]
  16. WantedBy=multi-user.target
  17. EOF

gvmd.service 

  1. cat << EOF > /etc/systemd/system/gvmd.service
  2. [Unit]
  3. Description=Job that runs the gvm daemon
  4. Documentation=man:gvm
  5. After=ospd.service
  6. [Service]
  7. Type=forking
  8. User=gvm
  9. Group=gvm
  10. PIDFile=/opt/gvm/var/run/gvmd.pid
  11. WorkingDirectory=/opt/gvm
  12. ExecStartPre=/bin/sleep 60
  13. ExecStart=/opt/gvm/sbin/gvmd --osp-vt-update=/opt/gvm/var/run/ospd.sock
  14. [Install]
  15. WantedBy=multi-user.target
  16. EOF
  1. cat << EOF > /etc/systemd/system/gsad.service
  2. [Unit]
  3. Description=Job that runs the gsa daemon
  4. Documentation=man:gsa
  5. After=postgresql.service
  6. [Service]
  7. Type=forking
  8. PIDFile=/opt/gvm/var/run/gsad.pid
  9. WorkingDirectory=/opt/gvm
  10. ExecStart=/opt/gvm/sbin/gsad --listen=0.0.0.0
  11. [Install]
  12. WantedBy=multi-user.target
  13. EOF

30 生成pdf报告

root用户

  1. install texlive-collection-fontsrecommended texlive-collection-latexrecommended texlive-changepage texlive-titlesec
  2. mkdir -p /usr/share/texlive/texmf-local/tex/latex/comment
  3. cd /usr/share/texlive/texmf-local/tex/latex/comment
  4. wget http://mirrors.ctan.org/macros/latex/contrib/comment/comment.sty
  5. chmod 644 comment.sty
  6. texhash
  7. history

31,开机自启

AS ROOT:
systemctl daemon-reload
systemctl enable ospd
systemctl enable gvmd
systemctl enable gsad

32,运行服务

AS ROOT:
systemctl start ospd
systemctl start gvmd
systemctl start gsad

日志文件路径  /opt/gvm/var/log/gvm.

33 ,修改默认扫描器

gvmd --get-scanners
08b69003-5fc2-4037-a479-93b440211c73 OpenVAS /tmp/ospd.sock 0 OpenVAS Default
6acd0832-df90-11e4-b9d5-28d24461215b CVE 0 CVE
gvmd --modify-scanner=08b69003-5fc2-4037-a479-93b440211c73 --scanner-host=/opt/gvm/var/run/ospd.sock
Scanner modified.
gvmd --verify-scanner=08b69003-5fc2-4037-a479-93b440211c73
Scanner version: OpenVAS 7.0.1.

 

43,创建一个web用户

AS GVM:
gvmd --create-user admin
gvmd --user=admin --new-password=123456

 

默认使用80端口

http://ip。

一定要关闭selinux 和防火墙。

 

启动ospd服务

 

更新feeds

systemctl start ospd

systemctl status gvmd

systemctl status gsad

 

 

greenbone-certdata-sync 
greenbone-scapdata-sync 
 greenbone-nvt-sync 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/208948
推荐阅读
相关标签
  

闽ICP备14008679号