標籤:int 郵件警示 config ifconf 服務 漏洞 作用 com ifconfig
伺服器的安全穩定是每個營運都希望達到的目標,畢竟網站一旦流量大了,訪問高了,就會有一些無聊人來攻擊,幫忙檢測漏洞是好,但純ddos的性質就很惡劣了.說遠了,這篇文章只是檢測有非法ip登入到伺服器上就自動給營運警示,當然也可以改成簡訊警示,前提是你有簡訊網關.
#!/bin/bash#該指令碼作用是檢測是否有惡意IP登陸伺服器並郵件警示#可以結合139郵箱以達到簡訊及時通知到手機的功能#適用系統centos5
Ldate=`which date`Lawk=`which awk`Llast=`which last`Lgrep=`which grep`Lsendmail=`which sendmail`Lifconfig=`which ifconfig`serverip=`$Lifconfig eth0|$Lgrep inet|$Lawk -F : ‘{print $2}‘|$Lawk ‘{print $1}‘`cutdate=`$Ldate |$Lawk ‘{print $1" "$2" "$3}‘` hackerip=`$Llast|$Lgrep "$cutdate"|$Lawk ‘{print $3}‘|$Lgrep -v 192.168.1x.xx` if [ -z $hackerip ]thenexitelse for logip in $hackeripdoecho "hacker ip is $logip already login $serverip"|mail -s "SOS" [email protected]139.com donefi
轉自
Shell指令碼實現非法IP登陸自動警示 - Lai18.com IT技術文章收藏夾
http://www.lai18.com/content/386124.html
Shell指令碼實現非法IP登陸自動警示【轉】