-
Notifications
You must be signed in to change notification settings - Fork 3
/
mailcop-mailer
executable file
·66 lines (39 loc) · 2.18 KB
/
mailcop-mailer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
PATH=/bin/:/usr/bin/:/usr/local/scripts/mail
mailcop > /tmp/mailcop-static
debut=$(awk 'NR==1 {printf "%s %s %s\n",$1,$2,$3}' < /tmp/mailcop-static)
fin=$(awk 'END{printf "%s %s %s\n",$1,$2,$3}' < /tmp/mailcop-static)
figlet -f small mailcop > /tmp/mailcop-stats
# echo -e "Mailcop" > /tmp/mailcop-stats
# echo -e "=======" >> /tmp/mailcop-stats
echo >> /tmp/mailcop-stats
echo -e "Statistiques des dernières attaques sur notre serveur de messagerie" >> /tmp/mailcop-stats
echo -e "Début : $debut" >> /tmp/mailcop-stats
echo -e "Fin : $fin" >> /tmp/mailcop-stats
echo -e "Nombre d'attaques : $(wc -l /tmp/mailcop-static | awk '{print $1}')" >> /tmp/mailcop-stats
echo -e "\n" >> /tmp/mailcop-stats
echo -e "Top 10 des pays" >> /tmp/mailcop-stats
echo -e "---------------" >> /tmp/mailcop-stats
mailcop-countries | sort -rn | head >> /tmp/mailcop-stats
echo -e "\n\n" >> /tmp/mailcop-stats
echo -e "Top 10 des addresses IP" >> /tmp/mailcop-stats
echo -e "-----------------------" >> /tmp/mailcop-stats
mailcop-ips | sort -k 2 -r -n | head | awk '{printf "%-16s %3d %s %s %s %s\n",$1,$2,$3,$4,$5,$6}' >> /tmp/mailcop-stats
echo -e "\n\n" >> /tmp/mailcop-stats
echo -e "Top 10 des logins utilisés" >> /tmp/mailcop-stats
echo -e "--------------------------" >> /tmp/mailcop-stats
mailcop-logins | sort -nr | head >> /tmp/mailcop-stats
echo -e "\n\n" >> /tmp/mailcop-stats
echo -e "Dernières attaques" >> /tmp/mailcop-stats
echo -e "------------------" >> /tmp/mailcop-stats
tail /tmp/mailcop-static >> /tmp/mailcop-stats
echo -e "\n\n" >> /tmp/mailcop-stats
echo -e "Les 10 dernières addresses bloquées" >> /tmp/mailcop-stats
echo -e "-----------------------------------" >> /tmp/mailcop-stats
# ychaouche
# je met shorewall au lieu de fail2ban parce que dès fois je banni des addresses manuellement
# donc comme ça on vois tout.
/sbin/shorewall show dynamic | sed -n '6p' >> /tmp/mailcop-stats
/sbin/shorewall show dynamic | tail -10 >> /tmp/mailcop-stats
mailx -s "Mailcop statistics" [email protected] [email protected] < /tmp/mailcop-stats
#mailx -s "Mailcop statistics" [email protected] < /tmp/mailcop-stats