Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raphaunix/4318212b9c74019e1276ffbed5da26c8 to your computer and use it in GitHub Desktop.
Save raphaunix/4318212b9c74019e1276ffbed5da26c8 to your computer and use it in GitHub Desktop.
Parsing log
Checking the number of login attempts coming from an ip:
debian/ubuntu:
cat /var/log/auth.log | grep -o '[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}' | cut -d " " -f 1 | sort | uniq -c | sort -unr
rhel/centos:
cat /var/log/secure | grep -o '[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}' | cut -d " " -f 1 | sort | uniq -c | sort -unr
Dropping ip attacker with iptables:
iptables -I INPUT -s IPATTACKER -j DROP && service iptables restart && clear; iptables -L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment