Alright all. (greets for the week). I have a question on sanitizing...
I have the following script looking at /var/log/secure (sometimes /var/log/authlog)
awk '!/invalid user/&&!/#/&& /\./&& !a[$0]++
{print "iptables -A INPUT -s "$13" -i eth0 -d eth0 -p TCP --dport 22 -j REJECT"}' /var/log/secure |\
awk '/iptables/ && !/#/ && !/-s -i/'|\
grep -E '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}'|sh
It looks for an offending address, then creates an iptables rule from the 13th column of the file. I'd like to be able to somehow get my grep -E '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}' to check the output of the 13th column in awk and SOLELY parse out IP addresses. Any thoughts?
perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
I have the following script looking at /var/log/secure (sometimes /var/log/authlog)
awk '!/invalid user/&&!/#/&& /\./&& !a[$0]++
{print "iptables -A INPUT -s "$13" -i eth0 -d eth0 -p TCP --dport 22 -j REJECT"}' /var/log/secure |\
awk '/iptables/ && !/#/ && !/-s -i/'|\
grep -E '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}'|sh
It looks for an offending address, then creates an iptables rule from the 13th column of the file. I'd like to be able to somehow get my grep -E '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}' to check the output of the 13th column in awk and SOLELY parse out IP addresses. Any thoughts?
perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'