RHEL 8 - CIS安全合规基线、SCAP、SSG和合规扫描、漏洞扫描

12 篇文章 1 订阅

OpenShift 4.x HOL教程汇总

CIS互联网安全中心

CIS(互联网安全中心)提供各种网络安全相关服务,它制作了各种安全基准以保护系统免受不断变化的安全威胁。CIS 基准是目标系统安全配置的最佳实践。CIS 基准适用于 25 多个供应商产品系列的 100 多个 CIS 基准,是通过由全球网络安全专业人员和主题专家组成的独特的基于共识的流程开发的。CIS 基准是唯一一种基于共识的最佳实践安全配置指南,已被政府、企业、行业和学术界开发和接受。

这些基准以 PDF 的形式免费提供给 CIS 成员,PDF 中的内容是可读的但不能直接被扫描工具使用。CIS 为付费会员提供了一些 XCCDF1 格式的基准,可以被工具使用,不过这些基准不包含改变服务器状态以达到合规性所需的自动化和补救步骤。

CIS 基准包括多种 Profile 配置:

  1. 1 级 Profile 是一个基本建议,可以相当迅速地实施,其设计不会对性能产生广泛影响。1 级 Profile 基准的目的是降低企业的攻击面,同时保持机器的可用性,不妨碍业务功能。
  2. 2 级 Profile 是 "深度防御"级别建议,旨在为安全至关重要的环境服务。如果不适当地或不谨慎地实施与 2 级 Profile 相关的建议,会对你的组织产生不利影响。
  3. STIG Profile 取代了以前的 3 级。STIG Profile 提供了所有针对 STIG 的建议。其他 Profile (即1级和2级)中的建议的重叠部分,在 STIG Profile 中也有适用。

SCAP安全内容自动化协议

安全内容自动化协议 (SCAP) 由 NIST 组织制定的一套信息安全评估标准体系。SCAP安全指南实施了由权威机构 PCI DSS,STIG 和 USGCB推荐的安全指南。SCAP 安全指南将这些安全指南转换为机器可读的格式,可以使用它来审核目标系统。

SCAP 由两部分组成:Protocol(协议)与Content(内容)。Protocol 是指 SCAP 由一系列现有的公开标准构成,这些公开标准被称为 SCAP Element(SCAP元素)。Protocol 规范了这些 Element 之间如何协同工作,Content 指按照 Protocol 的约定,利用 Element 描述生成的应用于实际检查工作的数据。

SCAP标准包含以下组件:XCCDF,OVAL,DataStream,ARF,CPE,CVE,CWE。

  1. XCCDF-可扩展配置清单描述格式。该语言用于描述安全检查表,文档生成,组织和定制合规情境,自动合规性测试以及合规性评分。在评估XCCDF基准时,通常会处理 XCCDF文件,OVAL 文件和 CPE 词典。
  2. OVAL-开放漏洞和评估语言。它用来描述系统的安全漏洞或所需的配置。OVAL 定义了计算机中某些对象的安全状态,例如配置文件、文件权限、进程。OVAL定义是通过 scanner 解释器进行评估的。
  3. CPE-通用平台枚举。CPE用来描述漏洞影响了什么组件的什么版本,是信息技术系统,软件和程序包的结构化命名方案。
  4. CVE-通用漏洞和披露。它是公开披露的安全漏洞列表。
  5. CWE-通用弱点列举。它是由 MITRE 公司支持的,用来描述已知的安全弱点和缺陷。CWE 提供了关于预防、实施和缓解弱点的信息。
  6. DataStream-是一种将其他 SCAP 组件打包到一个文件中的格式。因为单个文件更易于处理,所以RedHat建议使用 DataStream。
  7. ARF-资产报告格式。它合并了多个结果文件(OVAL 结果和 XCCDF 结果),通常也称为 Result DataStream。

SCAP Security Guide - SSG

为了实现自动化安全基线扫描,Red Hat 向用户提供“scap-security-guidelines”软件包,包含了基于SCAP的基准扫描合规性、自动化修复所需内容:

  1. openscap-scanner: 基于 SCAP 的命令扫描工具。
  2. scap-security-guide: 是 SCAP 的内容,包含定义合规 Profile 以及补救修复所需的文件,如红帽 Ansible 自动化平台 Playbook 或 Bash 脚本。
  3. scap-workbench: 基于 SCAP 的图形界面扫描工具。

