什么是暴力破解,简单来说就是对一个服务器进行无数次尝试登陆,并用不同的密码进行登陆直到可以登陆成功。暴力破解的基本步骤可以分为以下几步:文章源自小柒网-https://www.i7ti.cn/1210.html
1)找到对应的Linux服务器ip地址文章源自小柒网-https://www.i7ti.cn/1210.html
2)扫描端口号:22 nmap扫描端口文章源自小柒网-https://www.i7ti.cn/1210.html
3)开始暴力破解 :一般破解你的root 密码,登录你的服务器,进行破坏、盗取你的重要的数据。文章源自小柒网-https://www.i7ti.cn/1210.html
此脚本是Centos7.X防SSH暴力破解脚本,有需要朋友可以参考,脚本内容如下:
文章源自小柒网-https://www.i7ti.cn/1210.html
系统环境:CentOS 7.9文章源自小柒网-https://www.i7ti.cn/1210.html
[root@localhost ~]# vim auto_deny_ip_login.sh文章源自小柒网-https://www.i7ti.cn/1210.html
# 脚本内容如下文章源自小柒网-https://www.i7ti.cn/1210.html
#!/bin/bash #Date:2021-5-30 16:08:46 #Author Blog: # https://www.yangxingzhen.com # https://www.i7ti.cn #Author WeChat: # 微信公众号:小柒博客 #Author mirrors site: # https://mirrors.yangxingzhen.com #About the Author # BY:YangXingZhen # Mail:xingzhen.yang@yangxingzhen.com # QQ:675583110 #自动检测IP暴力破解,禁止IP登录SSHD服务 Secure_File="/var/log/secure" Deny_File="/etc/firewalld/zones/public.xml" Start_Time=$(date +%Y%m%d%H%M) IP_List="/tmp/firewalld.txt" # 匹配IP次数 IPADDR=$(grep -i "failed" /var/log/secure |egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" |sort -nr |uniq -c|awk '$1>=5 {print $2}') [ -f ${IP_List} ] || touch ${IP_List} for i in $(echo -n ${IPADDR}) do # IP失败次数达到5就加入防火墙Firewalld禁止登录ssh服务两个小时 grep -wq ${i} ${IP_List} if [ $? -ne 0 ];then firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source address="${i}" service name='ssh' drop" --permanent firewall-cmd --reload echo "${i} #${Start_Time}" >>${IP_List} else # 查询IP封停时间,大于等于两小时就删除此IP End_Time=$(date +%Y%m%d%H%M) IP_ADDR=$(egrep -v "^$|^#" ${IP_List} |awk -F'#' '{print $1,$2}' |awk '{if('${End_Time}'>=$2+200) print $1}') for j in $(echo -n ${IP_ADDR}) do if [ ! -z ${j} ];then firewall-cmd --permanent --remove-rich-rule="rule family=ipv4 source address="${IP_ADDR}" service name='ssh' drop" firewall-cmd --reload sed -i "/${IP_ADDR}/d" ${IP_List} fi done fi done
# 保存脚本文件到把脚本/data/scripts/文章源自小柒网-https://www.i7ti.cn/1210.html
1、添加定时任务执行文章源自小柒网-https://www.i7ti.cn/1210.html
[root@localhost ~]# crontab -e文章源自小柒网-https://www.i7ti.cn/1210.html
*/1 * * * * sh /data/scripts/auto_deny_ip_login.sh文章源自小柒网-https://www.i7ti.cn/1210.html
- 微信号
- 微信扫一扫加我!
-
- 微信公众号
- 微信扫一扫关注我!
-
评论