Ds1St3al
Utente Silver
Ultima modifica da un moderatore:
Salve ragazzi, sono walker.ultimate ( di skype ), e voglio rilasciarvi un lavoretto fatto nel mio passatempo, il firewall per siti PHP.
Salvate questo script su un file e chiamatelo come volete voi:
Per attivarlo nel vostro script, nella prima RIGA prima che inizi lo script inserite un bel
Buonagiornata.
Salvate questo script su un file e chiamatelo come volete voi:
PHP:
<?php
session_start();
class Firewall{
public $Flood_Attack_Protection = 1;
public $Get_Attack_Protection = 1;
public $Post_Attack_Protection = 1;
public $maxTries = 5;
public function Block($ipAddress){
$fp=fopen("Logs.txt", "a");
fwrite($fp, $ipAddress."@");
fclose($fp);
}
public function Is_Blocked($ipAddress){
if (file_exists("Logs.txt")) {
$fp=fopen("Logs.txt", "r");
$word=explode("@", fread($fp, filesize("Logs.txt")));
foreach ($word as $ipAddr) {
if ($ipAddress == $ipAddr) {
return true;
}
}
return false;
}else{
return false;
}
}
public function Refresh(){
$this->Message("<meta http-equiv='refresh' content='0'>");
}
public function UserBlock(){
if ($this->Is_Blocked($_SERVER["REMOTE_ADDR"])==false) {
$this->Block($_SERVER["REMOTE_ADDR"]);
$this->Refresh();
}
}
public function Message($msg){
die($msg);
}
public function Stop_Flood_Attack(){
if ($this->Flood_Attack_Protection == 1) {
if ($_SESSION["firewall"]>time()-1){
$_SESSION["count"]=$_SESSION["count"]+1;
$this->Message("<font color='red'>Errore:</font> rilevato flood!");
}
$_SESSION["firewall"]=time();
}
}
public function Stop_Post_Attack(){
if ($this->Get_Attack_Protection == 1) {
foreach ($_POST as $post){
if (preg_match("/[^a-zA-z0-9_-]/", $post)){
$_SESSION["count"]=$_SESSION["count"]+1;
$this->Message("<font color='red'>Errore:</font> rilevati caratteri speciali!");
}
}
}
}
public function Stop_Get_Attack(){
if ($this->Post_Attack_Protection == 1) {
foreach ($_GET as $get){
if (preg_match("/[^a-zA-z0-9_-]/", $get)){
$_SESSION["count"]=$_SESSION["count"]+1;
$this->Message("<font color='red'>Errore:</font> rilevati caratteri speciali!");
}
}
}
}
public function Start_Firewall(){
if ($this->Is_Blocked($_SERVER["REMOTE_ADDR"])==true) {
$this->Message("<font color='red'>Errore:</font> non puoi accedere al sito-web!");
}elseif($_SESSION["count"]>($this->maxTries)-1){
$this->UserBlock();
}else{
$this->Stop_Flood_Attack();
$this->Stop_Post_Attack();
$this->Stop_Get_Attack();
echo "<!-- This firewall is created by walker.ultimate -->\n";
}
}
}
$Firewall=new Firewall();
$Firewall->Start_Firewall();
?>
Per attivarlo nel vostro script, nella prima RIGA prima che inizi lo script inserite un bel
PHP:
include("NomeFileDelFirewall.php");
Buonagiornata.



