一、实验目的:
了解Apache基线加固原理,及工作过程。
二、实验内容:
在kali中完成Apache基线加固实验。
三、实验过程:
1、(1)启动Apache2服务(2)查看Apache2服务状态(3)查看apache2版本
2.(1)查看Apache配置文件/etc/apache2/conf-available/security.conf(2)修改Apache配置文件/etc/apache2/conf-available/security.conf,改回默认配置:
ServerSignature On
ServerTokens OS
3.禁止目录遍历:
查看Apache配置文件/etc/apache2/apache2.conf
<Directory "/var/www/ ">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
删除Indexes即可实现。
4. 禁止Apache访问Web目录之外的任何文件:
参考配置操作
编辑apache2.conf配置文件,“vi /etc/apache2/apache2.conf”
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
5.监听地址
查看Apache配置文件/etc/apache2/ports.conf
加固方法:修改Apache配置文件/etc/apache2/ports.conf,设置只监听80端口Listen 80
6.运行权限设置
查看Apache配置文件/etc/apache2/apache2.conf
加固方法:
修改Apache配置文件/etc/apache2/apache2.conf,可以自定义一个较小权限的用户和组。
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
7.禁用CGI
加固方法:
编辑配置文件/etc/apache2/conf-available/serve-cgi-bin.conf,把cgi-bin目录的配置和模块注释掉。
# <IfDefine ENABLE_USR_LIB_CGI_BIN>
# ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
# <Directory "/usr/lib/cgi-bin">
# AllowOverride None
# Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
# Require all granted
</Directory>
# </IfDefine>
8.日志审核
9.自定义错误信息
查看Apache配置文件/etc/apache2/conf-available/localized-error-pages.conf,检查是否使用ErrorDocument自定义错误信息
加固方法:
修改Apache配置文件/etc/apache2/localized-error-pages.conf,自定义错误信息,可以设置返回指定字符串,文件或重定向地址,如下:
ErrorDocument 500 "The server made a boo boo."
ErrorDocument 404 /missing.html
ErrorDocument 402 http://www.example.com/subscription_info.html
常见错误代码:
403 禁止访问;404 找不到页面;500是服务器内部错误
10、关闭TRACE
11、DDOS防御
加固方法:
修改Apache配置文件/etc/apache2/apache2.conf:
Timeout 10
KeepAlive On
keepAliveTimeout 15