|
312
|
Programación / PHP / NST Web Based Anti-DoS v0.1
|
en: 6 Junio 2009, 07:15 am
|
<? /* /************************************************************ / / NST Anti Denial of Service Script v 0.1 / / / / Author: Link < link07@gmail.com > / / ..::[N]eo [S]ecurity [T]eam::.. / / http://www.neosecurityteam.net / / Date: October - 2006 / / /************************************************************* This script will prevent Dos and DDos attacks using request flood of http packets, that causes your server to excecute to much connections with the database and execute tha php interpreter a lot of times in a few seconds, all you have to do to install this is include it in a script that all your scripts use , an script for the database connection for example and create three empty txt files on the same folder with write and read permissions: log.txt , bans.txt , counter.txt This script will ban users using the .htaccess file, so dont forget to put this is script on the same folder as the .htaccess file as well It is very configurable just modify the parameters indicated below , to asign how sctrict the script will act. */ $data = ""; $ban = ""; $visits = 1; $error = 0; $ahora = date("Y-n-j H:i:s"); $safemode = 0; $new = ""; $flooder =0; $registered = 0; $wwwdir = "/home/neosecur/public_html/"; $ahora = date("Y-n-j H:i:s"); if(!$file = @fopen($wwwdir."log.txt","r")) $error = 1; { } $i=0; while($visitor[$i]) { $iptime = explode("@",$visitor[$i]); if ($_SERVER['REMOTE_ADDR'] == $iptime[0]) { if ($tiempo <= 1) // this line controls the acces of an ip, only one request during the number of seconds you replace here { $safemode = 1; $flooder = 1; } $registered = 1; } $new .=$iptime[0]."@".$iptime[1]."\n"; $i++; } if (!$registered) $new.=$_SERVER['REMOTE_ADDR']."@".strtotime($ahora)."\n"; $error = 1; if(!$file = @fopen($wwwdir."log.txt","wt")) $error = 1; $error = 1; if (!$fcount = @fopen($wwwdir."counter.txt","rt")) $error = 1; { $visits = $count[0] + 1; $count[0] = $visits; } else { $count[0] = 1; } $error = 1; $new = $count[0]."@".$count[1]; if (!$fcount = @fopen($wwwdir."counter.txt","wt")) $error = 1; $error = 1; $new = ""; $registered = 0; if ($visits > 4) // this line controls visits during a second, it is used to prevent ddos attacks you can modify this depending on the capacity of your server { $safemode = 1; if ($flooder) { if (!$fban = @fopen($wwwdir."bans.txt","rt")) $error = 1; { } $i=0; while ($ips[$i]) { if ($_SERVER['REMOTE_ADDR'] == $ips[$i]) $registered = 1; $i++; $new .=$ips[$i]; } if (!@fclose($fban)) $error = 1; if (!$registered) { if (!$fban = @fopen($wwwdir."bans.txt","wt")) $error = 1; $new .=$_SERVER['REMOTE_ADDR']."\n"; if (!@fclose($fban)) $error = 1; } else { if (!$fht = @fopen($wwwdir.".htaccess","rt")) $error = 1; $cont = ""; $cont2 = ""; $eob = 0; { if ($eob) $cont2.=$a; else { if ($a == "</Limit>\r\n" or $a == "</Limit>" or $a == "</Limit>\n") { $eob = 1; $cont2.=$a; } else $cont.=$a; } } $error = 1; if (!$fht = @fopen($wwwdir.".htaccess","wt")) $error = 1; $cont .= "Deny from ".$_SERVER['REMOTE_ADDR']."\n"; $cont .= $cont2; $error = 1; } } } if ($error) { echo "ocurrio un error inesperado por favor trata actualizando de nuevo o vuelve en un rato. Gracias por tu comprensión."; } if($safemode) { echo '<META HTTP-EQUIV="Refresh" CONTENT="2;URL=">'; } // if no restrictions have been activated , the content of the web will be displayed normally //echo "contenido"; ?>
|
|
|
313
|
Programación / PHP / Re: Obtener la MAC
|
en: 5 Junio 2009, 00:41 am
|
OK, no lo veo en el código. (la función...). No, no es desafiarme.. naaaaa... que va, solo que no veo la función.
|
|
|
314
|
Programación / PHP / Re: Obtener la MAC
|
en: 4 Junio 2009, 20:12 pm
|
Bueno buscando encontre esto: <? function returnMacAddress() { // This code is under the GNU Public Licence // Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com // Tested only on linux, please report bugs // WARNING: the commands 'which' and 'arp' should be executable // by the apache user; on most linux boxes the default configuration // should work fine // Get the arp executable path $location = `which arp`; // Execute the arp command and store the output in $arpTable $arpTable = `$location`; // Split the output so every line is an entry of the $arpSplitted array $arpSplitted = split("\n",$arpTable); // Get the remote ip address (the ip address of the client, the browser) $remoteIp = $GLOBALS['REMOTE_ADDR']; // Cicle the array to find the match with the remote ip address foreach ($arpSplitted as $value) { // Split every arp line, this is done in case the format of the arp // command output is a bit different than expected $valueSplitted = split(" ",$value); foreach ($valueSplitted as $spLine) { $ipFound = true; } // The ip address has been found, now rescan all the string // to get the mac address if ($ipFound) { // Rescan all the string, in case the mac address, in the string // returned by arp, comes before the ip address // (you know, Murphy's laws) foreach ($valueSplitted as $spLine) { "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f]/i",$spLine)) { return $spLine; } } } $ipFound = false; } } return false; } ?>
Pero necesitas tener un servidor dedicado donde puedas activar shell_exec(). Creo que lo mismo pasa para otros scripts... Saludos Donde usas shell_exec???
|
|
|
315
|
Programación / PHP / Re: Comillas en PHP
|
en: 4 Junio 2009, 17:20 pm
|
uy el señor moderador de bugs a nivel web viene a confirmarnos el rendimiento (F) aaaaa mmmmiiiii qqqquuuueee mmmmeeee cccooonffffiiirrrmmmeee eeesstttaaaa (viva el albur mexicano xD)
|
|
|
316
|
Programación / PHP / Re: Obtener la MAC
|
en: 4 Junio 2009, 17:19 pm
|
mmm sí... php es de lado server. Busca algo hecho en java (no js), seguro hay pero es violar la privacidad...
|
|
|
317
|
Programación / PHP / Re: Pequeños trucos en PHP
|
en: 4 Junio 2009, 17:15 pm
|
Es para poner slashes del tipo (\) y se usa: echo addslashes__recursive($tuvariable);
Aunque en ese código ya esta siendo utilizada en todas las superglobales. Saludos, Dacan Exactirijillo xD, así es, con eso se cepilla todo lo que entra y sale a través del server/php. Aunque si tienes las magic quotes te va a poner tripe \ xD tons le cambié algo... //----------------------------------------------+ // We claer all traffic of our server | //----------------------------------------------+ // This function I extrac of SMF system fourum, cleared all " and ' in traffic server function addslashes__recursive($var){ foreach ($var as $k => $v)$new_var[addslashes($k)]=addslashes__recursive ($v); return $new_var; } //If the magic quotes are disable, aplicate the function, else, do not nothing $_POST=addslashes__recursive($_POST); $_GET=addslashes__recursive($_GET); $_REQUEST=addslashes__recursive($_REQUEST); $_SERVER=addslashes__recursive($_SERVER); $_COOKIE=addslashes__recursive($_COOKIE); }
Y pues entrado en tema... les regalo otra!: // With this function, we are clear the html chars to entity ascii function clear_chars($var){ } else{ foreach ($var as $k => $v){ return $new_var; } } } if($_POST) $_POST=clear_chars($_POST); if($_GET) $_GET=clear_chars($_GET); if($_REQUEST) $_REQUEST=clear_chars($_REQUEST); if($_SERVER) $_SERVER=clear_chars($_SERVER); if($_COOKIE) $_COOKIE=clear_chars($_COOKIE);
Suerte
|
|
|
318
|
Programación / PHP / Re: Web Services en PHP
|
en: 2 Junio 2009, 00:18 am
|
es que creo el xml pero como invoco el servicio web services para ser recogido esta información que se genero a traves de php a xml, como llamo al web services esoo
Con un arreglo de métodos y parámetros, vas a consumir de X tecnologia hacia PHP?
|
|
|
319
|
Programación / PHP / Re: error al hacer una variable
|
en: 1 Junio 2009, 00:05 am
|
no me ha servid pero e terminado por enviar el contenido del archivo mediante formulario y funciona bien otra cosa se puede hacer que cada x tiempo se abra un archivo y se imprima en una pagina?? seria mezclando javascript y php creo, pero no se como hacerlo
Con ajax
|
|
|
320
|
Programación / PHP / Re: Web Services en PHP
|
en: 1 Junio 2009, 00:04 am
|
Saludos como estan....tengo una duda grande, he tratado por todos los medios tratar de mandar información a traves de php a un Web Services mandando datos de un formulario y estos recogido en php y tranformandolos en un xml, lo malo es que no me funciona el web service que tiene el cliente, posiblemente no se como se hace.. por eso necesito ayuda solamente necesito mandar la información xml al web service nada mas no quiero recuperar datos de el...solo envio
gracias
Y la duda... ¿es?.
|
|
|
|
|
|
|