File: //opt/BCLinux/bse/include/generate_html_report.sh
#!/bin/sh
MY_IP=$(ip a s | grep "\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}" | grep -v 127 | awk -F ' ' '{print $2}')
cat <<- EOF > ${LOGDIR}/${HTML_REPORT_DIRNAME}/index.html
<!DOCTYPE html>
<html>
<head>
<meta name="generator"
content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<title>BC-Linux 系统安全评估报告</title>
<link rel="stylesheet" href="reportfiles/css/ns_report.css" />
<link rel="stylesheet" href="reportfiles/css/ns_report_rsas.css" />
<link rel="stylesheet" href="reportfiles/js/datepicker/skin/WdatePicker.css" />
<script src="reportfiles/js/jquery.js"></script>
<script src="reportfiles/js/common.js"></script>
<script src="reportfiles/js/datepicker/WdatePicker.js"></script>
</head>
<body>
<div id="report" class="wrapper_w800">
<div class="report_tip"></div>
<div id="head" class="report_title">
<h1>"BC-Linux 系统"安全评估报告</h1>
</div>
<!--head end,catalog start-->
<div id="catalog">
<div class="report_h1">目录</div>
</div>
<div id="content">
<div class="report_h report_h1">1.综述信息</div>
<div class="report_content">
<div class="report_h report_h2" id="title00">1.1任务信息</div>
<div>
<table class="report_table plumb">
<tbody>
<tr class="odd">
<th width="120" style="vertical-align:middle">整体评估结果</th>
<td style="padding:6px;">
<img align='absmiddle' src='reportfiles/images/${SECURE_IMG}' title=' ${SECURE_LEVEL} ' />
<span class="level_danger middle" style='color:#A60000'>${SECURE_LEVEL}</span></td>
</tr>
</tbody>
</table>
<table width="100%">
<tr>
<td width="50%" valign='top'>
<table class="report_table plumb">
<tbody>
<tr class="odd">
<th width="120">任务名称</th>
<td>BC-Linux 系统安全评估报告</td>
</tr>
<tr class="even">
<th>任务类型</th>
<td>基线检查与常规软件漏洞扫描</td>
</tr>
<tr class="odd">
<th width="120">任务状态</th>
<td>扫描完成</td>
</tr>
<tr class="even">
<th>漏洞扫描模板</th>
<td>系统基线配置与常规软件漏扫</td>
</tr>
<tr class="odd">
<th>下达任务用户</th>
<td>${USER}</td>
</tr>
<tr class="even">
<th>任务数据来源</th>
<td>本地扫描</td>
</tr>
<tr class="odd">
<th>任务说明</th>
<td>BC-Linux安全加固分析工具</td>
</tr>
</tbody>
</table>
</td>
<td width="20px"></td>
<td width="50%" valign='top'>
<table class="report_table plumb">
<tbody>
<tr class="odd">
<th width="120px">时间统计</th>
<td>开始:${report_datetime_start}
<br />结束:${report_datetime_end}</td>
</tr>
<tr class="even">
<th>主机信息</th>
<td>HOSTNAME:$(hostname)
<br />IP:${MY_IP}
<br />USER:${USER}
<br />内核版本:${OS_KERNELVERSION_FULL}</td>
</tr>
<tr class="odd">
<th>扫描工具版本信息</th>
<td>${PROGRAM_NAME} - ${PROGRAM_version}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>
</div>
<div class="report_h report_h1">2.风险类别</div>
<div class="report_content">
<div class="report_h report_h2" id="vuln_risk_category">2.1 系统基线安全</div>
<div>
<table class="report_table plumb">
<thead>
<tr class="first_title">
<td width="30px">序号</td>
<!-- <td width="60px">功能模块</td> -->
<td width="260px">加固问题项</td>
<td>修复意见</td>
</tr>
</thead>
<tbody>
${baseline_info}
<!-- <tr style="cursor:pointer;" class="odd">
<td>1</td>
<td>用户权限</td>
<td>
<span class="font_high"> No password minlenset, please check</span>
</td>
<td>
echo "xxx" /etc/pam.d/system-auth
</td>
</tr>
-->
</tbody>
<tfoot>
<tr class="second_title">
<td colspan="2">合计</td>
<td>
<span class="font_high">${TOTAL_WARNINGS}</span>
</td>
</tr>
</tfoot>
</table>
</div>
<br />
<div class="report_h report_h2" id="title00">2.2 系统漏洞分布</div>
<div>
<!-- <div style="text-align:rightvertical-align:middle;">漏洞类别:
<img align="absbottom" src="reportfiles/images/vuln_high.gif" />高风险[3]
<img align="absbottom" src="reportfiles/images/vuln_middle.gif" />中危险[7]
<img align="absbottom" src="reportfiles/images/vuln_low.gif" />低风险[10]</div>
-->
<table class="report_table plumb">
<thead>
<tr class="first_title">
<td style='width:30px'>序号</td>
<td style='width:50px'>CVE号</td>
<td style='width:50px'>涉及软件包名</td>
<td style='width:50px'>漏洞修复版本</td>
<td style='width:25px'>漏洞评分</td>
<td style='width:25px'>利用方式</td>
<td style='width:40px'>利用复杂度</td>
<td style='width:40px'>RHSA</td>
<td >CVE漏洞描述</td>
</tr>
</thead>
<tbody>
${cve_info}
</tbody>
<tfoot>
<tr class="first_title">
<td colspan="8">合计</td>
<td>
<span class="font_high">${TOTAL_CVES}</span>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="report_h report_h1">3.主机信息</div>
<div class="report_content">
<div class="report_h report_h2" id="title00">3.1主机风险等级列表</div>
<div>
<table class="report_table plumb">
<thead>
<tr class="first_title">
<td width="130px">IP地址</td>
<td>主机名</td>
<td>操作系统</td>
<!-- td colspan="4" width="40px">漏洞风险(个)</td -->
<th width="190px" style="white-space:pre-wrap;">内核版本</th>
</tr>
</thead>
<tbody>
<tr style="cursor:pointer;" class="odd">
<td>${MY_IP}</td>
<td>$(hostname)</td>
<td>${OS_ID} ${OS_DISTRO}</td>
<td>${OS_KERNELVERSION_FULL}</td>
</tr>
</tbody>
<!-- <tfoot>
<tr class="second_title">
<td colspan="3">合计</td>
<td>
<span class="font_high">12</span>
</td>
<td>28</td>
<td>37</td>
<td>77</td>
<td>9.3</td>
</tr>
</tfoot>
-->
</table>
</div>
</div>
<div class="report_h report_h1">4.入侵检测信息</div>
<div class="report_content">
<div class="report_h report_h2" id="title00">4.1入侵检测列表</div>
<div>
<table class="report_table plumb">
<thead>
<tr class="first_title">
<td width="30px">序号</td>
<td width="400px">入侵检测项</td>
<td>检测结果或建议</td>
</tr>
</thead>
<tbody>
${rootkit_info}
</tbody>
<tfoot>
<tr class="second_title">
<td colspan="2">可疑问题项合计</td>
<td>
<span class="font_high">${TOTAL_INFECTED}</span>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="report_h report_h1">5.参考标准</div>
<div class="report_content">
<div class="report_h report_h2" id="title00">5.1安全建议</div>
<div>
<p>据市场研究公司 Gartner 研究报告称"实施漏洞管理的企业会避免近 90%
的攻击"。可以看出,及时的漏洞修补可以在一定程度上防止病毒、攻击者的威胁。</p>
<p>建议所有 BC-Linux 系统使用"yum update --security"进行更新,修复所有安全漏洞。</p>
<p>
对于BC-Linux系统发布的安全公告,用户确认后可以进行漏洞修补、补丁安装、停止服务等。</p>
<p>
对于存在弱口令的系统,需在加强使用者安全意识的前提下,督促其修改密码,或者使用策略来强制限制密码长度和复杂性。</p>
<p>
对于存在弱口令或是空口令的服务,在一些关键服务上,应加强口令强度,同时需使用加密传输方式,对于一些可关闭的服务来说,建议关闭该服务以达到安全目的。</p>
<p>
由于其他原因不能及时安装BC-Linux提供的补丁,用户可以考虑在网络边界、路由器、防火墙上设置严格的访问控制策略,以保证网络的动态安全。</p>
<p>
建议网络管理员、系统管理员、安全管理员关注BC-Linux发布的安全信息、安全动态及最新的严重漏洞,攻与防的循环,伴随每个主流操作系统、应用服务的生命周期。</p>
<p>建议采用远程安全评估系统定期对网络进行评估,真正做到未雨绸缪。</p>
<p>
远程安全评估系统建议对存在不合规检查项的主机参考对应的检查点详情中提出的调整方案和标准值进行修正。</p>
<!--
<ul style="list-style:circlepadding-left:60px;">
<li>建议......</li>
</ul>
-->
</div>
</div>
</div>
<div class="report_tip"></div>
</div>
<!--content end-->
</body>
</html>
EOF