其中安全合规 Profile、修复执行脚本通过 SSG 构建系统构建成“scap-security-guidelines”软件包。在 SSG 中红帽推荐使用 DataStream,它是一种 XML 文件,可将其他SCAP组件打包成一个文件。这在分发 SCAP 内容时很有用,因为单个文件更容易处理。
在这里插入图片描述
如果想对本地系统进行配置或漏洞扫描,那么必须具备以下条件:

  1. 一个工具(oscap 或 SCAP Workbench)
  2. SCAP 内容(可以是 DataStream、XCCDF、OVAL三种格式)

安装 SCAP Security Guide

如果没有配置 RHEL 的 Yum Repo,可以参考《RHEL 8 - 配置基于安装 ISO 文件的 YUM Repo》配置 Yum。以下使用的是 RHEL 8.4 的 ISO 作为 Yum Repo。

scap-security-guide 运行所需要的包有以下三个文件:

$ ll /mnt/rhel8/AppStream/Packages/scap*
-r--r--r--. 449 root root 8093716 Feb 17  2021 /mnt/rhel8/AppStream/Packages/scap-security-guide-0.1.54-5.el8.noarch.rpm
-r--r--r--. 449 root root 6226080 Feb 17  2021 /mnt/rhel8/AppStream/Packages/scap-security-guide-doc-0.1.54-5.el8.noarch.rpm
-r--r--r--. 116 root root 1940900 Feb 12  2021 /mnt/rhel8/AppStream/Packages/scap-workbench-1.2.0-8.el8.x86_64.rpm

然后运行以下命令可在安装相关的 OpenSCAP 组件,分别是扫描工具 “openscap-scanner” 、SCAP 内容 “scap-security-guide” 和 SCAP 内容的说明文档 “scap-security-guide-doc”。

$ yum install openscap-scanner scap-security-guide scap-security-guide-doc

另外还可从 https://access.redhat.com/downloads 中查找对应 RHEL 版本的 “scap-security-guide” 相关的软件包。
在这里插入图片描述
我们还可以单独下载 “scap-security-guide”。由于不同版本的 RHEL 对应不同的 “scap-security-guide” ,可从 https://access.redhat.com/articles/6337261 中查找特定版本 RHEL 对应的 “scap-security-guide” 。
在这里插入图片描述
然后可从 https://github.com/ComplianceAsCode/content/releases 中下载对应版本的 scap-security-guide 打包文件。
注意:在 https://github.com/ComplianceAsCode/content/releases 下载的 scap-security-guide 包含更全的内容,除了包含 RHEL 外还包含其他各种常用 Linux 甚至还包含 RHCOS 的内容。

了解 SCAP Security Guide 中包含的内容

在 OpenSCAP 的 “scap-security-guide” 目录中提供了用于自动化检查和修复的脚本,其中包含 Ansible Playbook、Bash Shell 和 Anaconda Kickstart 三种类型的脚本。其中 Ansible 脚本支持 check-mode 和 run-mode 两种模式,分别用来进行检查合规和设置修复合规配置;而 Bash Shell 脚本用来设置修复合规配置(部分修复是由 Shell 脚本)。

$ ll /usr/share/scap-security-guide
total 12
drwxr-xr-x. 2 root root 4096 Feb 11 09:58 ansible
drwxr-xr-x. 2 root root 4096 Feb 11 09:58 bash
drwxr-xr-x. 2 root root 4096 Feb 11 09:58 kickstart

使用 OpenSCAP 可以对目标进行合规基线检查,其中除了 RHEL 6/7/8 外还支持对 JRE 等软件进行检查。合规检查的方法和项目在以下文件中有描述。每个文件名在 “ssg-XXXXXX” 后面是不同的合规检查描述规范。

