server_login_detection/run.py
2024-06-30 17:10:11 +08:00

37 lines
857 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# !/usr/bin/env python
# -*-coding:utf-8 -*-
"""
# File : run.py.py
# Time 2024/6/30 上午 12:23
# Modify sityliu
# Author :蓝陌
# version python 3.8
# Description服务器登录检测当检测到登录行为时自动发送钉钉消息
"""
import os
from src.message_sed import MessageSedes
sed = MessageSedes()
def monitoring_login_behavior():
login_num = 0
while True:
if login_num == 0:
print('开始监控登录行为......')
os.popen('inotifywait -e modify /var/log/wtmp > /dev/null').readlines()
sed.run()
login_num += 1
os.popen('inotifywait -e modify /var/log/wtmp > /dev/null').readlines()
login_num = 0
if __name__ == '__main__':
# sed.run()
monitoring_login_behavior()