-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.sh
35 lines (32 loc) · 861 Bytes
/
parser.sh
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
#!/bin/bash
## join
## version 0.0.2 - fix recursion parameters
##################################################
yn(){
while true; do
read -p "Blocked ip adress?" yn
case $yn in
[Yy]* ) fail2ban-client set css banip $ip2; iptables -A f2b-css -s $ip2 -j REJECT; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
}
join(){
local ak
local ak1
local ak2
local ak3
read ak ak1 ak2 ak3 || return
ip=$(tcpdump -nr badips.log |awk '{print $3}' |grep -oE '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' |sort |uniq -c |sort -r |grep $ak |grep $ak1 |grep $ak2 |grep $ak3)
ip2=$(echo $ip | sort -r | uniq | while read N; do echo $N |cut -c 2-; done)
if [ -z $ip2 ] && [ -n $ip2 ];then
echo "not found ip adress data bases"
return 0
else
echo "baned ip yes/no"
echo "$ip2"
yn [$ip2]
fi
}
join