$ ls /usr/share/xml/scap/ssg/content
ssg-firefox-cpe-dictionary.xml  ssg-jre-cpe-dictionary.xml  ssg-rhel6-cpe-dictionary.xml  ssg-rhel7-cpe-dictionary.xml  ssg-rhel8-cpe-dictionary.xml
ssg-firefox-cpe-oval.xml        ssg-jre-cpe-oval.xml        ssg-rhel6-cpe-oval.xml        ssg-rhel7-cpe-oval.xml        ssg-rhel8-cpe-oval.xml
ssg-firefox-ds-1.2.xml          ssg-jre-ds-1.2.xml          ssg-rhel6-ds-1.2.xml          ssg-rhel7-ds-1.2.xml          ssg-rhel8-ds-1.2.xml
ssg-firefox-ds.xml              ssg-jre-ds.xml              ssg-rhel6-ds.xml              ssg-rhel7-ds.xml              ssg-rhel8-ds.xml
ssg-firefox-ocil.xml            ssg-jre-ocil.xml            ssg-rhel6-ocil.xml            ssg-rhel7-ocil.xml            ssg-rhel8-ocil.xml
ssg-firefox-oval.xml            ssg-jre-oval.xml            ssg-rhel6-oval.xml            ssg-rhel7-oval.xml            ssg-rhel8-oval.xml
ssg-firefox-xccdf.xml           ssg-jre-xccdf.xml           ssg-rhel6-xccdf.xml           ssg-rhel7-xccdf.xml           ssg-rhel8-xccdf.xml

查看说明 SCAP 内容的指导描述文档,可以看到 SSG 为每类合规检查对象提供了哪些检查 Profile。

$ ls /usr/share/doc/scap-security-guide/guides/
ssg-firefox-guide-default.html                  ssg-rhel6-guide-stig.html                           ssg-rhel7-guide-rhelh-stig.html
ssg-firefox-guide-index.html                    ssg-rhel6-guide-usgcb-rhel6-server.html             ssg-rhel7-guide-rhelh-vpp.html
ssg-firefox-guide-stig.html                     ssg-rhel6-PCIDSS-RHEL-6-guide-default.html          ssg-rhel7-guide-rht-ccp.html
ssg-jre-guide-default.html                      ssg-rhel6-PCIDSS-RHEL-6-guide-pci-dss_centric.html  ssg-rhel7-guide-standard.html
ssg-jre-guide-index.html                        ssg-rhel7-guide-anssi_nt28_enhanced.html            ssg-rhel7-guide-stig.html
ssg-jre-guide-stig.html                         ssg-rhel7-guide-anssi_nt28_high.html                ssg-rhel7-PCIDSS-RHEL-7-guide-default.html
ssg-rhel6-guide-C2S.html                        ssg-rhel7-guide-anssi_nt28_intermediary.html        ssg-rhel7-PCIDSS-RHEL-7-guide-pci-dss_centric.html
ssg-rhel6-guide-CS2.html                        ssg-rhel7-guide-anssi_nt28_minimal.html             ssg-rhel8-guide-anssi_bp28_enhanced.html
ssg-rhel6-guide-CSCF-RHEL6-MLS.html             ssg-rhel7-guide-C2S.html                            ssg-rhel8-guide-anssi_bp28_intermediary.html
ssg-rhel6-guide-default.html                    ssg-rhel7-guide-cis.html                            ssg-rhel8-guide-anssi_bp28_minimal.html
ssg-rhel6-guide-desktop.html                    ssg-rhel7-guide-cjis.html                           ssg-rhel8-guide-cis.html
ssg-rhel6-guide-fisma-medium-rhel6-server.html  ssg-rhel7-guide-cui.html                            ssg-rhel8-guide-cui.html
ssg-rhel6-guide-ftp-server.html                 ssg-rhel7-guide-default.html                        ssg-rhel8-guide-default.html
ssg-rhel6-guide-index.html                      ssg-rhel7-guide-e8.html                             ssg-rhel8-guide-e8.html
ssg-rhel6-guide-nist-CL-IL-AL.html              ssg-rhel7-guide-hipaa.html                          ssg-rhel8-guide-hipaa.html
ssg-rhel6-guide-pci-dss.html                    ssg-rhel7-guide-index.html                          ssg-rhel8-guide-index.html
ssg-rhel6-guide-rht-ccp.html                    ssg-rhel7-guide-ncp.html                            ssg-rhel8-guide-ospp.html
ssg-rhel6-guide-server.html                     ssg-rhel7-guide-ospp.html                           ssg-rhel8-guide-pci-dss.html
ssg-rhel6-guide-standard.html                   ssg-rhel7-guide-pci-dss.html                        ssg-rhel8-guide-stig.html

