
| Current Path : /var/mail/etc/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/mail/etc/blocked.py |
import os,re,sys
x = {}
y = {}
text = open("blocked.sh").read()
for zeile in os.popen("grep 'does not resolve' /var/log/mail.log"):
m = re.search(r"does not resolve.*?(\d+\.\d+\.\d+\.\d+)",zeile)
if m and not m.group(1) in text:
x['iptables -A INPUT -s ' + m.group(1) + ' -j DROP'] = 1
for zeile in os.popen("grep 'Wrong password' /var/log/asterisk/messages"):
# print(zeile)
m = re.search(r"failed.*for.*(\d+\.\d+\.\d+\.\d+).*Wrong",zeile)
if m and not m.group(1) in text:
o = 'iptables -A INPUT -s ' + m.group(1) + ' -j DROP'
if not o in y:
y[o] = 0
y[o] = y[o] + 1
for zeile in x.keys():
print(zeile)
print("")
for o in y:
if y[o] > 100:
print(o)