Giter Site home page Giter Site logo

yeqizhang / deny-ssh-password-attack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vimers01/deny-ssh-password-attack

0.0 1.0 0.0 20 KB

Openwrt 自身没有对抗ssh破解的工具,为了暴露在互联网的路由器更加安全,基于iptables编写了一个小脚本, 脚本通过crontab定时执行,

Shell 100.00%

deny-ssh-password-attack's Introduction

deny-ssh-password-attack

Openwrt 自身没有对抗ssh破解的工具,为了使我们暴露在互联网的路由器更加安全,基于iptables编写了一个小脚本, 脚本通过crontab定时执行.

Openwrt does not have its own tools to combat SSH cracking. To make our Internet-exposed routers more secure, a small script based on iptables is written. The script is executed by crontab timing.

脚本的功能是读取 logread 中 ssh(22端口) 和 luci (443端口) 的失败日志,对于失败次数超过10次的同一个IP,在Iptables 中增加一条封锁规则,并记录日志到 /tmp/DenyPwdHack.log .

操作步骤如下:

下载文件DenyPwdHack.sh , 以root登录,放在 /root/ 目录下, 然后执行 chmod u+x /root/DenyPwdHack.sh 在Openwrt增加以下 crontab 内容:

执行命令: crontab -e

然后贴入以下内容: 0 */3 * * * /root/DenyPwdHack.sh

每三个小时执行一次脚本.

脚本中的参数:

SSH_PORT=22 #是SSH的端口,请根据自己的实际情况填写,一般是22端口

Luci_Port=443 #是Luci的登录端口,请根据自己的实际情况填写,一般是80端口,如果采用https,一般是443端口

LOG_DEST=/tmp/DenyPwdHack.log #日志的绝对路径,因为 /tmp文件系统从内存中开辟的,写到该文件系统速度快,对芯片也安全

LOG_KEY_WORD="auth.info\s+sshd.*Failed password for|luci:\s+failed\s+login" #日志关键字,每个关键字可以用"|"号隔开,支持awk的正则表达式

exclude_ip="192.168.|127.0.0.1" #白名单IP可以用"|"号隔开,支持grep的正则表达式## 失败次数

Failed_times=10 #登录失败封锁IP的阈值

deny-ssh-password-attack's People

Contributors

vimers01 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.