CentOS8安装服务器安全狗、Apache版网站安全狗
笺注:这是在 CentOS8安装LAMP+phpMyAdmin 的基础上进行的。
Apache的版本:
[root@centos8 ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built: Jun 8 2020 20:14:33
关闭SELinux:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
重启服务器:
reboot
安装一些依赖软件包:
yum -y install wget zlib-devel libtool ncurses-devel libxml2-devel mlocate lsof dmidecode
去官网下载最新的安全狗软件包:
wget http://down.safedog.cn/safedog_linux64.tar.gz
安装安全狗软件:(这是64位软件)
tar -zxvf safedog_linux64.tar.gz
cd safedog_an_linux64_2.8.21207/
chmod a+x *.py
[root@centos8 safedog_an_linux64_2.8.21207]# ./install.py
/usr/bin/env: “python”: 没有那个文件或目录
解决方法:
yum -y install python2
ln -s /usr/bin/python2 /usr/bin/python
[root@centos8 safedog_an_linux64_2.8.21207]# ./install.py
Need system command 'netstat' to install safedog for linux.
Installation aborted!
解决方法:
yum -y install net-tools
[root@centos8 safedog_an_linux64_2.8.21207]# ./install.py
Need system command 'killall' to install safedog for linux.
Installation aborted!
解决方法:
yum -y install psmisc
正式安装:(以下是安装Apache版网站安全狗)
[root@centos8 safedog_an_linux64_2.8.21207]# ./install.py
extracting files ...
Warning: Web defense module will restart web process during installation!!:
Web defense module select: 1.apache 2.nginx . Input(Ctrl-C to skip web defense module installation): 1
step 1/3, start install common lib [ok]
step 2/3, start Install Server Defense Module
step 2.1, checking os release version... [ok]
step 2.2, installing file... [ok]
step 2.3, start service... [ok]
step 2.4, save safedog install info...
Tips:
(1)safedog install directory: /etc/safedog
(2)install safedog version: 2.8.21207
install safedog completely
step 3/3, start install Apache Defense Module..
step 3.1, start install Apache Defend Module...
step 3.2, copy libraries [ok]
step 3.3, copy bin [ok]
step 3.4, Install apache defense module succeed.. [ok]
step 3.5, restart the apache server..send command to server ok.
[ok]
Tips:
(1)If you want to change the configuration of apache defense module, please modify the files in /etc/safedog/apache/conf;
(2)If you want to check apache defense module log, please use command: sdalog;
(3)If apache defense module is failed to use, you can try to restart Apache service.
Installation is complete!
safedog install directory:
/etc/safedog
apache defense module directory:
/etc/safedog/apache/conf
备注:
安全狗默认会随操作系统的启动而自动启动的;
如无特殊要求,服务器安全狗、网站安全狗里的规则保持默认即可;
查看安全狗是否运行中:(运行时的效果)
[root@centos8 ~]# service safedog status
safedog service is running
[root@centos8 ~]#
[root@centos8 ~]# pgrep -l sdsvrd
9091 sdsvrd
关闭安全狗:
[root@centos8 ~]# service safedog stop
stop sdsvrd server ###
safedog serivce stopped!
[root@centos8 ~]#
[root@centos8 ~]# pgrep -l sdsvrd
[root@centos8 ~]#
重启安全狗:
[root@centos8 ~]# service safedog restart
[root@centos8 ~]#
[root@centos8 ~]# pgrep -l sdsvrd
11544 sdsvrd
可运行命令sdui进入操作界面:
[root@centos8 ~]# sdui
[Firewall]->NetFireWall
备注:DDOS Firewall、CC Attack Defense默认是开启的。
[Firewall]->NetFireWall->DDOS Firewall[Setting]
[Firewall]->NetFireWall->CC Attack Defense[Setting]
测试Apache版网站安全狗的防护功能:
http://192.168.168.154/?order%20by
在服务器上查看Apache版网站安全狗的防护日志:
[root@centos8 ~]# sdalog
Total 2 records!
Time |Type |AttackIP |FullUrl |AttackContent |PhysicalPath
2021-02-22 16:54:01 |SQL injection |192.168.168.138 |192.168.168.154/?order%20by |防止order by函数利用,可疑内容:192.168.16.. |
2021-02-22 16:54:23 |SQL injection |192.168.168.138 |192.168.168.154/?order%20by |防止order by函数利用,可疑内容:192.168.16.. |
######
Apache版网站安全狗的上传防护配置文件:
[root@centos8 ~]# cat /etc/safedog/apache/conf/WPCDefTrojan.conf
[Trojan]
SpeSiteCount=0
WhitePathCount=0
ChkWTBrowsyFile=1
Resource=asa|asax|ascx|ashx|asmx|asp|aspx|cdx|cer|cgi|jsp|php
IgnoreFileSize=1048576
ChkForbidPostExt=1
ForbidPostExt=asa|asax|ascx|ashx|asmx|asp|aspx|cdx|cer|cgi|dll|exe|jsp|php
ChkWTPost=0
ChkHTCookie=0
ChkHTPost=0
ChkHTUrl=0
SendAlert=1
ForbidOtherRequests=1
NeedSendInterceptPage=1
假如不允许在网站上传后缀为.png的文件:
[root@centos8 ~]# cat /etc/safedog/apache/conf/WPCDefTrojan.conf
[Trojan]
SpeSiteCount=0
WhitePathCount=0
ChkWTBrowsyFile=1
Resource=asa|asax|ascx|ashx|asmx|asp|aspx|cdx|cer|cgi|jsp|php
IgnoreFileSize=1048576
ChkForbidPostExt=1
ForbidPostExt=asa|asax|ascx|ashx|asmx|asp|aspx|cdx|cer|cgi|dll|exe|jsp|php|png
ChkWTPost=0
ChkHTCookie=0
ChkHTPost=0
ChkHTUrl=0
SendAlert=1
ForbidOtherRequests=1
NeedSendInterceptPage=1
重启安全狗:
[root@centos8 ~]# service safedog restart
测试:
在discuz!上传后缀为.png的文件:(本来是可以的)
备注:实验中,后缀为.png的文件无法上传,但不影响其他类型的文件上传。
在服务器上查看Apache版网站安全狗的防护日志:
[root@centos8 ~]# sdalog
Total 3 records!
Time |Type |AttackIP |FullUrl |AttackContent |PhysicalPath
2021-02-22 16:54:01 |SQL injection |192.168.168.138 |192.168.168.154/?order%20by |防止order by函数利用,可疑内容:192.168.16.. |
2021-02-22 16:54:23 |SQL injection |192.168.168.138 |192.168.168.154/?order%20by |防止order by函数利用,可疑内容:192.168.16.. |
2021-02-22 17:39:25 |upload forbit |192.168.168.138 |192.168.168.154/discuz/misc.php?mod=sw.. |禁止上传特定类型文件:图片12.png
笺注:CentOS8也可以加入安全狗的服云,可参考:CentOS6安装服务器安全狗、Apache版网站安全狗
#################################
#################################
亲,学习研究也要劳逸结合哦,来我微店逛逛,买点东西好好犒劳犒劳自己和家人吧^_^^_^
苏泊尔电压力锅家用智能5L高压饭煲特价
苏泊尔电磁炉火锅家用智能正品学生电池炉灶特价炒菜
苏泊尔电蒸锅多功能家用蒸气锅三层大容量电蒸笼蒸锅蒸菜自动断电
|