标签:攻击 off end bash ESS cas 取出 pts opp
[root@centos7 scripts]# cat selinux.sh
#!/bin/bash
. /etc/init.d/functions
STATUS=`getenforce`
start(){
[ $STATUS != Disabled ] && { setenforce 1;echo "Selinux is already started";return 10; }
sed -i ‘s/SELINUX=disabled/SELINUX=enforcing/‘ /etc/selinux/config
action "starting selinux ..."
echo "You need to restart the system for the changes to take effect."
}
stop(){
[ $STATUS = Disabled ] && { echo "Selinux is already stopped";return 20; }
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config
action "stopping selinux ..."
echo "You need to restart the system for the changes to take effect."
echo "You can also use ‘setenforce 0‘ to turn off selinux temporarily"
}
status(){
getenforce
}
case $* in
start)
start
;;
stop)
stop
;;
status)
status
;;
*)
echo "Usage:$0 {start|stop|status}"
exit 100
;;
esac
# 执行结果
[root@centos7 scripts]# ./selinux.sh status
Disabled
[root@centos7 scripts]# ./selinux.sh start
starting selinux ... [ OK ]
You need to restart the system for the changes to take effect.
[root@centos7 scripts]# ./selinux.sh stop
Selinux is already stopped
[root@centos7 scripts]#./selinux.sh status
Enforcing
[root@centos7 scripts]#./selinux.sh stop
stopping selinux ... [ OK ]
You need to restart the system for the changes to take effect.
You can also use ‘setenforce 0‘ to turn off selinux temporarily
[root@centos7 ~]# awk ‘/^[^# ]/{fsys[$3]++}END{for(n in fsys)print n,fsys[n]}‘ /etc/fstab
swap 1
ext4 1
xfs 3
[root@centos7 ~]# echo "Yd$C@M05MB%9&Bdh7dq+YVixp3vpw" | awk -F "" ‘{for(n=1;n<=NF;n++){if($n ~ /[0-9]/)print $n}}‘
0
5
9
7
3
[root@centos7 ~]# echo "Yd$C@M05MB%9&Bdh7dq+YVixp3vpw" | tr -dc "[0-9]"
05973[root@centos7 ~]#
[root@centos7 ~]# crontab -l
*/5 * * * * /usr/bin/awk ‘{IP[$1]++}END{for(n in IP){if(IP[n]>100)system("/usr/sbin/iptables -A INPUT -s " n " -j REJECT")}}‘ /var/log/httpd/access_log
标签:攻击 off end bash ESS cas 取出 pts opp
原文地址:https://www.cnblogs.com/kfscott/p/13205075.html