diff -urN smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip smeserver-xt_geoip-1.3.1/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip --- smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip 2022-07-10 12:00:06.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/xt_geoip 2022-07-11 17:57:53.190000000 +0400 @@ -115,6 +115,16 @@ + F2B_LIST_DESCRIPTION +
  • Click here to see the statistics of the connections banned by fail2ban
  • ]]> +
    +
    + + F2B_LIST + F2B banned + + + STATS_GENERATED Statistics generated @@ -135,6 +145,7 @@
  • For 3 periods : Day, Week and Month
  • Banned Ips by country sorted by number
  • Ssh errors by country sorted by number
  • +
  • Fail2ban banned IPs by country sorted by number
  • XX means Country not found !

    ]]> diff -urN smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/templates/etc/crontab/xt_geoip smeserver-xt_geoip-1.3.1/root/etc/e-smith/templates/etc/crontab/xt_geoip --- smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/templates/etc/crontab/xt_geoip 2020-06-07 23:12:41.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/etc/e-smith/templates/etc/crontab/xt_geoip 2022-07-10 23:06:42.047000000 +0400 @@ -4,10 +4,10 @@ $OUT .= " # saturday at 06:00 update xtables geoip base 00 06 * * 6 root /usr/share/xt_geoip/update_base $output +45 1 * * * root /usr/share/xt_geoip/geoip_stats f2b $output 50 1 * * * root /usr/share/xt_geoip/geoip_stats ssh $output 55 1 * * * root /usr/share/xt_geoip/geoip_stats ipt $output 05 2 * * * root /usr/share/xt_geoip/geoip_listat $output # "; } - diff -urN smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/web/functions/xt_geoip smeserver-xt_geoip-1.3.1/root/etc/e-smith/web/functions/xt_geoip --- smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/web/functions/xt_geoip 2022-07-10 12:00:06.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/etc/e-smith/web/functions/xt_geoip 2022-07-11 17:59:30.311000000 +0400 @@ -143,6 +143,11 @@ + + F2B_LIST_DESCRIPTION + + + diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm smeserver-xt_geoip-1.3.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm --- smeserver-xt_geoip-1.3.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2022-07-10 12:00:06.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2022-07-11 18:01:52.568000000 +0400 @@ -306,7 +306,7 @@ # Untaint $name before use in system() my $stats_type = $q->param ('type'); $stats_type =~ /(.+)/; $stats_type = $1; - if ($stats_type ne "ipt" && $stats_type ne "ssh") + if ($stats_type ne "ipt" && $stats_type ne "ssh" && $stats_type ne "f2b") { print $q->p($q->b($self->localise('INVALID_STATS_TYPE')." ". $stats_type)); diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/smanager/lib/SrvMngr/Controller/Xt_geoip.pm smeserver-xt_geoip-1.3.1/root/usr/share/smanager/lib/SrvMngr/Controller/Xt_geoip.pm --- smeserver-xt_geoip-1.3.1.old/root/usr/share/smanager/lib/SrvMngr/Controller/Xt_geoip.pm 2022-07-10 12:00:06.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/smanager/lib/SrvMngr/Controller/Xt_geoip.pm 2022-07-11 20:42:53.626000000 +0400 @@ -62,6 +62,15 @@ # return $c->render('xt_geoip_lst'); }; + if ( $choice eq 'LF2B' ) { + + $result = $c->generateStats( 'f2b' ); +# $result = $c->render_to_string(inline => generateStats($c, 'f2b')); + +# $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas ); +# return $c->render('xt_geoip_lst'); + }; + if ( $choice eq 'LSSH' ) { $result = $c->generateStats( 'ssh' ); @@ -107,7 +116,7 @@ $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas ); - return $c->render( 'xt_geoip_lst' ) if ( $choice ~~ [ 'LCOD', 'LSSH', 'LIPT' ] ); + return $c->render( 'xt_geoip_lst' ) if ( $choice ~~ [ 'LCOD', 'LF2B', 'LSSH', 'LIPT' ] ); return $c->render( 'xt_geoip'.'_'.lc($choice) ) if ( $choice ~~ [ 'UPDT', 'UPDS', 'REMS', 'LSRV' ] ); @@ -324,7 +333,7 @@ # Untaint $name before use in system() $stats_type =~ /(.+)/; $stats_type = $1; - if ($stats_type ne "ipt" and $stats_type ne "ssh") { + if ($stats_type ne "ipt" and $stats_type ne "ssh" and $stats_type ne "f2b") { $out .= sprintf("

    %s %s

    ", $c->l('xtg_INVALID_STATS_TYPE'), $stats_type); return $out; } diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Xt_geoip/xt_geoip_en.lex smeserver-xt_geoip-1.3.1/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Xt_geoip/xt_geoip_en.lex --- smeserver-xt_geoip-1.3.1.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Xt_geoip/xt_geoip_en.lex 2020-07-30 22:04:46.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Xt_geoip/xt_geoip_en.lex 2022-07-11 17:49:17.335000000 +0400 @@ -22,6 +22,8 @@ 'xtg_IPT_LIST' => 'Filtered', 'xtg_SSH_LIST_DESCRIPTION' => ' ', 'xtg_SSH_LIST' => 'SSH errors', +'xtg_F2B_LIST_DESCRIPTION' => ' ', +'xtg_F2B_LIST' => 'F2b banned', 'xtg_STATS_GENERATED' => 'Statistics generated', 'xtg_END_OF_STATS' => 'End of Statistics', 'xtg_INVALID_STATS_TYPE' => 'Invalid type of statistics', @@ -29,6 +31,7 @@
  • For 3 periods : Day, Week and Month
  • Banned Ips by country sorted by number
  • Ssh errors by country sorted by number
  • +
  • Fail2ban banned IPs by country sorted by number
  • XX means Country not found !

    ', 'xtg_COUNTRY_LIST_DESCRIPTION' => ' ', 'xtg_LABEL_COUNTRY_LIST' => 'Country codes : ', diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/smanager/themes/default/templates/partials/_xtg_stats.html.ep smeserver-xt_geoip-1.3.1/root/usr/share/smanager/themes/default/templates/partials/_xtg_stats.html.ep --- smeserver-xt_geoip-1.3.1.old/root/usr/share/smanager/themes/default/templates/partials/_xtg_stats.html.ep 2020-07-24 23:40:43.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/smanager/themes/default/templates/partials/_xtg_stats.html.ep 2022-07-11 17:42:54.950000000 +0400 @@ -21,4 +21,13 @@ % end + %= form_for '/xt_geoip' => (method => 'POST') => begin + + %= $c->render_to_string(inline => l('xtg_F2B_LIST_DESCRIPTION')); + + %= submit_button l 'xtg_F2B_LIST', class => 'action' + %= hidden_field 'Choice' => 'LF2B' + + % end + diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_exstat smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_exstat --- smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_exstat 2020-06-07 23:12:41.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_exstat 2022-07-11 20:13:25.962000000 +0400 @@ -15,8 +15,12 @@ PREF="ipt" TITLE=" Numbers of IPs banned (xt_geoip) by country" ;; + "f2b") + PREF="f2b" + TITLE=" Numbers of IPs banned (fail2ban) by country" + ;; *) - echo "usage : $0 'ssh|ipt' [D|W|M]" + echo "usage : $0 'ssh|ipt|f2b' [D|W|M]" exit 1 ;; esac diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_listat smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_listat --- smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_listat 2020-06-07 23:12:41.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_listat 2022-07-11 17:32:55.054000000 +0400 @@ -3,7 +3,7 @@ EXECDIR="/usr/share/xt_geoip" STATDIR="/var/lib/xt_geoip" -for pref in $(echo 'ipt ssh') +for pref in $(echo 'ipt ssh f2b') do echo "" > ${STATDIR}/extA_${pref}_country.lst for period in $(echo 'D W M') diff -urN smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_stats smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_stats --- smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_stats 2022-07-10 12:05:34.000000000 +0400 +++ smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_stats 2022-07-11 17:31:41.471000000 +0400 @@ -21,8 +21,22 @@ CMD2=' | grep -i ' CMD3=' | grep "GeoIP BAN" | sed -e "s/^.*SRC=//" -e "s/ DST=.*$//" >> $RESFILE' ;; + "f2b") + if [[ -x /bin/fail2ban-client && -f /var/log/fail2ban/daemon.log ]] + then + PREF="f2b" + LOGDIR="/var/log/fail2ban" + CMD1='zcat -f ' + CMD2=' | grep -i ' + CMD3=' | grep -E "] Ban " | sed -e "s/^.* Ban //" >> $RESFILE' + # CMD3=' | grep -E ": NOTICE [.*] Ban" | sed -e "s/^.* Ban //" >> $RESFILE' + else + echo "No fail2ban enabled here" + exit 1 + fi + ;; *) - echo "usage : $0 [ssh|ipt|....]" + echo "usage : $0 [ssh|ipt|f2b|....]" exit 1 ;; esac @@ -43,6 +57,7 @@ LOGDAY="$(LC_ALL=C date --date '1 day ago' '+%h %e')" DATE=$(date --date '1 day ago' '+%Y-%m-%d') ARCHDATE=$(date --date '90 day ago' '+%Y-%m-%d') +[[ $PREF = 'f2b' ]] && LOGDAY=$DATE cd $EXECDIR