Apache中间件安全实验

实验名称:Apache中间件安全实验
实验目的:Apache服务器的安全设置,练习日志分析,虚拟主机
实验环境:CentOS 7
实验步骤:
配置基本信息如下:
1、Apache2.2默认的是prefork;
2.4默认是event
一般有三种稳定的(MPM多进程处理模块)模式,分别是prefork,worke和event,代表apache的演变与发展。
查看apache的模式,使用httpd -V命令来查看
[root@localhost ~]# httpd -V
在这里插入图片描述
2、apache prefork的httpd.conf中的配置方式:
[root@localhost ~]# vim /etc/httpd/conf.modules.d/00-mpm.conf
在这里插入图片描述
3、再次查看
[root@localhost ~]# httpd -V
在这里插入图片描述
[root@localhost ~]# cd /etc/httpd/modules/
[root@localhost modules]# ls /etc/httpd/modules/ | grep mod_mpm
在这里插入图片描述
4、使用开源版查找apache prefork的httpd.conf中的配置方式(prefork模式)很古老但是非常稳定的Apache模式。
[root@localhost modules]# vim /usr/local/httpd/conf/extra/httpd-mpm.conf
在这里插入图片描述
在这里插入图片描述
5、apache worker的httpd.conf中的配置方式(worker模式)多进程和多线程的混合模式。
[root@localhost modules]# vim /usr/local/httpd/conf/extra/httpd-mpm.conf
在这里插入图片描述
在这里插入图片描述
6、apache event的httpd.conf中的配置方式(event模式)最新模式,是稳定可用的模式
event
在这里插入图片描述
7、Apache配置虚拟主机-配置不同域名虚拟主机。
[root@localhost ~]# vim /etc/hosts
在这里插入图片描述
8、创建
[root@localhost ~]# mkdir -p /var/www/{wj.net,wj.com}
[root@localhost ~]# echo “www.wj.net” > /var/www/wj.net/index.html
[root@localhost ~]# echo “www.wj.com” > /var/www/wj.com/index.html
在这里插入图片描述
9、查看
[root@localhost ~]# cat /etc/hosts
在这里插入图片描述
10、在配置文件添加以下内容
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# vim /etc/httpd/conf.d/vhosts.conf
在这里插入图片描述
<VirtualHost *:80>
DocumentRoot “/var/www/wj.com”
ServerName www.wj.com
ErrorLog “logs/wj.com-err.log”
CustomLog "logs/wj.com-access.log"common

<VirtualHost *:80>
DocumentRoot “/var/www/wj.net”
ServerName www.wj.net
ErrorLog “logs/wj.net-err.log”
CustomLog "logs/wj.net-access.log"common

11、重启服务
[root@localhost conf.d]# systemctl restart httpd
12、在火狐访问,用回环地址就可以
http://127.0.0.1
在这里插入图片描述
用http://www.wj.net
在这里插入图片描述
13、apache配置虚拟主机-配置Apache基本身份验证。
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
在编辑文件中添加以下内容
在这里插入图片描述
<Directory “/var/www/wj.net”>
Require all granted

<Directory “/var/www/wj.net”>
AllowOverride Authconfig
AuthType Basic
AuthBasicProvider file
AuthUserFile /etc/httpd/htpasswd
AuthNAME “Please Enter YUName Pwd!”
Require user coco
14、重启服务
[root@localhost ~]# systemctl restart httpd
15、在火狐访问
http://www.wj.net
在这里插入图片描述
16、另一个不需要密码
www.wj.com
在这里插入图片描述
17、创建目录测试indexes危险性
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# mkdir abc
18、注释掉增加的
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
在这里插入图片描述
19、查看
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# ls
autoindex.conf userdir.conf welcome.conf
README vhosts.conf
20、改名字
[root@localhost conf.d]# mv vhosts.conf vhosts.conf.old
21、重启生效配置文件
[root@localhost conf.d]# systemctl restart httpd
22、测试文件
拥有这个权限很危险,可以在abc目录下随便查看文件
http://127.0.0.1/abc
在这里插入图片描述
23、在abc目录下创建一个文件测试一下
[root@localhost ~]# cd /var/www/html/abc/
[root@localhost abc]# touch qq
在这里插入图片描述
24、进入配置文件找到如图144行“Indexes”删除此处
[root@localhost abc]# vim /etc/httpd/conf/httpd.conf
在这里插入图片描述
25、重启
[root@localhost abc]# systemctl restart httpd
26、再次访问
这样才是安全的
在这里插入图片描述
26、在abc目录下有页面文件就好自动选择这个页面文件查看生成一个网页文件
[root@localhost abc]# echo “ww” > index.html
27、访问
在这里插入图片描述
29、Apache服务器日志审计。
复制日志分析练习,在[root@localhost ~]# vim rz.sh中
30、获得访问前10位的ip地址
[root@localhost ~]# cat rz.sh | awk ‘{print $1}’ | sort | uniq -c | sort -nr | head -10
在这里插入图片描述
31、访问次数最多的文件或页面,取前10
[root@localhost ~]# cat rz.sh | awk ‘{print $1 1}’ | sort | uniq -c | sort -nr | head -10
在这里插入图片描述
32、统计此日志文件中所有的流量
[root@localhost ~]# cat rz.sh | awk ‘{sum+=$10} END {print sum/1024/ 1024/1024 “G”}’
在这里插入图片描述
33、列出输出大于2000000byte(约200kb)的exe文件以及对应文件发生次数
[root@localhost ~]# cat rz.sh | awk ‘($10 > 200000 && $7~/.exe/){print $7}’ | sort - n | uniq -c | sort -nr | head -100
在这里插入图片描述
34、如果日志最后一列记录的是页面文件传输时间,则有列出到客户端最耗时的页面
[root@localhost ~]# cat rz.sh | awk '($10 > 200000 && $7~/.e[root@localhost ~]# cat rz.sh | awk ‘($7-/.php/){print $NF " " $1 " " $4 " " $7}’ | sort -nr | head -20

在这里插入图片描述
35、列出最最耗时的页面(超时60秒的)的以及对应页面发生次数
[root@localhost ~]# cat rz.sh | awk ‘($NF > 60 && $7~/.php/){print $7}’ | sort -n | uniq -c | sort -nr | head -2
在这里插入图片描述

36、列出传输时间超过30秒的文件
[root@localhost ~]# cat rz.sh | awk ‘($NF > 30){print $7}’ | sort -n | uniq -c | sort -nr | head -20
在这里插入图片描述
37、统计404的连接
[root@localhost ~]# awk ‘($9~/404/)’ rz.sh | awk ‘{print $9,$7}’ | sort | uniq -c | head -10
在这里插入图片描述
38、统计HTTP Status
[root@localhost ~]# cat rz.sh | awk ‘{print $9}’ | sort | uniq -c | sort -rn
在这里插入图片描述
39、蜘蛛分析查看是哪些蜘蛛来访问过
[root@localhost ~]# cat rz.sh | awk ‘{print $12}’ | grep -iE ‘bot|crawler|slurp|spider’ |sort |uniq -c
在这里插入图片描述
至此,Apache中间件安全实验成功!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值