Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1294 → Rev 1339

/web/acc/admin/net_filter.php
19,12 → 19,6
$l_antivir_off="L'antivirus de flux WEB est actuellement désactivé";
$l_switch_antivir_on="Activer l'antivirus";
$l_switch_antivir_off="Désactiver l'antivirus";
$l_title_ip_block="Filtrage d'adresses IP";
$l_ip_address="Adresses IP (ou addresse de réseau) bloquées";
$l_blocked_ip_address="Adresses IP";
$l_blocked_ip_address_comment="Commentaires";
$l_blocked="Bloquée";
$l_ip_block_explain="Liste des adresses IP (ou adresses IP de réseaux) bloquées";
$l_remove="Retirer de la liste";
$l_title_proto = "Filtrage de protocoles réseau";
$l_netfilter_on="Le filtrage de protocoles réseau est actuellement activé";
47,12 → 41,6
$l_antivir_off="Actually, the WEB antivirus is off";
$l_switch_antivir_on="Switch the antivirus on";
$l_switch_antivir_off="Switch the antivirus off";
$l_title_ip_block="IP address filter";
$l_ip_address="IP address (or network IP address)";
$l_blocked_ip_address="IP addresses";
$l_blocked_ip_address_comment="Comments";
$l_blocked="Blocked";
$l_ip_block_explain="List of blocked IP addresses (or network IP adresses)";
$l_remove="Remove from list";
$l_title_proto = "Network protocols filter";
$l_netfilter_on="Actually, the network protocols filter is enable";
75,8 → 63,7
*********************/
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
define ("IP_BLOCKED", "/usr/local/etc/alcasar-ip-blocked");
$conf_files=array(SERVICES_LIST,CONF_FILE,IP_BLOCKED);
$conf_files=array(SERVICES_LIST,CONF_FILE);
foreach ($conf_files as $file){
if (!file_exists($file)){
exit("Requested file ".$file." isn't present");}
138,34 → 125,6
}
}
break;
case 'new_ip' :
if (trim($_POST['add_ip']) != "")
{
$_POST['add_comment'] = str_replace (CHR(32),"-",$_POST['add_comment']);
$tab=file(IP_BLOCKED);
$insert = true;
if ($tab) // file isn't empty
{
foreach ($tab as $line) // test if IP address doesn't already exist
{
$IP_f=explode(" ", $line);
if (strcmp (trim($_POST['add_ip']),trim(trim($IP_f[0],"#"))) == 0)
{
$insert = false;
break;
}
}
}
if ($insert == true)
{
$line ="\n" . "#".trim($_POST['add_ip']) . " " . trim($_POST['add_comment']);
$pointeur=fopen(IP_BLOCKED,"a");
fwrite ($pointeur, $line);
fclose ($pointeur);
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
}
}
break;
case 'change_port' :
$tab=file(SERVICES_LIST);
if ($tab)
208,54 → 167,6
}
exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
break;
case 'change_ip' :
$tab=file(IP_BLOCKED);
if ($tab)
{
// authorize/block IPs
exec ("sudo /usr/sbin/ipset flush alcasar_ip_blocked");
$pointeur=fopen(IP_BLOCKED,"w+");
foreach ($tab as $ligne)
{
$ip_f=explode(" ", $ligne);
$ip_blocked1=trim($ip_f[0],"#");
$actif = False; $remove_line = false;
foreach ($_POST as $key => $value)
{
$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
if (strstr($key,'del-'))
{
$ip_blocked2 = str_replace('del-','',$key);
if ($ip_blocked1 == $ip_blocked2)
{
$remove_line = True;
break;
}
}
if (strstr($key,'chk-'))
{
$ip_blocked2 = str_replace('chk-','',$key);
if ($ip_blocked1 == $ip_blocked2)
{
$actif = True;
break;
}
}
}
if (! $remove_line)
{
if (! $actif) { $line="#$ip_blocked1 $ip_f[1]";}
else
{
$line="$ip_blocked1 $ip_f[1]";
exec ("sudo /usr/sbin/ipset add alcasar_ip_blocked $ip_blocked1");
}
fwrite($pointeur,$line);
}
}
fclose($pointeur);
}
break;
}
# default values
if (is_file (CONF_FILE))
297,64 → 208,6
</td></tr>
</table>
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><th><?echo "$l_title_ip_block";?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
<table width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td colspan=2 align="center">
<?
echo "$l_ip_block_explain</td></tr>";
echo "<tr><td align='center' valign='middle'>";
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
echo "<input type=hidden name='choix' value=\"IP_block_filter\">";
echo "<table cellspacing=2 cellpadding=2 border=1>";
echo "<tr><th>$l_blocked_ip_address<th>$l_blocked_ip_address_comment<th>$l_blocked<th>$l_remove</tr>";
// Read the "IP_block" file
$tab=file(IP_BLOCKED);
if ($tab) # the file isn't empty
{
foreach ($tab as $line)
{
if (trim($line) != '') # the line isn't empty
{
$blocked_ip=explode(" ", $line);
$ip_addr=trim($blocked_ip[0],"#");
$comment=trim($blocked_ip[1]);
if ($comment ==''){$comment="&nbsp;";}
echo "<tr><td>$ip_addr<td>$comment";
echo "<td><input type='checkbox' name='chk-$ip_addr'";
if (preg_match('/^#/',$line, $r)) {
echo ">";}
else {
echo "checked>";}
echo "<td>";
if (strcmp (trim($ip_addr),trim($conf["PUBLIC_IP"]))) {
echo "<input type='checkbox' name='del-$ip_addr'>";}
else {
echo "&nbsp;";}
echo "</tr>";
}
}
}
?>
</table>
<input type='hidden' name='choix' value='change_ip'>
<input type='submit' value='<?echo"$l_save";?>'>
</form></td><td valign='middle' align='center'>
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
<table cellspacing=2 cellpadding=3 border=1>
<tr><th><?echo"$l_ip_address<th>$l_blocked_ip_address_comment";?>
<td></td></tr>
<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>
<tr><td><input type='text' name='add_ip' size='17'></td>
<td><input type='text' name='add_comment' size='10'></td>
<input type='hidden' name='choix' value='new_ip'>
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
</tr></table>
</form>
</td></tr>
</table>
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><th><?echo "$l_title_proto";?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>