Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1935 → Rev 1936

/web/acc/admin/bl_filter.php
101,7 → 101,6
$l_reject_bl="Rejeter";
$l_warning="Temps estimé : une minute.";
$l_specific_filtering="Filtrage special";
$l_one_dns_ip="Entrez un nom de domaine ou une adresse IP ou une adresse de réseau par ligne<br>exemple (domaine) : .domaine.org - exemple (ip) : 61.54.52.56 - exemple (réseau) : 172.16.0.0/16";
$l_maj_rehabilitated="Noms de domaine ou IP réhabilités";
$l_rehabilitated_dns="Noms de domaine réhabilités";
$l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
108,7 → 107,9
$l_add_to_bl="Noms de domaine ou adresses IP à ajouter à la liste noire";
$l_rehabilitated_ip="IP réhabilitées";
$l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
$l_one_dns="Entrez une adresse DNS par ligne (exemple : www.domaine.com)";
$l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
$l_one_dns_ip="Entrez un nom de domaine ou une adresse IP ou une adresse de réseau par ligne<br>exemple (domaine) : .domaine.org - exemple (ip) : 61.54.52.56 - exemple (réseau) : 172.16.0.0/16";
$l_record="Enregistrer les modifications";
$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
$l_ip_filtering="Filtrer les URLs contenant une adresse IP au lieu d'un nom de domaine (ex: http://25.56.58.59/index.htm)";
148,7 → 149,6
$l_warning="Estimated time : one minute.";
$l_specific_filtering="Specific filtering";
$l_allowed_dns="Allowed domain names";
$l_one_dns_ip="Enter one domain name or one IP address or one network address per row <br>example (domain): .domain.org - example (ip): 61.54.56.52 - example (network) : 172.16.0.0/16";
$l_maj_rehabilitated="Domain names or IP rehabilitated";
$l_rehabilitated_dns="Rehabilitated domain names";
$l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
155,7 → 155,9
$l_add_to_bl="Domain names or IP addresses to add to the blacklist";
$l_rehabilitated_ip="Rehabilitated IP";
$l_rehabilitated_ip_explain="Enter here IP that are blocked by the blacklist <BR> and you want to rehabilitate.";
$l_one_dns="Enter one DNS per row (example : www.domaine.com)";
$l_one_ip="Enter one IP per row (example : 123.123.123.123)";
$l_one_dns_ip="Enter one domain name or one IP address or one network address per row <br>example (domain): .domain.org - example (ip): 61.54.56.52 - example (network) : 172.16.0.0/16";
$l_record="Save changes";
$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
184,17 → 186,17
}
$dir_etc="/usr/local/etc/";
$dir_dg="/etc/dansguardian/lists/";
$dir_blacklist=$dir_dg."blacklists/";
$dir_bl_ip="/usr/local/share/iptables-bl/";
$dir_bl_dns="/usr/local/share/dnsmasq-bl/";
$bl_categories=$dir_etc."alcasar-bl-categories";
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
$conf_file=$dir_etc."alcasar.conf";
$dir_blacklist=$dir_dg."blacklists/";
$urlregex_file=$dir_dg."urlregexplist";
$bannedsite_file=$dir_dg."bannedsitelist";
$dir_tmp="/tmp/blacklists";
$upload_dir_ip = "/usr/local/share/iptables-bl-enabled/";
$upload_dir_domain_names = "/usr/local/share/dnsmasq-bl-enabled/";
$dir_ip_enabled = "/usr/local/share/iptables-bl-enabled/";
$dir_domain_names_enabled = "/usr/local/share/dnsmasq-bl-enabled/";
$dir_ip = "/usr/local/share/iptables-bl/";
$dir_domain_names = "/usr/local/share/dnsmasq-bl/";
$update_file_cat="/usr/local/etc/update_cat.conf";
253,18 → 255,14
fclose($pointeur);
}
else {echo "$l_error_open_file $bl_categories_enabled";}
$fichier=fopen($dir_bl_dns."ossi.conf","w+");
fputs($fichier, form_filter($_POST['OSSI_bl_domains']));
$fichier=fopen($dir_blacklist."ossi-bl/domains","w+");
fputs($fichier, form_filter($_POST['OSSI_bl']));
fclose($fichier);
unset($_POST['OSSI_bl_domains']);
unset($_POST['OSSI_bl']);
$fichier=fopen($dir_dg."exceptionsitelist","w+");
fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
fclose($fichier);
unset($_POST['BL_rehabilited_domains']);
$fichier=fopen($dir_bl_ip."ossi","w+");
fputs($fichier, form_filter_ip($_POST['OSSI_bl_ip'], "black"));
fclose($fichier);
unset($_POST['OSSI_bl_ip']);
$fichier=fopen($dir_dg."exceptioniplist","w+");
fputs($fichier, form_filter($_POST['BL_rehabilited_ip']));
fclose($fichier);
280,7 → 278,7
}
exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh $safesearch $pureip");
break;
case 'MAJ_ip_file' :
case 'MAJ_ossi_file' :
foreach($_POST as $fichier => $value)
{
if($fichier != "choix")
288,30 → 286,29
$action=$_POST[$fichier];
if($action == $l_remove) //delete
{
exec("rm -rf $upload_dir_ip$fichier");
exec("rm -rf $upload_dir_domain_names$fichier");
exec("rm -rf $dir_ip$fichier");
exec("rm -rf $dir_domain_names$fichier");
exec("rm -f $dir_ip_enabled$fichier");
exec("rm -f $dir_domain_names_enabled$fichier");
exec("rm -f $dir_ip$fichier");
exec("rm -f $dir_domain_names$fichier");
exec("rm -rf $dir_dg$fichier");
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
}
if($action == $l_disable) //disable
{
exec("mv -f $upload_dir_ip$fichier $dir_ip$fichier");
if($fichier!='ossi-tor_node_ip')
exec("mv -f $upload_dir_domain_names$fichier $dir_domain_names$fichier");
exec("rm -f $dir_ip_enabled$fichier");
exec("rm -f $dir_domain_names_enabled$fichier");
exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
}
if($action == $l_enable) //enable
{
exec("mv -f $dir_ip$fichier $upload_dir_ip$fichier");
if($fichier!='ossi-tor_node_ip')
exec("mv -f $dir_domain_names$fichier $upload_dir_domain_names$fichier");
exec("ln -s $dir_ip$fichier $dir_ip_enabled$fichier");
exec("ln -s $dir_domain_names$fichier $dir_domain_names_enables$fichier");
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
}
}
}
break;
case 'MAJ_ip_file_upload' :
case 'MAJ_ossi_file_upload' :
$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
# Si un fichier a été choisi
if(!empty($nom))
319,29 → 316,6
# On l'upload
if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $blacklist_dir."ossi-bl-".$nom))
{
# On extrait uniquement les ip du fichier
// exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi_ip");
 
# Suppression des doublons
// exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
 
# On adapte le fichier à la sauvegarde du set
// exec("sed -i \"s/^/add bl_ip_blocked /g\" $upload_dir_ip\ossi-$nom");
 
# On extrait uniquement les noms de domaine
# max_tld() retourne le nombre max de charactere pour un top-level dns
// exec("grep -Eo '([a-zA-Z0-9_-]+\.){1,2}[a-zA-Z]{2,".max_tld()."}' $upload_dir_ip$nom > $upload_dir_domain_names\ossi_domain_names");
 
# Suppression des doublons
// exec("sort -u $upload_dir_domain_names\ossi_domain_names > $upload_dir_domain_names\ossi-$nom && rm -f $upload_dir_domain_names\ossi_domain_names");
 
# On adapte le fichier pour Dnsmasq
// exec("sed -i \"s/^/address=\//g\" $upload_dir_domain_names\ossi-$nom");
// exec("sed -i \"s/$/\/$PRIVATE_IP/g\" $upload_dir_domain_names\ossi-$nom");
 
# Suppression du fichier
// exec("rm -f $upload_dir_ip$nom");
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
exec ("sudo /usr/local/bin/alcasar-iptables.sh ");
}
393,45 → 367,39
<input type='hidden' name='choix' value='MAJ_cat_bl'>
<?php
echo "<center>";
// total nnumber of IP, DNS & URLs
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-bl/* | tail -n 1 | awk '{print $1}'");
$nbUrl = exec ("for file in `find /etc/dansguardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb");
$nbIp = exec ("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'");
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
echo "$l_bl_categories</center></td></tr>";
//on lit et on interprete le fichier de catégories
//read & display all BL categories (checked or not)
$cols=1;
if (file_exists($bl_categories))
{
$pointeur=fopen($bl_categories,"r");
while (!feof ($pointeur))
$bl_files = file($bl_categories);
$bl_files = preg_grep("/ossi-/", $bl_files, 1); // don't display ossi custom categories
foreach($bl_files as $fichier => $value)
{
$ligne=fgets($pointeur, 4096);
if ($ligne)
{
if ($cols == 1) { echo "<tr>";}
$categorie=trim(basename($ligne));
if($categorie != "ossi") // don't display ossi
{
echo "<td><a href='bl_categories_help.php?liste=bl&cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>$categorie</a><br>";
echo "<input type='checkbox' name='chk-$categorie'";
// si la ligne est commentée -> categorie non selectionnée
if (preg_match('/^#/',$ligne, $r)) { echo ">";}
else { echo "checked>"; }
echo "</td>";
$cols++;
}
if ($cols > 10) {
echo "</tr>";
$cols=1; }
}
if ($cols == 1) { echo "<tr>";}
$categorie=trim(basename($value));
echo "<td><a href='bl_categories_help.php?liste=bl&cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>$categorie</a><br>";
echo "<input type='checkbox' name='chk-$categorie'";
// si la ligne est commentée -> categorie non selectionnée
if (preg_match('/^#/',$value, $r)) { echo ">";}
else { echo "checked>"; }
echo "</td>";
$cols++;
if ($cols > 10) {
echo "</tr>";
$cols=1; }
}
fclose($pointeur);
}
else {
echo "$l_error_open_file $bl_categories";
}
 
#update categories via rsync
//update categories with rsync
$update_select = array();
$update_select[0] = "";
$update_select[1] = "";
457,26 → 425,19
echo "<H3>$l_rehabilitated_ip</H3>$l_rehabilitated_ip_explain<BR>$l_one_ip<BR>";
echo "<textarea name='BL_rehabilited_ip' rows=3 cols=40>";
echo_file ($dir_dg."exceptioniplist");
echo "</textarea></td></tr><tr><td width=50% colspan=10>";
echo "</textarea></td></tr>";
echo "<tr><td valign='middle' align='left' colspan=10>";
echo "<center><b>$l_add_to_bl</b></center></td></tr>";
echo "<tr><td width=100% colspan=10 align=center>";
echo "$l_one_dns_ip<BR>";
echo "<textarea name='OSSI_bl_domains' rows=3 cols=40>";
echo_file ($dir_blacklist."ossi-bl/domain");
echo "<textarea name='OSSI_bl' rows=3 cols=40>";
echo_file ($dir_blacklist."ossi-bl/domains");
echo "</textarea></td>";
//echo "<td width=50% colspan=5 align=center>";
//echo "<H3>$l_forbidden_ip</H3>$l_forbidden_ip_explain<BR>";
//echo "<textarea name='OSSI_bl_ip' rows=3 cols=40>";
//echo_ip_file ($dir_blacklist."ossi");
//echo "</textarea></td></tr>;
echo "</tr><tr><td colspan=10>";
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'>";
echo "</form> ($l_wait)";
echo "</td></tr></table><br/>";
?>
 
 
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><?php echo $l_additional_file_title; ?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
483,36 → 444,21
</table>
<table width="100%" border=1 cellspacing=0 cellpadding=1>
<form action='bl_filter.php' method='POST'>
<input type='hidden' name='choix' value='MAJ_ip_file'>
<input type='hidden' name='choix' value='MAJ_ossi_file'>
<?php
echo "<tr><td width=50% colspan=5 align=center>";
echo "<H3>$l_file_list</H3>";
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th>$l_file_state<th>$l_file_remove</tr>";
 
//liste des fichiers activés
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.'));
$fichiersbl = preg_grep("/^ossi-bl",$fichiersbl);
//list OSSI custom categories
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
$fichiersbl = preg_grep("/^ossi-/",$fichiersbl);
foreach($fichiersbl as $fichier => $value)
{
if($value=='ossi-tor_node_ip')
echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&filtre=domain' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td><center>".exec("wc -l $upload_dir_ip$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $upload_dir_domain_names$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove' disabled></center></td></tr>";
else
echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&filtre=domain' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td><center>".exec("wc -l $upload_dir_ip$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $upload_dir_domain_names$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&filtre=domain' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td><center>".exec("wc -l $dir_ip_enabled$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $dir_domain_names_enabled$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
}
//liste des fichiers desactivés
$fichiersIp = array_diff(scandir($dir_ip), array('ossi','ossi-ip-safesearch','..','.'));
$fichiersIp = preg_grep("/^ossi-/",$fichiersIp);
foreach($fichiersIp as $fichier => $value)
{
if($value=='ossi-tor_node_ip')
echo "<tr><td bgcolor='BEBEBE'><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&filtre=domain&state=disable' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_ip$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_domain_names$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_enable'></center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_remove' disabled></center></td></tr>";
else
echo "<tr><td bgcolor='BEBEBE'><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&filtre=domain&state=disable' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_ip$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_domain_names$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_enable'></center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
}
 
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
echo "<H3>$l_add_file</H3>";
echo "$l_add_file_explain";
echo "<input type='file' name='fichier_ip'>";