Skip to content

Commit 48e43c6

Browse files
authored
main bash script for parsing secure logs
first version pulls ASN info via whois by parsing secure logs, gather failed login attempts, putting the worst offenders at the top, and logging their ISP. DEPS: get_fails.sh
1 parent f947f2f commit 48e43c6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

secure_log_whois_parser.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
2 #
3+
3 #
4+
4 INFILE=/root/failed_login_ips.txt
5+
5 #
6+
6 GETFAILS=/root/get_fails.sh
7+
7 #
8+
8 /bin/bash $GETFAILS
9+
9 #
10+
10 while read line
11+
11 do
12+
12 HOST="$(echo $line | awk '{print$2}')"
13+
13 REGEX='([A-Za-z]+\d*).*'
14+
14 OUTFILE=/root/resolved_hosts.txt
15+
15 if [[ $HOST =~ $REGEX ]]
16+
16 then
17+
17 # echo "its a hostname"
18+
18 echo $(echo $line | awk '{print$1}')" failed logins from "
19+
19 echo $line | awk '{print$2}' >> $OUTFILE
20+
20 dig $(echo $line | awk '{print$2}') | grep -A 1 -i answer | grep -i "IN A" | awk '{print$5}' >> $OUTFILE
21+
21 tail -n 2 $OUTFILE
22+
22
23+
23 else
24+
24 # echo "its an ip"
25+
25 echo $(echo $line | awk '{print$1}')" failed logins from "
26+
26 whois $(echo $line | awk '{print$2}') | grep -i netname
27+
27
28+
28 fi
29+
29 sleep 1
30+
30 done < $INFILE

0 commit comments

Comments
 (0)