在浏览器中打开 “ssg-rhel8-guide-cis.html” 文件,可以在下图的描述中查看该文档对应的是哪种 Profile。
在这里插入图片描述
在 Profile 的说明中检查项目和规则被分为若干大类,见下图。注意:下图中 SSG 对 CIS 的项目分类和 CIS 官方分类有区别,在本文后面介绍如何对合规结果按照 CIS 的分类重新排序项目指标。
在这里插入图片描述
为了了解 “ssg-rhel8-guide-cis.html” 文档的内容,可以在文档中找到名为 “Set Lockouts for Failed Password Attempts” 的 Group,如下图的组包含3个规则(截图有限,只显示了 1 个规则)。
在这里插入图片描述
在上图下方的 References 区域是使用该规则所有的合规项目,其中 “5.4.3” 会链接到 CIS。我们可以在 CIS 网站获得《CIS RHEL 8 Benchmark》文档,并确认编号 “5.4.3” 的内容也是限制用户密码重用的规则。
在这里插入图片描述
注意:在上面 SSG 的 ssg-rhel8-guide-cis.html 文件中使用的引用的 CIS 编号是和 SSG 的版本以及 CIS 的版本相关。两者的版本如果不兼容,则无法对应上。

注意:无论在 ssg-rhel8-guide-cis.html 文件中还是在《CIS RHEL 8 Benchmark》文档中都提供了项目的修复代码,但两者的代码有一定差异。

还可在 ssg-rhel8-guide-cis.html 中查找 Rule ID 为 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny” 的规则,它对应的是上图中 CIS 为 “5.4.2” 的条目。

用 OpenSCAP 进行 CIS 合规扫描

查看 DataStream 文件包含的 Profile

执行命令查看 ssg-rhel8-ds.xml 中支持包含的 Profile,其中有一个的 Title 为 “CIS Red Hat Enterprise Linux 8 Benchmark”。另外从 Id 名称可以知道,该 Data Stream 中所有 Profile 使用的是 XCCDF 格式定义的。

$ oscap info /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Document type: Source Data Stream
Imported: 2021-02-17T10:44:54

Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml
Generated: (null)
Version: 1.3
Checklists:
        Ref-Id: scap_org.open-scap_cref_ssg-rhel8-xccdf-1.2.xml
WARNING: Datastream component 'scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml' points out to the remote 'https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml'. Use '--fetch-remote-resources' option to download it.
WARNING: Skipping 'https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml' file which is referenced from datastream
                Status: draft
                Generated: 2021-02-17
                Resolved: true
                Profiles:
                        Title: ANSSI-BP-028 (enhanced)
                                Id: xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced
                        Title: ANSSI-BP-028 (intermediary)
                                Id: xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary
                        Title: ANSSI-BP-028 (minimal)
                                Id: xccdf_org.ssgproject.content_profile_anssi_bp28_minimal
                        Title: CIS Red Hat Enterprise Linux 8 Benchmark
                                Id: xccdf_org.ssgproject.content_profile_cis
                        Title: Unclassified Information in Non-federal Information Systems and Organizations (NIST 800-171)
                                Id: xccdf_org.ssgproject.content_profile_cui
                        Title: Australian Cyber Security Centre (ACSC) Essential Eight
                                Id: xccdf_org.ssgproject.content_profile_e8
                        Title: Health Insurance Portability and Accountability Act (HIPAA)
                                Id: xccdf_org.ssgproject.content_profile_hipaa
                        Title: Protection Profile for General Purpose Operating Systems
                                Id: xccdf_org.ssgproject.content_profile_ospp
                        Title: PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 8
                                Id: xccdf_org.ssgproject.content_profile_pci-dss
                        Title: DISA STIG for Red Hat Enterprise Linux 8
                                Id: xccdf_org.ssgproject.content_profile_stig
                Referenced check files:
                        ssg-rhel8-oval.xml
                                system: http://oval.mitre.org/XMLSchema/oval-definitions-5
                        ssg-rhel8-ocil.xml
                                system: http://scap.nist.gov/schema/ocil/2
                        security-data-oval-com.redhat.rhsa-RHEL8.xml
                                system: http://oval.mitre.org/XMLSchema/oval-definitions-5
