The security and stability of the server is the goal that every operation and maintenance want to achieve, after all, once the website traffic is big, access is high, there will be some boring people to attack, to help detect the vulnerability is good, but the nature of pure DDoS is very bad. Said far, this article only detects that there is an illegal IP login to the server automatically to the Of course, it can be changed to SMS alarm, if you have a message gateway.
#!/bin/bash# This script function is to detect whether there is a malicious IP login server and mail alarm # can be combined with 139 of mailboxes to achieve SMS timely notification to the function of mobile phone # applicable system centos5
Ldate= 'which Date' Lawk=`which awk' Llast=`which Last' Lgrep=`which grep' Lsendmail=`whichSendMail ' Lifconfig=`which ifconfig' ServerIP= ' $Lifconfig eth0| $Lgrep inet| $Lawk-F:'{print $}'| $Lawk'{print $}'' Cutdate= ' $Ldate | $Lawk'{print $ "" $ "" $ $} "'' Hackerip= ' $Llast | $Lgrep"$cutdate"| $Lawk'{print $}'| $Lgrep-V192.168. 1x.xx 'if[ -Z $hackerip] ThenExitElse forLogipinch$hackerip DoEcho "Hacker IP is $LOGIP already login $serverip"|mail-s"SOS"[Email protected]139. com Donefi
Turn from
Shell script implementation Illegal IP login automatic alarm-lai18.com IT technology articles favorites
Http://www.lai18.com/content/386124.html
Shell script implementation of illegal IP landing automatic alarm "turn"