利用lynis如何进行linux漏洞扫描详解

2019-01-16 21:39:53王振洲

查看详细说明

在查看审计结果时,你可以通过 show details 参数来获取关于某条警告/建议的详细说明。其对应的命令形式为:

lynis show details ${test_id}

比如,上面图中有一个建议

* Consider running ARP monitoring software (arpwatch,arpon) [NETW-3032]

我们可以运行命令:

sudo lynis show details NETW-3032
2018-06-08 18:18:01 Performing test ID NETW-3032 (Checking for ARP monitoring software) 2018-06-08 18:18:01 IsRunning: process 'arpwatch' not found 2018-06-08 18:18:01 IsRunning: process 'arpon' not found 2018-06-08 18:18:01 Suggestion: Consider running ARP monitoring software (arpwatch,arpon) [test:NETW-3032] [details:-] [solution:-] 2018-06-08 18:18:01 Checking permissions of /usr/share/lynis/include/tests_printers_spools 2018-06-08 18:18:01 File permissions are OK 2018-06-08 18:18:01 ===---------------------------------------------------------------===

查看日志文件

lynis在审计完成后会将详细的信息记录在 /var/log/lynis.log 中.

sudo tail /var/log/lynis.log
2018-06-08 17:59:46 ================================================================================ 2018-06-08 17:59:46 Lynis 2.6.4 2018-06-08 17:59:46 2007-2018, CISOfy - https://cisofy.com/lynis/ 2018-06-08 17:59:46 Enterprise support available (compliance, plugins, interface and tools) 2018-06-08 17:59:46 Program ended successfully 2018-06-08 17:59:46 ================================================================================ 2018-06-08 17:59:46 PID file removed (/var/run/lynis.pid) 2018-06-08 17:59:46 Temporary files: /tmp/lynis.sGxCR0hSPz 2018-06-08 17:59:46 Action: removing temporary file /tmp/lynis.sGxCR0hSPz 2018-06-08 17:59:46 Lynis ended successfully.

同时将报告数据被保存到 /var/log/lynis-report.dat 中.

sudo tail /var/log/lynis-report.dat

另外需要注意的是,每次审计都会覆盖原日志文件.

检查更新

审计软件需要随时进行更新从而得到最新的建议和信息,我们可以使用 update info 参数来检查更新:

lynis update info --no-colors
== Lynis == Version : 2.6.4 Status : Up-to-date Release date : 2018-05-02 Update location : https://cisofy.com/lynis/ 2007-2018, CISOfy - https://cisofy.com/lynis/

自定义lynis安全审计策略

lynis的配置信息以 .prf 文件的格式保存在 /etc/lynis 目录中。 其中,默认lynis自带一个名为 default.prf 的默认配置文件。

不过我们无需直接修改这个默认的配置文件,只需要新增一个 custom.prf 文件将自定义的信息加入其中就可以了。

关于配置文件中各配置项的意义,在 default.prf 中都有相应的注释说明,这里就不详述了。