Checks:
        Ref-Id: scap_org.open-scap_cref_ssg-rhel8-oval.xml
        Ref-Id: scap_org.open-scap_cref_ssg-rhel8-ocil.xml
        Ref-Id: scap_org.open-scap_cref_ssg-rhel8-cpe-oval.xml
        Ref-Id: scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml
Dictionaries:
        Ref-Id: scap_org.open-scap_cref_ssg-rhel8-cpe-dictionary.xml

可以注意到上面有 “WARNING” 提示,这是因为 ssg-rhel8-ds.xml 文件引用了在线的 com.redhat.rhsa-RHEL8.xml 文件。可以根据提示在以上命令中通过增加 ‘--fetch-remote-resources’ 参数,还可以根据提示下载 https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml 文件到 /usr/share/xml/scap/ssg/content 目录中,然后再修改 ssg-rhel8-ds.xml 文件以下部分的 2 处远程引用,即可修复告警。
在这里插入图片描述
执行命令,查看名为 xccdf_org.ssgproject.content_profile_cis 的 Profile 信息。注意:可以根据 Description 了解当前 CIS Profile 的版本为 “v1.0.0”。

$ oscap info --fetch-remote-resources --profile xccdf_org.ssgproject.content_profile_cis /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Document type: Source Data Stream
Imported: 2021-02-17T10:44:54

Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml
Generated: (null)
Version: 1.3
Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml ... ok
Profile
        Title: CIS Red Hat Enterprise Linux 8 Benchmark
        Id: xccdf_org.ssgproject.content_profile_cis

        Description: This profile defines a baseline that aligns to the Center for Internet Security® Red Hat Enterprise Linux 8 Benchmark™, v1.0.0, released 09-30-2019.  This profile includes Center for Internet Security® Red Hat Enterprise Linux 8 CIS Benchmarks™ content.

CIS 合规扫描

全面扫描

执行以下命令,使用 ssg-rhel8-ds.xml 中名为 “CIS Red Hat Enterprise Linux 8 Benchmark” 对应的 Profile Id 进行合规扫描。将扫描结果保存在 cis-result.xml 文件中,该文件可用于 OpenSCAP 工具后续处理,不适合人直接查阅;而供人查看的扫描报告是 cis-report.html。

$ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results-arf cis-results.xml --report cis-report.html --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

局部扫描

执行以下命令,只使用 CIS Profile(这里使用了 CIS 的简称)中的 “content_rule_accounts_passwords_pam_faillock_deny” 规则进行扫描。

$ oscap xccdf eval --profile cis --rule xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny --report cis-rule-report.html --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml ... ok
Title   Set Deny For Failed Password Attempts
Rule    xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
Ident   CCE-80667-9
Result  fail

查看 CIS 合规扫描结果,了解 SSG DS 定义文件内容。

