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";
|
861 |
richard |
42 |
$l_save="Enregistrer les modifications";
|
318 |
richard |
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";
|
861 |
richard |
71 |
$l_save="Save changes";
|
318 |
richard |
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 |
}
|
861 |
richard |
86 |
/**********************************
|
|
|
87 |
* Read ALCASAR CONF_FILE *
|
|
|
88 |
***********************************/
|
|
|
89 |
$ouvre=fopen(CONF_FILE,"r");
|
|
|
90 |
if ($ouvre){
|
|
|
91 |
while (!feof ($ouvre))
|
|
|
92 |
{
|
|
|
93 |
$tampon = fgets($ouvre, 4096);
|
|
|
94 |
if (strpos($tampon,"=")!==false){
|
|
|
95 |
$tmp = explode("=",$tampon);
|
|
|
96 |
$conf[$tmp[0]] = $tmp[1];
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
}else{
|
|
|
100 |
exit("Erreur d'ouverture du fichier ".CONF_FILE);
|
|
|
101 |
}
|
|
|
102 |
fclose($ouvre);
|
859 |
richard |
103 |
|
318 |
richard |
104 |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
|
|
|
105 |
switch ($choix)
|
|
|
106 |
{
|
|
|
107 |
case 'AV_On' :
|
|
|
108 |
exec ("sudo /usr/local/sbin/alcasar-havp.sh -on");
|
|
|
109 |
break;
|
|
|
110 |
case 'AV_Off' :
|
|
|
111 |
exec ("sudo /usr/local/sbin/alcasar-havp.sh -off");
|
|
|
112 |
break;
|
|
|
113 |
case 'NF_On' :
|
|
|
114 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
115 |
break;
|
|
|
116 |
case 'NF_Off' :
|
|
|
117 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
|
|
|
118 |
break;
|
859 |
richard |
119 |
case 'new_port' :
|
318 |
richard |
120 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
121 |
{
|
860 |
richard |
122 |
$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
|
859 |
richard |
123 |
$tab=file(SERVICES_LIST);
|
860 |
richard |
124 |
$insert = true;
|
|
|
125 |
if ($tab) // file isn't empty
|
318 |
richard |
126 |
{
|
860 |
richard |
127 |
foreach ($tab as $line) //test if port doesn't already exist
|
318 |
richard |
128 |
{
|
859 |
richard |
129 |
$proto_f=explode(" ", $line);
|
318 |
richard |
130 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
131 |
}
|
|
|
132 |
}
|
860 |
richard |
133 |
if ($insert == true)
|
|
|
134 |
{
|
|
|
135 |
$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
|
|
|
136 |
$pointeur=fopen(SERVICES_LIST,"a");
|
|
|
137 |
fwrite ($pointeur, $line);
|
|
|
138 |
fclose ($pointeur);
|
|
|
139 |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
|
|
|
140 |
}
|
318 |
richard |
141 |
}
|
|
|
142 |
break;
|
859 |
richard |
143 |
case 'new_ip' :
|
|
|
144 |
if (trim($_POST['add_ip']) != "")
|
|
|
145 |
{
|
860 |
richard |
146 |
$_POST['add_comment'] = str_replace (CHR(32),"-",$_POST['add_comment']);
|
859 |
richard |
147 |
$tab=file(IP_BLOCKED);
|
860 |
richard |
148 |
$insert = true;
|
|
|
149 |
if ($tab) // file isn't empty
|
859 |
richard |
150 |
{
|
860 |
richard |
151 |
foreach ($tab as $line) // test if IP address doesn't already exist
|
859 |
richard |
152 |
{
|
860 |
richard |
153 |
$IP_f=explode(" ", $line);
|
|
|
154 |
if (trim($_POST['add_ip']) == trim(trim($IP_f[0],"#"))) {$insert = false;}
|
859 |
richard |
155 |
}
|
|
|
156 |
}
|
860 |
richard |
157 |
if ($insert == true)
|
|
|
158 |
{
|
|
|
159 |
$line ="\n" . "#".trim($_POST['add_ip']) . " " . trim($_POST['add_comment']);
|
|
|
160 |
$pointeur=fopen(IP_BLOCKED,"a");
|
|
|
161 |
fwrite ($pointeur, $line);
|
|
|
162 |
fclose ($pointeur);
|
|
|
163 |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
|
|
|
164 |
}
|
859 |
richard |
165 |
}
|
|
|
166 |
break;
|
|
|
167 |
case 'change_port' :
|
|
|
168 |
$tab=file(SERVICES_LIST);
|
318 |
richard |
169 |
if ($tab)
|
|
|
170 |
{
|
859 |
richard |
171 |
// authorize/block protocols
|
|
|
172 |
$pointeur=fopen(SERVICES_LIST,"w+");
|
318 |
richard |
173 |
foreach ($tab as $ligne)
|
|
|
174 |
{
|
|
|
175 |
$proto_f=explode(" ", $ligne);
|
|
|
176 |
$name_svc1=trim($proto_f[0],"#");
|
|
|
177 |
$actif = False; $remove_line = false;
|
|
|
178 |
foreach ($_POST as $key => $value)
|
|
|
179 |
{
|
|
|
180 |
if (strstr($key,'del-'))
|
|
|
181 |
{
|
|
|
182 |
$name_svc2 = str_replace('del-','',$key);
|
|
|
183 |
if ($name_svc1 == $name_svc2)
|
|
|
184 |
{
|
|
|
185 |
$remove_line = True;
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
if (strstr($key,'chk-'))
|
|
|
189 |
{
|
|
|
190 |
$name_svc2 = str_replace('chk-','',$key);
|
|
|
191 |
if ($name_svc1 == $name_svc2)
|
|
|
192 |
{
|
|
|
193 |
$actif = True;
|
|
|
194 |
break;
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
if (! $remove_line)
|
|
|
199 |
{
|
|
|
200 |
if (! $actif) { $line="#$name_svc1 $proto_f[1]";}
|
|
|
201 |
else { $line="$name_svc1 $proto_f[1]";}
|
|
|
202 |
fwrite($pointeur,$line);
|
|
|
203 |
}
|
|
|
204 |
}
|
|
|
205 |
fclose($pointeur);
|
|
|
206 |
}
|
860 |
richard |
207 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
|
318 |
richard |
208 |
break;
|
859 |
richard |
209 |
case 'change_ip' :
|
|
|
210 |
$tab=file(IP_BLOCKED);
|
|
|
211 |
if ($tab)
|
|
|
212 |
{
|
|
|
213 |
// authorize/block IPs
|
|
|
214 |
$pointeur=fopen(IP_BLOCKED,"w+");
|
|
|
215 |
foreach ($tab as $ligne)
|
|
|
216 |
{
|
|
|
217 |
$ip_f=explode(" ", $ligne);
|
|
|
218 |
$ip_blocked1=trim($ip_f[0],"#");
|
|
|
219 |
$actif = False; $remove_line = false;
|
|
|
220 |
foreach ($_POST as $key => $value)
|
|
|
221 |
{
|
860 |
richard |
222 |
$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
|
859 |
richard |
223 |
if (strstr($key,'del-'))
|
|
|
224 |
{
|
|
|
225 |
$ip_blocked2 = str_replace('del-','',$key);
|
|
|
226 |
if ($ip_blocked1 == $ip_blocked2)
|
|
|
227 |
{
|
|
|
228 |
$remove_line = True;
|
|
|
229 |
break;
|
|
|
230 |
}
|
|
|
231 |
}
|
|
|
232 |
if (strstr($key,'chk-'))
|
|
|
233 |
{
|
|
|
234 |
$ip_blocked2 = str_replace('chk-','',$key);
|
|
|
235 |
if ($ip_blocked1 == $ip_blocked2)
|
|
|
236 |
{
|
|
|
237 |
$actif = True;
|
|
|
238 |
break;
|
|
|
239 |
}
|
|
|
240 |
}
|
|
|
241 |
}
|
|
|
242 |
if (! $remove_line)
|
|
|
243 |
{
|
|
|
244 |
if (! $actif) { $line="#$ip_blocked1 $ip_f[1]";}
|
|
|
245 |
else { $line="$ip_blocked1 $ip_f[1]";}
|
|
|
246 |
fwrite($pointeur,$line);
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
fclose($pointeur);
|
|
|
250 |
}
|
860 |
richard |
251 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
859 |
richard |
252 |
break;
|
318 |
richard |
253 |
}
|
612 |
richard |
254 |
# default values
|
859 |
richard |
255 |
if (is_file (CONF_FILE))
|
612 |
richard |
256 |
{
|
859 |
richard |
257 |
$tab=file(CONF_FILE);
|
612 |
richard |
258 |
if ($tab)
|
|
|
259 |
{
|
|
|
260 |
foreach ($tab as $line)
|
|
|
261 |
{
|
|
|
262 |
$field=explode("=", $line);
|
|
|
263 |
if ($field[0] == "PROTOCOLS_FILTERING") {$PROTOCOLS_FILTERING=trim($field[1]);}
|
|
|
264 |
if ($field[0] == "WEB_ANTIVIRUS") {$WEB_ANTIVIRUS=trim($field[1]);}
|
|
|
265 |
}
|
|
|
266 |
}
|
|
|
267 |
}
|
|
|
268 |
echo "<tr><th>$l_title_antivir</th></tr>";
|
318 |
richard |
269 |
?>
|
612 |
richard |
270 |
<tr bgcolor=#FFCC66><td><img src=/images/pix.gif width=1 height=2></td></tr>
|
|
|
271 |
</TABLE>
|
318 |
richard |
272 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
|
|
273 |
<tr><td valign="middle" align="left">
|
|
|
274 |
<?php
|
612 |
richard |
275 |
if ($WEB_ANTIVIRUS == "on")
|
318 |
richard |
276 |
{
|
|
|
277 |
echo "<CENTER><H3>$l_antivir_on</H3></CENTER>";
|
|
|
278 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
279 |
echo "<input type=hidden name='choix' value=\"AV_Off\">";
|
|
|
280 |
echo "<input type=submit value=\"$l_switch_antivir_off\">";
|
|
|
281 |
}
|
|
|
282 |
else
|
|
|
283 |
{
|
|
|
284 |
echo "<CENTER><H3>$l_antivir_off</H3></CENTER>";
|
|
|
285 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
286 |
echo "<input type=hidden name='choix' value=\"AV_On\">";
|
|
|
287 |
echo "<input type=submit value=\"$l_switch_antivir_on\">";
|
|
|
288 |
}
|
|
|
289 |
?>
|
|
|
290 |
</FORM>
|
|
|
291 |
</td></tr>
|
372 |
richard |
292 |
</table>
|
|
|
293 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
859 |
richard |
294 |
<tr><th><?echo "$l_title_ip_block";?></th></tr>
|
372 |
richard |
295 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
296 |
</table>
|
859 |
richard |
297 |
<table width="100%" border=1 cellspacing=0 cellpadding=1>
|
|
|
298 |
<tr><td colspan=2 align="center">
|
|
|
299 |
<?
|
|
|
300 |
echo "$l_ip_block_explain</td></tr>";
|
|
|
301 |
echo "<tr><td align='center' valign='middle'>";
|
|
|
302 |
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
|
|
|
303 |
echo "<input type=hidden name='choix' value=\"IP_block_filter\">";
|
|
|
304 |
echo "<table cellspacing=2 cellpadding=2 border=1>";
|
|
|
305 |
echo "<tr><th>$l_blocked_ip_address<th>$l_blocked_ip_address_comment<th>$l_blocked<th>$l_remove</tr>";
|
|
|
306 |
// Read the "IP_block" file
|
|
|
307 |
$tab=file(IP_BLOCKED);
|
|
|
308 |
if ($tab) # the file isn't empty
|
790 |
richard |
309 |
{
|
859 |
richard |
310 |
foreach ($tab as $line)
|
|
|
311 |
{
|
|
|
312 |
if (trim($line) != '') # the line isn't empty
|
|
|
313 |
{
|
|
|
314 |
$blocked_ip=explode(" ", $line);
|
|
|
315 |
$ip_addr=trim($blocked_ip[0],"#");
|
860 |
richard |
316 |
$comment=trim($blocked_ip[1]);
|
|
|
317 |
if ($comment ==''){$comment=" ";}
|
|
|
318 |
echo "<tr><td>$ip_addr<td>$comment";
|
859 |
richard |
319 |
echo "<td><input type='checkbox' name='chk-$ip_addr'";
|
|
|
320 |
if (preg_match('/^#/',$line, $r)) {
|
|
|
321 |
echo ">";}
|
|
|
322 |
else {
|
|
|
323 |
echo "checked>";}
|
861 |
richard |
324 |
echo "<td>";
|
|
|
325 |
if (strcmp (trim($ip_addr),trim($conf["PUBLIC_IP"]))) {
|
|
|
326 |
echo "<input type='checkbox' name='del-$ip_addr'>";}
|
|
|
327 |
else {
|
|
|
328 |
echo " ";}
|
859 |
richard |
329 |
echo "</tr>";
|
|
|
330 |
}
|
|
|
331 |
}
|
790 |
richard |
332 |
}
|
|
|
333 |
?>
|
859 |
richard |
334 |
</table>
|
|
|
335 |
<input type='hidden' name='choix' value='change_ip'>
|
861 |
richard |
336 |
<input type='submit' value='<?echo"$l_save";?>'>
|
859 |
richard |
337 |
</form></td><td valign='middle' align='center'>
|
|
|
338 |
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
|
|
|
339 |
<table cellspacing=2 cellpadding=3 border=1>
|
|
|
340 |
<tr><th><?echo"$l_ip_address<th>$l_blocked_ip_address_comment";?>
|
|
|
341 |
<td></td></tr>
|
|
|
342 |
<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>
|
|
|
343 |
<tr><td><input type='text' name='add_ip' size='17'></td>
|
|
|
344 |
<td><input type='text' name='add_comment' size='10'></td>
|
|
|
345 |
<input type='hidden' name='choix' value='new_ip'>
|
|
|
346 |
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
|
|
|
347 |
</tr></table>
|
|
|
348 |
</form>
|
790 |
richard |
349 |
</td></tr>
|
|
|
350 |
</table>
|
|
|
351 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
352 |
<tr><th><?echo "$l_title_proto";?></th></tr>
|
|
|
353 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
354 |
</table>
|
|
|
355 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
859 |
richard |
356 |
<tr>
|
318 |
richard |
357 |
<?
|
612 |
richard |
358 |
if ($PROTOCOLS_FILTERING == "on")
|
318 |
richard |
359 |
{
|
859 |
richard |
360 |
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
|
318 |
richard |
361 |
echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
|
|
|
362 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
363 |
echo "<input type=hidden name='choix' value=\"NF_Off\">";
|
|
|
364 |
echo "<input type=submit value=\"$l_switch_off\">";
|
859 |
richard |
365 |
echo "</FORM></td></tr>";
|
|
|
366 |
require ('net_filter2.php');
|
318 |
richard |
367 |
}
|
|
|
368 |
else
|
|
|
369 |
{
|
859 |
richard |
370 |
echo "<td valign=\"middle\" align=\"left\">";
|
318 |
richard |
371 |
echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
|
|
|
372 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
373 |
echo "<input type=hidden name='choix' value=\"NF_On\">";
|
|
|
374 |
echo "<input type=submit value=\"$l_switch_on\">";
|
859 |
richard |
375 |
echo "</FORM></td></tr>";
|
|
|
376 |
echo "</table></body></html>";
|
318 |
richard |
377 |
}
|
|
|
378 |
?>
|