From 5ef0de5b85f69aa3ebed61fa74d14d263f76efe5 Mon Sep 17 00:00:00 2001 From: aixiao Date: Fri, 8 Jul 2022 09:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=09=E4=BF=AE=E6=94=B9=EF=BC=9A=20=20=20=20=20RE?= =?UTF-8?q?ADME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++------ rhost.c | 5 +++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f6a0071..06132c0 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,53 @@ # denyhosts -ssh防止暴力破解,适用Debian 8、9 -支持钉钉告警和邮件告警 -支持第三方QQ邮箱告警 -支持一次运行检测、后台运行检测 -请安装libcurl库 +ssh防止暴力破解,适用Debian 8、9、11 Centos 7 +支持钉钉告警和邮件告警 +支持第三方QQ邮箱告警 +支持一次运行检测、后台运行检测 +请安装libcurl库和libiptc库 +``` cd /root -git clone https://github.com/niuyuling/denyhosts.git +git clone https://git.aixiao.me/aixiao/denyhosts cd denyhosts make clean; make chmod a+x /root/denyhosts/denyhosts.sh crontab 定时任务,像这样. 0 22 * * * /root/denyhosts/denyhosts.sh +``` + + +``` +使用libiptc库需要nftables切换到iptables +Switching to the legacy version:(切换到 iptables) + +update-alternatives --set iptables /usr/sbin/iptables-legacy +update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy +update-alternatives --set arptables /usr/sbin/arptables-legacy +update-alternatives --set ebtables /usr/sbin/ebtables-legacy +``` + +``` +配置文件 +global { + DAEMON = "off"; // on开启后台运行,off不开启 + TIME = "60"; // 睡眠时间(单位秒,大于等于1) + + REFUSE_NUMBER = 5; // 拒绝攻击次数(大于等于1) + + IS_MAIL = 0; // 开启邮件告警(0关闭,1开启) + + IS_DING_WEBHOOK = 1; // 开启叮叮告警(0关闭,1开启) + PHONE = "15565979082"; // @的人手机号 + DING_WEBHOOK = "https://oapi.dingtalk.com/robot/send?access_token=7f069c672cb878987aa6772cca336740eece4ce36bde12b51b45e9f440e0565a"; // 钉钉WEBHOOK + + IS_QQMAIL = 0; // 开启QQ邮箱告警(0关闭,1开启) + SEND_QQ = "1605227279"; // 发送者QQ + QQMAIL_KEY = "caczsjchvyibiabe"; // 发送者QQ密钥 + RECV_MAIL = "1605227279"; // 接收者QQ +} +``` \ No newline at end of file diff --git a/rhost.c b/rhost.c index 7c510ae..a864074 100644 --- a/rhost.c +++ b/rhost.c @@ -263,8 +263,8 @@ int rule(conf *conf) sprintf(iptables, IPTABLES, buffer); sprintf(iptables_check, IPTABLES_CHECK, buffer); - //if (0 != system(iptables_check)) // 判断是否存在规则, 不存在时再添加规则 - if (0 != show_all_rule(buffer)) + //if (0 != system(iptables_check)) // 调用iptables命令判断是否存在规则, 不存在时再添加规则 + if (0 != show_all_rule(buffer)) // libiptc库判断 { if (conf->IS_DING_WEBHOOK == 1) // 钉钉告警 { @@ -285,6 +285,7 @@ int rule(conf *conf) } /* + // 调用命令下发规则 if ((fc = popen(iptables, "r")) == NULL) { perror("popen iptables"); return 1;