1 |
michel |
1.1 |
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 |
2 |
|
|
--- 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 |
3 |
|
|
+++ 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 |
4 |
|
|
@@ -115,6 +115,16 @@ |
5 |
|
|
</entry> |
6 |
|
|
|
7 |
|
|
<entry> |
8 |
|
|
+ <base>F2B_LIST_DESCRIPTION</base> |
9 |
|
|
+ <trans><![CDATA[<ul><li>Click here to see the statistics of the connections banned by fail2ban</li></ul> ]]> |
10 |
|
|
+ </trans> |
11 |
|
|
+ </entry> |
12 |
|
|
+ <entry> |
13 |
|
|
+ <base>F2B_LIST</base> |
14 |
|
|
+ <trans>F2B banned</trans> |
15 |
|
|
+ </entry> |
16 |
|
|
+ |
17 |
|
|
+ <entry> |
18 |
|
|
<base>STATS_GENERATED</base> |
19 |
|
|
<trans>Statistics generated</trans> |
20 |
|
|
</entry> |
21 |
|
|
@@ -135,6 +145,7 @@ |
22 |
|
|
<li>For 3 periods : Day, Week and Month</li> |
23 |
|
|
<li>Banned Ips by country sorted by number</li> |
24 |
|
|
<li>Ssh errors by country sorted by number</li> |
25 |
|
|
+ <li>Fail2ban banned IPs by country sorted by number</li> |
26 |
|
|
</ul><p><i>XX means Country not found !</i></p> ]]> |
27 |
|
|
</trans> |
28 |
|
|
</entry> |
29 |
|
|
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 |
30 |
|
|
--- smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/templates/etc/crontab/xt_geoip 2020-06-07 23:12:41.000000000 +0400 |
31 |
|
|
+++ smeserver-xt_geoip-1.3.1/root/etc/e-smith/templates/etc/crontab/xt_geoip 2022-07-10 23:06:42.047000000 +0400 |
32 |
|
|
@@ -4,10 +4,10 @@ |
33 |
|
|
$OUT .= " |
34 |
|
|
# saturday at 06:00 update xtables geoip base |
35 |
|
|
00 06 * * 6 root /usr/share/xt_geoip/update_base $output |
36 |
|
|
+45 1 * * * root /usr/share/xt_geoip/geoip_stats f2b $output |
37 |
|
|
50 1 * * * root /usr/share/xt_geoip/geoip_stats ssh $output |
38 |
|
|
55 1 * * * root /usr/share/xt_geoip/geoip_stats ipt $output |
39 |
|
|
05 2 * * * root /usr/share/xt_geoip/geoip_listat $output |
40 |
|
|
# |
41 |
|
|
"; |
42 |
|
|
} |
43 |
|
|
- |
44 |
|
|
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 |
45 |
|
|
--- smeserver-xt_geoip-1.3.1.old/root/etc/e-smith/web/functions/xt_geoip 2022-07-10 12:00:06.000000000 +0400 |
46 |
|
|
+++ smeserver-xt_geoip-1.3.1/root/etc/e-smith/web/functions/xt_geoip 2022-07-11 17:59:30.311000000 +0400 |
47 |
|
|
@@ -143,6 +143,11 @@ |
48 |
|
|
</field> |
49 |
|
|
<subroutine src="print_custom_button('SSH_LIST', 'Stats', 'ssh')"/> |
50 |
|
|
|
51 |
|
|
+ <field type="literal" id="f2b_list_label" value=""> |
52 |
|
|
+ <description>F2B_LIST_DESCRIPTION</description> |
53 |
|
|
+ </field> |
54 |
|
|
+ <subroutine src="print_custom_button('F2B_LIST', 'Stats', 'f2b')"/> |
55 |
|
|
+ |
56 |
|
|
</page> |
57 |
|
|
|
58 |
|
|
|
59 |
|
|
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 |
60 |
|
|
--- 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 |
61 |
|
|
+++ 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 |
62 |
|
|
@@ -306,7 +306,7 @@ |
63 |
|
|
# Untaint $name before use in system() |
64 |
|
|
my $stats_type = $q->param ('type'); |
65 |
|
|
$stats_type =~ /(.+)/; $stats_type = $1; |
66 |
|
|
- if ($stats_type ne "ipt" && $stats_type ne "ssh") |
67 |
|
|
+ if ($stats_type ne "ipt" && $stats_type ne "ssh" && $stats_type ne "f2b") |
68 |
|
|
{ |
69 |
|
|
print $q->p($q->b($self->localise('INVALID_STATS_TYPE')." ". |
70 |
|
|
$stats_type)); |
71 |
|
|
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 |
72 |
|
|
--- 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 |
73 |
|
|
+++ smeserver-xt_geoip-1.3.1/root/usr/share/smanager/lib/SrvMngr/Controller/Xt_geoip.pm 2022-07-11 20:42:53.626000000 +0400 |
74 |
|
|
@@ -62,6 +62,15 @@ |
75 |
|
|
# return $c->render('xt_geoip_lst'); |
76 |
|
|
}; |
77 |
|
|
|
78 |
|
|
+ if ( $choice eq 'LF2B' ) { |
79 |
|
|
+ |
80 |
|
|
+ $result = $c->generateStats( 'f2b' ); |
81 |
|
|
+# $result = $c->render_to_string(inline => generateStats($c, 'f2b')); |
82 |
|
|
+ |
83 |
|
|
+# $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas ); |
84 |
|
|
+# return $c->render('xt_geoip_lst'); |
85 |
|
|
+ }; |
86 |
|
|
+ |
87 |
|
|
if ( $choice eq 'LSSH' ) { |
88 |
|
|
|
89 |
|
|
$result = $c->generateStats( 'ssh' ); |
90 |
|
|
@@ -107,7 +116,7 @@ |
91 |
|
|
|
92 |
|
|
$c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas ); |
93 |
|
|
|
94 |
|
|
- return $c->render( 'xt_geoip_lst' ) if ( $choice ~~ [ 'LCOD', 'LSSH', 'LIPT' ] ); |
95 |
|
|
+ return $c->render( 'xt_geoip_lst' ) if ( $choice ~~ [ 'LCOD', 'LF2B', 'LSSH', 'LIPT' ] ); |
96 |
|
|
|
97 |
|
|
return $c->render( 'xt_geoip'.'_'.lc($choice) ) if ( $choice ~~ [ 'UPDT', 'UPDS', 'REMS', 'LSRV' ] ); |
98 |
|
|
|
99 |
|
|
@@ -324,7 +333,7 @@ |
100 |
|
|
|
101 |
|
|
# Untaint $name before use in system() |
102 |
|
|
$stats_type =~ /(.+)/; $stats_type = $1; |
103 |
|
|
- if ($stats_type ne "ipt" and $stats_type ne "ssh") { |
104 |
|
|
+ if ($stats_type ne "ipt" and $stats_type ne "ssh" and $stats_type ne "f2b") { |
105 |
|
|
$out .= sprintf("<h3>%s %s </h3>", $c->l('xtg_INVALID_STATS_TYPE'), $stats_type); |
106 |
|
|
return $out; |
107 |
|
|
} |
108 |
|
|
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 |
109 |
|
|
--- 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 |
110 |
|
|
+++ 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 |
111 |
|
|
@@ -22,6 +22,8 @@ |
112 |
|
|
'xtg_IPT_LIST' => 'Filtered', |
113 |
|
|
'xtg_SSH_LIST_DESCRIPTION' => '<ul><li>Click here to see the statistics of SSH errors for non blocked access</li></ul> ', |
114 |
|
|
'xtg_SSH_LIST' => 'SSH errors', |
115 |
|
|
+'xtg_F2B_LIST_DESCRIPTION' => '<ul><li>Click here to see the statistics of the connections banned by fail2ban</li></ul> ', |
116 |
|
|
+'xtg_F2B_LIST' => 'F2b banned', |
117 |
|
|
'xtg_STATS_GENERATED' => 'Statistics generated', |
118 |
|
|
'xtg_END_OF_STATS' => 'End of Statistics', |
119 |
|
|
'xtg_INVALID_STATS_TYPE' => 'Invalid type of statistics', |
120 |
|
|
@@ -29,6 +31,7 @@ |
121 |
|
|
<li>For 3 periods : Day, Week and Month</li> |
122 |
|
|
<li>Banned Ips by country sorted by number</li> |
123 |
|
|
<li>Ssh errors by country sorted by number</li> |
124 |
|
|
+<li>Fail2ban banned IPs by country sorted by number</li> |
125 |
|
|
</ul><p><i>XX means Country not found !</i></p> ', |
126 |
|
|
'xtg_COUNTRY_LIST_DESCRIPTION' => '<ul><li>Click here to see a <b>list of available country codes</b></li></ul> ', |
127 |
|
|
'xtg_LABEL_COUNTRY_LIST' => 'Country codes : ', |
128 |
|
|
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 |
129 |
|
|
--- 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 |
130 |
|
|
+++ 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 |
131 |
|
|
@@ -21,4 +21,13 @@ |
132 |
|
|
|
133 |
|
|
% end |
134 |
|
|
|
135 |
|
|
+ %= form_for '/xt_geoip' => (method => 'POST') => begin |
136 |
|
|
+ |
137 |
|
|
+ %= $c->render_to_string(inline => l('xtg_F2B_LIST_DESCRIPTION')); |
138 |
|
|
+ |
139 |
|
|
+ %= submit_button l 'xtg_F2B_LIST', class => 'action' |
140 |
|
|
+ %= hidden_field 'Choice' => 'LF2B' |
141 |
|
|
+ |
142 |
|
|
+ % end |
143 |
|
|
+ |
144 |
|
|
</div> |
145 |
|
|
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 |
146 |
|
|
--- smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_exstat 2020-06-07 23:12:41.000000000 +0400 |
147 |
|
|
+++ smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_exstat 2022-07-11 20:13:25.962000000 +0400 |
148 |
|
|
@@ -15,8 +15,12 @@ |
149 |
|
|
PREF="ipt" |
150 |
|
|
TITLE=" Numbers of IPs banned (xt_geoip) by country" |
151 |
|
|
;; |
152 |
|
|
+ "f2b") |
153 |
|
|
+ PREF="f2b" |
154 |
|
|
+ TITLE=" Numbers of IPs banned (fail2ban) by country" |
155 |
|
|
+ ;; |
156 |
|
|
*) |
157 |
|
|
- echo "usage : $0 'ssh|ipt' [D|W|M]" |
158 |
|
|
+ echo "usage : $0 'ssh|ipt|f2b' [D|W|M]" |
159 |
|
|
exit 1 |
160 |
|
|
;; |
161 |
|
|
esac |
162 |
|
|
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 |
163 |
|
|
--- smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_listat 2020-06-07 23:12:41.000000000 +0400 |
164 |
|
|
+++ smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_listat 2022-07-11 17:32:55.054000000 +0400 |
165 |
|
|
@@ -3,7 +3,7 @@ |
166 |
|
|
EXECDIR="/usr/share/xt_geoip" |
167 |
|
|
STATDIR="/var/lib/xt_geoip" |
168 |
|
|
|
169 |
|
|
-for pref in $(echo 'ipt ssh') |
170 |
|
|
+for pref in $(echo 'ipt ssh f2b') |
171 |
|
|
do |
172 |
|
|
echo "" > ${STATDIR}/extA_${pref}_country.lst |
173 |
|
|
for period in $(echo 'D W M') |
174 |
|
|
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 |
175 |
|
|
--- smeserver-xt_geoip-1.3.1.old/root/usr/share/xt_geoip/geoip_stats 2022-07-10 12:05:34.000000000 +0400 |
176 |
|
|
+++ smeserver-xt_geoip-1.3.1/root/usr/share/xt_geoip/geoip_stats 2022-07-11 17:31:41.471000000 +0400 |
177 |
|
|
@@ -21,8 +21,22 @@ |
178 |
|
|
CMD2=' | grep -i ' |
179 |
|
|
CMD3=' | grep "GeoIP BAN" | sed -e "s/^.*SRC=//" -e "s/ DST=.*$//" >> $RESFILE' |
180 |
|
|
;; |
181 |
|
|
+ "f2b") |
182 |
|
|
+ if [[ -x /bin/fail2ban-client && -f /var/log/fail2ban/daemon.log ]] |
183 |
|
|
+ then |
184 |
|
|
+ PREF="f2b" |
185 |
|
|
+ LOGDIR="/var/log/fail2ban" |
186 |
|
|
+ CMD1='zcat -f ' |
187 |
|
|
+ CMD2=' | grep -i ' |
188 |
|
|
+ CMD3=' | grep -E "] Ban " | sed -e "s/^.* Ban //" >> $RESFILE' |
189 |
|
|
+ # CMD3=' | grep -E ": NOTICE [.*] Ban" | sed -e "s/^.* Ban //" >> $RESFILE' |
190 |
|
|
+ else |
191 |
|
|
+ echo "No fail2ban enabled here" |
192 |
|
|
+ exit 1 |
193 |
|
|
+ fi |
194 |
|
|
+ ;; |
195 |
|
|
*) |
196 |
|
|
- echo "usage : $0 [ssh|ipt|....]" |
197 |
|
|
+ echo "usage : $0 [ssh|ipt|f2b|....]" |
198 |
|
|
exit 1 |
199 |
|
|
;; |
200 |
|
|
esac |
201 |
|
|
@@ -43,6 +57,7 @@ |
202 |
|
|
LOGDAY="$(LC_ALL=C date --date '1 day ago' '+%h %e')" |
203 |
|
|
DATE=$(date --date '1 day ago' '+%Y-%m-%d') |
204 |
|
|
ARCHDATE=$(date --date '90 day ago' '+%Y-%m-%d') |
205 |
|
|
+[[ $PREF = 'f2b' ]] && LOGDAY=$DATE |
206 |
|
|
|
207 |
|
|
cd $EXECDIR |
208 |
|
|
|