可以查看扫描结果文件 cis-results.xml,从 “Group rules by” 下拉框中选择下图的 CIS 地址,此时下方的扫描结果就会按照 CIS 分类和编号进行重新排序。
在这里插入图片描述
在扫描结果文件中可以根据 Rule ID 查找 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny”,可以看到该规则的检查结果。
在这里插入图片描述
查看上图的 “Set Deny For Failed Password Attempts” 链接,可以得到下图详细的扫描结果。从中可以看出名为 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny” 的 Rule ID 对应的是内容为 “oval:ssg-accounts_passwords_pam_faillock_deny:def:1” 的 “OVAL Definition ID”。
在这里插入图片描述
在 “ssg-rhel8-ds.xml” 文件中可以找到 “oval:ssg-accounts_passwords_pam_faillock_deny:def:1” 的 OVAL Definition ID,它定义了规则是如何实现的。其下有 8 个 “oval-def:criterion”,每个都包含了一个 “test_ref” ,例如 “oval:ssg-test_accounts_passwords_pam_faillock_preauth_silent_system-auth:tst:1”。这 8 个 “test_ref” 对应上图下方显示的OVAL test results 的 8 个项目。
在这里插入图片描述
下面结合上面一个 test-ref 的内容进行进一步分析。查找上图第一个 “oval-def:criterion” 对应的 test-ref:“oval:ssg-test_accounts_passwords_pam_faillock_preauth_silent_system-auth:tst:1”,可以获得下图的内容,其中包含了 OVAL 需要检查的对象和状态。
在这里插入图片描述
然后在 “ssg-rhel8-ds.xml” 文件中查找上图中 “oval:ssg-object_accounts_passwords_pam_faillock_when_lines_skipped_system-auth:obj:1” 可以得到下图的内容。
在这里插入图片描述
根据上图的 var_ref 在文件中查找 “oval:ssg-object_accounts_passwords_pam_faillock_when_lines_skipped_system-auth:obj:1”,可以看到下图对象。
在这里插入图片描述
根据上图的 object_ref 在文件中查找 “oval:ssg-object_accounts_passwords_pam_faillock_lines_value_system-auth:obj:1”,可以看到下图内容,它定义了实现规则的操作。
在这里插入图片描述
在 “ssg-rhel8-ds.xml” 文件中查找 “oval:ssg-state_var_accounts_passwords_pam_faillock_deny_value_upper_bound:ste:1” 和 “oval:ssg-state_var_accounts_passwords_pam_faillock_deny_value_lower_bound:ste:1”(它们是向上数第 4 个图中绿框中的内容),可以看到下图 2 个对象,分别定义了表达式。
在这里插入图片描述
根据上图的 var_ref 在文件中查找 “oval:ssg-var_accounts_passwords_pam_faillock_deny:var:1”,可以看到下图的内容。
在这里插入图片描述
此时一个用 XCCDF 定义的规则就分析完了。

定制 CIS 基线扫描指标

修改 “ssg-rhel8-ds.xml” 文件,在下图的 CIS Profile 区域将 “xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny” 后的 selected 设置为 “false”。
在这里插入图片描述
执行命令再次扫描,然后查看扫描结果。

$ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results-arf customize-cis-results.xml --report customize-cis-report.html --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

确认已经找不到 “content_rule_accounts_passwords_pam_faillock_deny”了,而且 failed 状态的数量也少了 1 个。
在这里插入图片描述

修复不符合合规基线的项目

直接修复

可以使用 “–remediate” 参数在扫描的同时直接修复发现问题项目。

$ oscap xccdf eval --profile cis --rule xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny --results one-cis-results.xml --remediate --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml ... ok
Title   Set Deny For Failed Password Attempts
Rule    xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
Ident   CCE-80667-9
Result  fail

 --- Starting Remediation ---
Title   Set Deny For Failed Password Attempts
Rule    xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
Ident   CCE-80667-9
Result  fixed

生成修复 Ansible 剧本

先运行命令根据扫描结果文件生成基于 Ansible 的修复文件。

$ oscap xccdf generate fix --fix-type ansible --output PlaybookToRemediate.yml --fetch-remote-resources --result-id "" cis-result.xml

然后运行以下命令,针对当前主机执行Ansible脚本。

$ ansible-playbook -i "localhost," -c local PlaybookToRemediate.yml

最后可再次进行扫描,确认已经有大部分项目通过扫描,少量还不能通过基线的项目需要手动修复。

$ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --fetch-remote-resources --report customize-cis-report.html /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml

转换文件

所有 SCAP 包含的对象都是用 XML 来进行描述,因此可以对基于 XML 规范的 SCAP 内容文档进行格式转换、内容拆分组合。

分解 DataStream 文件

执行命令,可以将在 ssg-rhel8-ds.xml 文件中包含的内容分解出来。

$ oscap ds sds-split --fetch-remote-resources /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml ssg-rhel8-ds-extracted/
$ ls -1 ssg-rhel8-ds-extracted/
scap_org.open-scap_cref_ssg-rhel8-cpe-dictionary.xml
scap_org.open-scap_cref_ssg-rhel8-xccdf-1.2.xml
security-data-oval-com.redhat.rhsa-RHEL8.xml
ssg-rhel8-cpe-oval.xml
ssg-rhel8-ocil.xml
ssg-rhel8-oval.xml

将 XCCDF 文档从适合机器处理的XML格式转为适合人工查看的HTML格式

以下将根据 ssg-rhel8-xccdf.xml 中的 CIS Profile 生成 HTML 格式的 Guide 文件。

