Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Shell script to realize automatic alarm of illegal IP login

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use Shell script to achieve illegal IP login automatic alarm", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Shell script to achieve illegal IP login automatic alarm" bar!

The code is as follows:

#! / bin/bash

# this script is used to detect whether a malicious IP has logged in to the server and send an email alarm

# can be combined with 139 mailbox to achieve the function of timely notification of SMS to mobile phone.

# applicable system 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]

Then

Exit

Else

For logip in $hackerip

Do

Echo "hacker ip is $logip already login $serverip" | mail-s "SOS" rocdk890@139.com

Done

Fi

Thank you for your reading, the above is "how to use Shell script to achieve illegal IP login automatic alarm" content, after the study of this article, I believe you on how to use Shell script to achieve illegal IP login automatic alarm this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report