CentOS7 Redis 上的 OpenVAS 无法启动

Tho*_*rin 1 centos openvas redis

我正在尝试按照下面的文章让 OpenVAS 工作。

https://www.atlantic.net/community/howto/install-openvas-vulnerability-scanner-centos-7

但是它不起作用,当我运行 openvas-check-setup 时出现以下错误,当我检查 /var/log/redis/redis.log 时,它显示“打开 Unix 套接字:绑定:权限被拒绝”

openvas-check-setup 2.3.7   Test completeness and readiness of OpenVAS-8   (add '--v6' or '--v7' or '--v9'    if you want to check for another OpenVAS version)

  Please report us any non-detected problems and   help us to improve this check routine:   http://lists.wald.intevation.org/mailman/listinfo/openvas-discuss

  Send us the log-file (/tmp/openvas-check-setup.log) to help analyze the problem.

  Use the parameter --server to skip checks for client tools   like GSD and OpenVAS-CLI.

Step 1: Checking OpenVAS Scanner ...
        OK: OpenVAS Scanner is present in version 5.0.7.
        OK: OpenVAS Scanner CA Certificate is present as /var/lib/openvas/CA/cacert.pem.
        OK: redis-server is present in version v=3.0.7.
        OK: scanner (kb_location setting) is configured properly using the redis-server socket: /tmp/redis.sock
        ERROR: redis-server is not running or not listening on socket: /tmp/redis.sock
        FIX: You should start the redis-server or configure it to listen on socket: /tmp/redis.sock

 ERROR: Your OpenVAS-8 installation is not yet complete!
Run Code Online (Sandbox Code Playgroud)

Mic*_*ton 5

恭喜,您发现了一个糟糕的 Internet 教程。该教程的作者似乎从未亲自测试过它是否有效,因为它不能按原样运行。更糟糕的是,该教程似乎实际上是从官方 OpenVAS 网站链接的,这会误导和挫败很多人。

因此,redis 无法启动的原因是 SELinux 拒绝 redis-server 写入/tmp. 您可以在审核日志中看到这一点:

type=AVC msg=audit(1482284806.464:112): avc:  denied  { write } for  pid=1275 comm="redis-server" name="tmp" dev="dm-0" ino=33574981 scontext=system_u:system_r:redis_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=dir
type=SYSCALL msg=audit(1482284806.464:112): arch=c000003e syscall=49 success=no exit=-13 a0=5 a1=7ffe55938670 a2=6e a3=7ffe55938614 items=0 ppid=1 pid=1275 auid=4294967295 uid=997 gid=995 euid=997 suid=997 fsuid=997 egid=995 sgid=995 fsgid=995 tty=(none) ses=4294967295 comm="redis-server" exe="/usr/bin/redis-server" subj=system_u:system_r:redis_t:s0 key=(null)
Run Code Online (Sandbox Code Playgroud)

而不是/tmp,套接字文件应位于/run/redis,例如:

unixsocket /run/redis/redis.sock
Run Code Online (Sandbox Code Playgroud)

这允许它在 SELinux 施加的约束内运行。

在编辑时/etc/redis.conf,一定要检查文件底部是否有第二 unixsocket条指令被添加,openvas-setup并将其删除为多余的。

当然,通常在启用 SELinux 的系统上,redis 应该配置为侦听本地主机上的 TCP 端口,而不是使用套接字,因为其他守护进程可能不允许通过套接字与 redis 通信,而只能通过 TCP。这不是真正的问题,因为 OpenVAS(还)不是 SELinux 限制的,但它也不支持通过 TCP 联系 redis。这样做的结果是,除了 OpenVAS 的本地副本之外,此 redis 安装无法与任何其他服务共享或重用。


但是本教程的错误不止于此!

第二件事是 OpenVAS 没有任何地方被配置为实际使用 redis。它依赖于默认编译,正如我们所见,这是错误的。为了解决这个问题,需要设置一个配置指令/etc/openvas/openvassd.conf,一些东西,教程从来没有提到:

kb_location = /run/redis/redis.sock
Run Code Online (Sandbox Code Playgroud)

第三件事是,它采用了第三方回购称为原子,它提供的软件包,在正常的回购,如EPEL与包冲突-它已经提供的Redis和OpenVAS!不清楚为什么 atomic 会这样做,也不清楚为什么本教程开始使用 atomic。使用带有冲突包的存储库具有潜在危险。如果您继续使用原子包,您将需要绝对确定这台(虚拟)机器不会出于任何原因用于任何其他用途。

最后,一旦你安装了它,网络界面实际上是无法访问的,因为指定的端口没有在防火墙中打开。你也必须自己做这件事。

firewall-cmd --add-port=9392/tcp    # though this opens it to the world
firewall-cmd --runtime-to-permanent
Run Code Online (Sandbox Code Playgroud)

完成后,openvas-check-setup应该说,除此之外...

        OK: scanner (kb_location setting) is configured properly using the redis-server socket: /run/redis/redis.sock
        OK: redis-server is running and listening on socket: /run/redis/redis.sock.
        OK: redis-server configuration is OK and redis-server is running.
Run Code Online (Sandbox Code Playgroud)

具有讽刺意味的是,它还会说:

        ERROR: SELinux is enabled. For a working OpenVAS installation you need to disable it.
        FIX: Please disable SELinux.
Run Code Online (Sandbox Code Playgroud)

这似乎是完全没有必要和不必要的,因为 OpenVAS 无论如何都不会受到 SELinux 的限制。