$ oscap xccdf generate guide --profile cis /usr/share/xml/scap/ssg/content/ssg-rhel8-xccdf.xml > rhel8-cis-guide.html

以下将根据适合机器处理的 cis-results.xml 扫描结果文件生成 HTML 格式的 Report 文件,以方便人工阅读。

$ oscap xccdf generate report cis-results.xml > cis-report.html

用 OpenSCAP 进行 OVAL 安全漏洞扫描

红帽安全队为 RHEL 的漏洞提供了基于 OVAL 的扫描定义,用户能够执行漏洞扫描以诊断系统是否受到 CVE 漏洞攻击。使用 OpenSCAP 不但可以直接根据 OVAL 进行漏洞扫描,还可以根据 OVAL + XCCDF 或 Source DataStream 文件进行漏洞扫描(后面两种的扫描结果格式更友好)。

执行以下命令,前面是根据 Source DataStream 进行 CVE 漏洞扫描,后面是根据 OVAL + XCCDF 进行 CVE 漏洞扫描。

$ wget https://www.redhat.com/security/data/metrics/ds/com.redhat.rhsa-all.ds.xml
$ oscap xccdf eval --results cve-results.xml --report cve-report.html com.redhat.rhsa-all.ds.xml

$ wget https://www.redhat.com/security/data/metrics/com.redhat.rhsa-all.xccdf.xml
$ wget https://www.redhat.com/security/data/oval/com.redhat.rhsa-all.xml
$ oscap xccdf eval --results cve-results.xml --report cve-report.html com.redhat.rhsa-all.xccdf.xml

参考

https://access.redhat.com/articles/6337261
https://access.redhat.com/sites/default/files/attachments/scap-security-guide-0.1.50-scap-1.3-rhel8.zip
https://github.com/ComplianceAsCode/content/releases
http://www.open-scap.org/security-policies/choosing-policy/
https://www.redhat.com/en/blog/center-internet-security-cis-compliance-red-hat-enterprise-linux-using-openscap
https://ncp.nist.gov/repository
https://static.open-scap.org/openscap-1.3/oscap_user_manual.html
https://www.redhat.com/en/blog/center-internet-security-cis-compliance-red-hat-enterprise-linux-using-openscap
http://static.open-scap.org/openscap-1.3/oscap_user_manual.html

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在提到RHEL cp -R命令之前,需要先进行一些前置步骤。首先,我们需要解压缩rhel-server-7.5-x86_64-dvd.part1.rar和rhel-server-7.5-x86_64-dvd.part2.rar这两个文件。可以使用rar命令来解压缩这些文件。在命令行中执行以下命令: [root@server1 ~]# rar e rhel-server-7.5-x86_64-dvd.part*.rar 这个命令将解压缩这两个文件。 接下来,我们需要检查是否有rarlinux-5.6.1.tar.gz这个包。如果没有,您可以从https://www.rarlab.com/download.htm这个网站下载RAR 5.61 for Linux或RAR 5.61 for Linux x64。 一旦我们解压缩了rhel-server-7.5-x86_64-dvd.part1.rar和rhel-server-7.5-x86_64-dvd.part2.rar,并且有了rarlinux-5.6.1.tar.gz这个包,我们就可以使用cp -R命令来复制文件或目录。 RHEL cp -R命令用于递归地复制一个目录及其内容到另一个目录。其中,-R选项表示递归复制,即复制目录及其所有子目录和文件。在命令行中执行以下命令: [root@server1 ~]# cp -R /path/to/source/directory /path/to/destination/directory 将"/path/to/source/directory"替换为您要复制的源目录的路径,将"/path/to/destination/directory"替换为您要将源目录复制到的目标目录的路径。 请确保您具有足够的权限来执行复制操作,并且源目录和目标目录的路径是正确的。 总结起来,要使用RHEL cp -R命令复制文件或目录,您需要先解压缩rhel-server-7.5-x86_64-dvd.part1.rar和rhel-server-7.5-x86_64-dvd.part2.rar文件,而后检查是否有rarlinux-5.6.1.tar.gz包,最后使用cp -R命令进行复制操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [rhel-server-7.5-x86_64-dvd.iso镜像下载及rar压缩包的解压](https://blog.csdn.net/weixin_41922887/article/details/85009541)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值