Skip to content

Instantly share code, notes, and snippets.

@scriptzteam
Forked from flowolf/fail2ban_ctry_stats.sh
Created October 13, 2016 20:56
Show Gist options
  • Select an option

  • Save scriptzteam/7894864725c9dbc3ac7f613ba57aa31d to your computer and use it in GitHub Desktop.

Select an option

Save scriptzteam/7894864725c9dbc3ac7f613ba57aa31d to your computer and use it in GitHub Desktop.

Revisions

  1. @flowolf flowolf revised this gist Jan 6, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fail2ban_ctry_stats.sh
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,4 @@ for i in `sudo cat /var/log/fail2ban.log | sed 's/.*[Bb]an \(.*\)/\1/' | sort |
    do
    echo $i; whois $i | grep country\: |head -n 1 >> fail2ban_ctry.log ;
    done
    cat fail2ban_ctry.log fail2bancry2.log | sed 's/country: //g' |sort | uniq -c | sort -nr
    cat fail2ban_ctry.log | sed 's/country: //g' |sort | uniq -c | sort -nr
  2. @flowolf flowolf renamed this gist Sep 11, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @flowolf flowolf revised this gist Sep 11, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fail2ban_ctry_stats
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,4 @@ for i in `sudo cat /var/log/fail2ban.log | sed 's/.*[Bb]an \(.*\)/\1/' | sort |
    do
    echo $i; whois $i | grep country\: |head -n 1 >> fail2ban_ctry.log ;
    done
    cat fail2ban_ctry.log fail2bancry2.log | sed 's/country: //g' |sort | uniq -c
    cat fail2ban_ctry.log fail2bancry2.log | sed 's/country: //g' |sort | uniq -c | sort -nr
  4. @flowolf flowolf created this gist Sep 11, 2014.
    9 changes: 9 additions & 0 deletions fail2ban_ctry_stats
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/bash
    # get a country statistic for Fail2Ban blocks:
    # this just accounts for IPs once. Multiple failed attempts by one IP just show up once for a country.

    for i in `sudo cat /var/log/fail2ban.log | sed 's/.*[Bb]an \(.*\)/\1/' | sort | uniq | cut -d ' ' -f 1 | grep "\."`;
    do
    echo $i; whois $i | grep country\: |head -n 1 >> fail2ban_ctry.log ;
    done
    cat fail2ban_ctry.log fail2bancry2.log | sed 's/country: //g' |sort | uniq -c