318 |
richard |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
2 |
<HTML><!-- written by Rexy -->
|
|
|
3 |
<HEAD>
|
|
|
4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
5 |
<TITLE>Network Filter</TITLE>
|
|
|
6 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
|
|
7 |
</HEAD>
|
|
|
8 |
<body>
|
|
|
9 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
10 |
<?
|
|
|
11 |
# Choice of language
|
|
|
12 |
$Language = 'en';
|
|
|
13 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
14 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
15 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
16 |
if($Language == 'fr'){
|
372 |
richard |
17 |
$l_title_antivir = "Antivirus de flux WEB";
|
364 |
franck |
18 |
$l_antivir_on="L'antivirus de flux WEB est actuellement activé";
|
|
|
19 |
$l_antivir_off="L'antivirus de flux WEB est actuellement désactivé";
|
318 |
richard |
20 |
$l_switch_antivir_on="Activer l'antivirus";
|
364 |
franck |
21 |
$l_switch_antivir_off="Désactiver l'antivirus";
|
859 |
richard |
22 |
$l_title_ip_block="Filtrage d'adresses IP";
|
|
|
23 |
$l_ip_address="Adresses IP (ou addresse de réseau) bloquées";
|
|
|
24 |
$l_blocked_ip_address="Adresses IP";
|
|
|
25 |
$l_blocked_ip_address_comment="Commentaires";
|
|
|
26 |
$l_blocked="Bloquée";
|
|
|
27 |
$l_ip_block_explain="Liste des adresses IP (ou adresses IP de réseaux) bloquées";
|
|
|
28 |
$l_remove="Retirer de la liste";
|
791 |
richard |
29 |
$l_title_proto = "Filtrage de protocoles réseau";
|
372 |
richard |
30 |
$l_netfilter_on="Le filtrage de protocoles réseau est actuellement activé";
|
|
|
31 |
$l_netfilter_off="Le filtrage de protocoles réseau est actuellement désactivé";
|
|
|
32 |
$l_switch_on="Activer le filtrage";
|
|
|
33 |
$l_switch_off="Désactiver le filtrage";
|
318 |
richard |
34 |
$l_comment_on="À l'exclusion du WEB (port 80), les protocoles réseau sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
|
364 |
franck |
35 |
$l_comment_off="(tous les protocoles réseau sont autorisés)";
|
|
|
36 |
$l_protocols="Protocoles autorisés";
|
318 |
richard |
37 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
859 |
richard |
38 |
$l_port="Numéro de port";
|
|
|
39 |
$l_proto="Nom du protocole";
|
364 |
franck |
40 |
$l_enabled="Autorisé";
|
318 |
richard |
41 |
$l_add_to_list="Ajouter à la liste";
|
|
|
42 |
$l_save_modif="Enregistrer les modifications";
|
|
|
43 |
}
|
|
|
44 |
else {
|
372 |
richard |
45 |
$l_title_antivir = "WEB antivirus";
|
|
|
46 |
$l_antivir_on="Actually, the WEB antivirus is on";
|
|
|
47 |
$l_antivir_off="Actually, the WEB antivirus is off";
|
318 |
richard |
48 |
$l_switch_antivir_on="Switch the antivirus on";
|
|
|
49 |
$l_switch_antivir_off="Switch the antivirus off";
|
859 |
richard |
50 |
$l_title_ip_block="IP address filter";
|
|
|
51 |
$l_ip_address="IP address (or network IP address)";
|
|
|
52 |
$l_blocked_ip_address="IP addresses";
|
|
|
53 |
$l_blocked_ip_address_comment="Comments";
|
|
|
54 |
$l_blocked="Blocked";
|
|
|
55 |
$l_ip_block_explain="List of blocked IP addresses (or network IP adresses)";
|
|
|
56 |
$l_remove="Remove from list";
|
791 |
richard |
57 |
$l_title_proto = "Network protocols filter";
|
372 |
richard |
58 |
$l_netfilter_on="Actually, the network protocols filter is enable";
|
|
|
59 |
$l_netfilter_off="Actually, the network protocols filter is disable";
|
|
|
60 |
$l_switch_on="Switch the Filter on";
|
|
|
61 |
$l_switch_off="Switch the Filter off";
|
318 |
richard |
62 |
$l_comment_on="(choose the authorized network protocols)";
|
859 |
richard |
63 |
$l_comment_on="Except for the WEB (port 80), all protocols are blocked.<BR>Choose in the list below, the protocols you want authorize";
|
318 |
richard |
64 |
$l_comment_off="(all the network protocols are allowed for authenticated users)";
|
|
|
65 |
$l_protocols="Authorize protocols";
|
|
|
66 |
$l_error_open_file="Error opening the file";
|
859 |
richard |
67 |
$l_port="Port number";
|
|
|
68 |
$l_proto="protocol name";
|
|
|
69 |
$l_enabled="Authorized";
|
318 |
richard |
70 |
$l_add_to_list="Add to the list";
|
|
|
71 |
$l_save_modif="Save modifications";
|
|
|
72 |
}
|
859 |
richard |
73 |
/********************
|
|
|
74 |
* TEST CONF FILES *
|
|
|
75 |
*********************/
|
|
|
76 |
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
|
|
|
77 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
|
|
78 |
define ("IP_BLOCKED", "/usr/local/etc/alcasar-ip-blocked");
|
|
|
79 |
$conf_files=array(SERVICES_LIST,CONF_FILE,IP_BLOCKED);
|
|
|
80 |
foreach ($conf_files as $file){
|
|
|
81 |
if (!file_exists($file)){
|
|
|
82 |
exit("Requested file ".$file." isn't present");}
|
|
|
83 |
if (!is_readable($file)){
|
|
|
84 |
exit("Can't read the file ".$file);}
|
|
|
85 |
}
|
|
|
86 |
|
318 |
richard |
87 |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
|
|
|
88 |
switch ($choix)
|
|
|
89 |
{
|
|
|
90 |
case 'AV_On' :
|
|
|
91 |
exec ("sudo /usr/local/sbin/alcasar-havp.sh -on");
|
|
|
92 |
break;
|
|
|
93 |
case 'AV_Off' :
|
|
|
94 |
exec ("sudo /usr/local/sbin/alcasar-havp.sh -off");
|
|
|
95 |
break;
|
|
|
96 |
case 'NF_On' :
|
|
|
97 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
98 |
break;
|
|
|
99 |
case 'NF_Off' :
|
|
|
100 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
|
|
|
101 |
break;
|
859 |
richard |
102 |
case 'new_port' :
|
681 |
richard |
103 |
$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
|
318 |
richard |
104 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
105 |
{
|
859 |
richard |
106 |
$tab=file(SERVICES_LIST);
|
318 |
richard |
107 |
if ($tab)
|
|
|
108 |
{
|
859 |
richard |
109 |
$pointeur=fopen(SERVICES_LIST,"r");
|
|
|
110 |
// test if port doesn't already exist
|
318 |
richard |
111 |
$insert = true;
|
859 |
richard |
112 |
foreach ($tab as $line)
|
318 |
richard |
113 |
{
|
859 |
richard |
114 |
$proto_f=explode(" ", $line);
|
318 |
richard |
115 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
116 |
}
|
|
|
117 |
fclose($pointeur);
|
|
|
118 |
if ($insert == true)
|
|
|
119 |
{
|
859 |
richard |
120 |
$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
|
|
|
121 |
$pointeur=fopen(SERVICES_LIST,"a");
|
318 |
richard |
122 |
fwrite ($pointeur, $line);
|
|
|
123 |
fclose ($pointeur);
|
859 |
richard |
124 |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
|
318 |
richard |
125 |
}
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
break;
|
859 |
richard |
129 |
case 'new_ip' :
|
|
|
130 |
if (trim($_POST['add_ip']) != "")
|
|
|
131 |
{
|
|
|
132 |
$tab=file(IP_BLOCKED);
|
|
|
133 |
if ($tab)
|
|
|
134 |
{
|
|
|
135 |
$pointeur=fopen(IP_BLOCKED,"r");
|
|
|
136 |
// test if IP doesn't already exist
|
|
|
137 |
$insert = true;
|
|
|
138 |
foreach ($tab as $line)
|
|
|
139 |
{
|
|
|
140 |
$IP_f=explode("#", $line);
|
|
|
141 |
if (trim($_POST['add_ip']) == trim($IP_f[0])) {$insert = false;}
|
|
|
142 |
}
|
|
|
143 |
fclose($pointeur);
|
|
|
144 |
if ($insert == true)
|
|
|
145 |
{
|
|
|
146 |
$line ="\n" . trim($_POST['add_ip']) . " # " . trim($_POST['add_comment']);
|
|
|
147 |
$pointeur=fopen(IP_BLOCKED,"a");
|
|
|
148 |
fwrite ($pointeur, $line);
|
|
|
149 |
fclose ($pointeur);
|
|
|
150 |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
}
|
|
|
154 |
break;
|
|
|
155 |
case 'change_port' :
|
|
|
156 |
$tab=file(SERVICES_LIST);
|
318 |
richard |
157 |
if ($tab)
|
|
|
158 |
{
|
859 |
richard |
159 |
// authorize/block protocols
|
|
|
160 |
$pointeur=fopen(SERVICES_LIST,"w+");
|
318 |
richard |
161 |
foreach ($tab as $ligne)
|
|
|
162 |
{
|
|
|
163 |
$proto_f=explode(" ", $ligne);
|
|
|
164 |
$name_svc1=trim($proto_f[0],"#");
|
|
|
165 |
$actif = False; $remove_line = false;
|
|
|
166 |
foreach ($_POST as $key => $value)
|
|
|
167 |
{
|
|
|
168 |
if (strstr($key,'del-'))
|
|
|
169 |
{
|
|
|
170 |
$name_svc2 = str_replace('del-','',$key);
|
|
|
171 |
if ($name_svc1 == $name_svc2)
|
|
|
172 |
{
|
|
|
173 |
$remove_line = True;
|
|
|
174 |
break;
|
|
|
175 |
}
|
|
|
176 |
}
|
|
|
177 |
if (strstr($key,'chk-'))
|
|
|
178 |
{
|
|
|
179 |
$name_svc2 = str_replace('chk-','',$key);
|
|
|
180 |
if ($name_svc1 == $name_svc2)
|
|
|
181 |
{
|
|
|
182 |
$actif = True;
|
|
|
183 |
break;
|
|
|
184 |
}
|
|
|
185 |
}
|
|
|
186 |
}
|
|
|
187 |
if (! $remove_line)
|
|
|
188 |
{
|
|
|
189 |
if (! $actif) { $line="#$name_svc1 $proto_f[1]";}
|
|
|
190 |
else { $line="$name_svc1 $proto_f[1]";}
|
|
|
191 |
fwrite($pointeur,$line);
|
|
|
192 |
}
|
|
|
193 |
}
|
|
|
194 |
fclose($pointeur);
|
|
|
195 |
}
|
|
|
196 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
197 |
break;
|
859 |
richard |
198 |
case 'change_ip' :
|
|
|
199 |
$tab=file(IP_BLOCKED);
|
|
|
200 |
if ($tab)
|
|
|
201 |
{
|
|
|
202 |
// authorize/block IPs
|
|
|
203 |
$pointeur=fopen(IP_BLOCKED,"w+");
|
|
|
204 |
foreach ($tab as $ligne)
|
|
|
205 |
{
|
|
|
206 |
$ip_f=explode(" ", $ligne);
|
|
|
207 |
$ip_blocked1=trim($ip_f[0],"#");
|
|
|
208 |
$actif = False; $remove_line = false;
|
|
|
209 |
foreach ($_POST as $key => $value)
|
|
|
210 |
{
|
|
|
211 |
if (strstr($key,'del-'))
|
|
|
212 |
{
|
|
|
213 |
$ip_blocked2 = str_replace('del-','',$key);
|
|
|
214 |
if ($ip_blocked1 == $ip_blocked2)
|
|
|
215 |
{
|
|
|
216 |
$remove_line = True;
|
|
|
217 |
break;
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
if (strstr($key,'chk-'))
|
|
|
221 |
{
|
|
|
222 |
$ip_blocked2 = str_replace('chk-','',$key);
|
|
|
223 |
if ($ip_blocked1 == $ip_blocked2)
|
|
|
224 |
{
|
|
|
225 |
$actif = True;
|
|
|
226 |
break;
|
|
|
227 |
}
|
|
|
228 |
}
|
|
|
229 |
}
|
|
|
230 |
if (! $remove_line)
|
|
|
231 |
{
|
|
|
232 |
if (! $actif) { $line="#$ip_blocked1 $ip_f[1]";}
|
|
|
233 |
else { $line="$ip_blocked1 $ip_f[1]";}
|
|
|
234 |
fwrite($pointeur,$line);
|
|
|
235 |
}
|
|
|
236 |
}
|
|
|
237 |
fclose($pointeur);
|
|
|
238 |
}
|
|
|
239 |
#exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
|
|
240 |
break;
|
318 |
richard |
241 |
}
|
612 |
richard |
242 |
# default values
|
859 |
richard |
243 |
if (is_file (CONF_FILE))
|
612 |
richard |
244 |
{
|
859 |
richard |
245 |
$tab=file(CONF_FILE);
|
612 |
richard |
246 |
if ($tab)
|
|
|
247 |
{
|
|
|
248 |
foreach ($tab as $line)
|
|
|
249 |
{
|
|
|
250 |
$field=explode("=", $line);
|
|
|
251 |
if ($field[0] == "PROTOCOLS_FILTERING") {$PROTOCOLS_FILTERING=trim($field[1]);}
|
|
|
252 |
if ($field[0] == "WEB_ANTIVIRUS") {$WEB_ANTIVIRUS=trim($field[1]);}
|
|
|
253 |
}
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
echo "<tr><th>$l_title_antivir</th></tr>";
|
318 |
richard |
257 |
?>
|
612 |
richard |
258 |
<tr bgcolor=#FFCC66><td><img src=/images/pix.gif width=1 height=2></td></tr>
|
|
|
259 |
</TABLE>
|
318 |
richard |
260 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
|
|
261 |
<tr><td valign="middle" align="left">
|
|
|
262 |
<?php
|
612 |
richard |
263 |
if ($WEB_ANTIVIRUS == "on")
|
318 |
richard |
264 |
{
|
|
|
265 |
echo "<CENTER><H3>$l_antivir_on</H3></CENTER>";
|
|
|
266 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
267 |
echo "<input type=hidden name='choix' value=\"AV_Off\">";
|
|
|
268 |
echo "<input type=submit value=\"$l_switch_antivir_off\">";
|
|
|
269 |
}
|
|
|
270 |
else
|
|
|
271 |
{
|
|
|
272 |
echo "<CENTER><H3>$l_antivir_off</H3></CENTER>";
|
|
|
273 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
274 |
echo "<input type=hidden name='choix' value=\"AV_On\">";
|
|
|
275 |
echo "<input type=submit value=\"$l_switch_antivir_on\">";
|
|
|
276 |
}
|
|
|
277 |
?>
|
|
|
278 |
</FORM>
|
|
|
279 |
</td></tr>
|
372 |
richard |
280 |
</table>
|
|
|
281 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
859 |
richard |
282 |
<tr><th><?echo "$l_title_ip_block";?></th></tr>
|
372 |
richard |
283 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
284 |
</table>
|
859 |
richard |
285 |
<table width="100%" border=1 cellspacing=0 cellpadding=1>
|
|
|
286 |
<tr><td colspan=2 align="center">
|
|
|
287 |
<?
|
|
|
288 |
echo "$l_ip_block_explain</td></tr>";
|
|
|
289 |
echo "<tr><td align='center' valign='middle'>";
|
|
|
290 |
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
|
|
|
291 |
echo "<input type=hidden name='choix' value=\"IP_block_filter\">";
|
|
|
292 |
echo "<table cellspacing=2 cellpadding=2 border=1>";
|
|
|
293 |
echo "<tr><th>$l_blocked_ip_address<th>$l_blocked_ip_address_comment<th>$l_blocked<th>$l_remove</tr>";
|
|
|
294 |
// Read the "IP_block" file
|
|
|
295 |
$tab=file(IP_BLOCKED);
|
|
|
296 |
if ($tab) # the file isn't empty
|
790 |
richard |
297 |
{
|
859 |
richard |
298 |
foreach ($tab as $line)
|
|
|
299 |
{
|
|
|
300 |
if (trim($line) != '') # the line isn't empty
|
|
|
301 |
{
|
|
|
302 |
$blocked_ip=explode(" ", $line);
|
|
|
303 |
$ip_addr=trim($blocked_ip[0],"#");
|
|
|
304 |
echo "<tr><td>$ip_addr<td>$blocked_ip[1]";
|
|
|
305 |
echo "<td><input type='checkbox' name='chk-$ip_addr'";
|
|
|
306 |
// if the line is commented -> IP adress is not blocked
|
|
|
307 |
if (preg_match('/^#/',$line, $r)) {
|
|
|
308 |
echo ">";}
|
|
|
309 |
else {
|
|
|
310 |
echo "checked>";}
|
|
|
311 |
echo "<td><input type='checkbox' name='del-$ip_addr'>";
|
|
|
312 |
echo "</tr>";
|
|
|
313 |
}
|
|
|
314 |
}
|
790 |
richard |
315 |
}
|
|
|
316 |
?>
|
859 |
richard |
317 |
</table>
|
|
|
318 |
<input type='hidden' name='choix' value='change_ip'>
|
|
|
319 |
<input type='submit' value='<?echo"$l_save_modif";?>'>
|
|
|
320 |
</form></td><td valign='middle' align='center'>
|
|
|
321 |
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
|
|
|
322 |
<table cellspacing=2 cellpadding=3 border=1>
|
|
|
323 |
<tr><th><?echo"$l_ip_address<th>$l_blocked_ip_address_comment";?>
|
|
|
324 |
<td></td></tr>
|
|
|
325 |
<tr><td>exemple1 : 15.25.26.27 <br>exemple2 : 18.20.20.0/24</td><td>exemple1 : CERT alert<br>exemple2 : LAN of zombies</td><td></td></tr>
|
|
|
326 |
<tr><td><input type='text' name='add_ip' size='17'></td>
|
|
|
327 |
<td><input type='text' name='add_comment' size='10'></td>
|
|
|
328 |
<input type='hidden' name='choix' value='new_ip'>
|
|
|
329 |
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
|
|
|
330 |
</tr></table>
|
|
|
331 |
</form>
|
790 |
richard |
332 |
</td></tr>
|
|
|
333 |
</table>
|
|
|
334 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
335 |
<tr><th><?echo "$l_title_proto";?></th></tr>
|
|
|
336 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
337 |
</table>
|
|
|
338 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
859 |
richard |
339 |
<tr>
|
318 |
richard |
340 |
<?
|
612 |
richard |
341 |
if ($PROTOCOLS_FILTERING == "on")
|
318 |
richard |
342 |
{
|
859 |
richard |
343 |
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
|
318 |
richard |
344 |
echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
|
|
|
345 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
346 |
echo "<input type=hidden name='choix' value=\"NF_Off\">";
|
|
|
347 |
echo "<input type=submit value=\"$l_switch_off\">";
|
859 |
richard |
348 |
echo "</FORM></td></tr>";
|
|
|
349 |
require ('net_filter2.php');
|
318 |
richard |
350 |
}
|
|
|
351 |
else
|
|
|
352 |
{
|
859 |
richard |
353 |
echo "<td valign=\"middle\" align=\"left\">";
|
318 |
richard |
354 |
echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
|
|
|
355 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
356 |
echo "<input type=hidden name='choix' value=\"NF_On\">";
|
|
|
357 |
echo "<input type=submit value=\"$l_switch_on\">";
|
859 |
richard |
358 |
echo "</FORM></td></tr>";
|
|
|
359 |
echo "</table></body></html>";
|
318 |
richard |
360 |
}
|
|
|
361 |
?>
|