elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: 1 ... 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [32] 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ... 138
311  Programación / PHP / Re: Conocer id de un registro antes de insertarlo en: 6 Junio 2009, 18:22 pm
Pues mete los id's de los nombres de tus archivos a una matriz, con explode cortas los id's, con sort() las ordenas y por último tomas el 0 (el primero).

How To Sort Files Of A Directory using Php
http://www.trap17.com/index.php/Sort-Files-Directory-Php_t36366.html

sort
http://www.php.net/sort

Se te agradecerá que cuando hayas encontrado la solución la postees aquí  ;)

Suerte
312  Programación / PHP / NST Web Based Anti-DoS v0.1 en: 6 Junio 2009, 07:15 am
Código
  1. <?
  2. /*
  3. /************************************************************
  4. /                                                                                                        
  5. /           NST Anti Denial of Service Script  v 0.1                                          
  6. /                                                                                                        
  7. /                                                                                                        
  8. /                                                                                                        
  9. /             Author: Link   < link07@gmail.com >                              
  10. /                                                                                                        
  11. /              ..::[N]eo [S]ecurity [T]eam::..                                          
  12. /                                                                                                          
  13. /              http://www.neosecurityteam.net    
  14. /
  15. /                   Date:  October - 2006                
  16. /                                                                                                          
  17. /                                                                                                          
  18. /*************************************************************
  19.  
  20.  
  21.      This script will prevent Dos and DDos attacks using request flood
  22.      of http packets, that causes your server to excecute to much connections
  23.      with the database and execute tha php interpreter a lot of times in a few
  24.      seconds, all you have to do to install this is include it in a script that
  25.      all your scripts use , an script for the database connection for example
  26.      and create three empty txt files on the same folder with write and read
  27.      permissions: log.txt , bans.txt , counter.txt
  28.      This script will ban users using the .htaccess file, so dont forget to put
  29.      this is script on the same folder as the .htaccess file as well
  30.      It is very configurable just modify the parameters indicated below , to
  31.      asign how sctrict the script will act.  
  32.  
  33. */
  34.  
  35. $data = "";
  36.  
  37. $ban = "";
  38.  
  39. $visits = 1;
  40.  
  41. $error = 0;
  42.  
  43. $ahora = date("Y-n-j H:i:s");
  44.  
  45. $safemode = 0;
  46.  
  47. $new = "";
  48.  
  49. $flooder =0;
  50.  
  51. $registered = 0;
  52.  
  53. $wwwdir = "/home/neosecur/public_html/";
  54.  
  55. $ahora = date("Y-n-j H:i:s");
  56.  
  57. if(!$file = @fopen($wwwdir."log.txt","r"))
  58.  
  59. $error = 1;
  60.  
  61. while (!@feof($file))
  62.  
  63. {
  64.  
  65. $data .= @fgets($file);
  66.  
  67. }
  68.  
  69. $visitor = explode("\n",$data);
  70.  
  71. $i=0;
  72.  
  73. while($visitor[$i])
  74.  
  75. {
  76.  
  77. $iptime = explode("@",$visitor[$i]);
  78.  
  79. if ($_SERVER['REMOTE_ADDR'] == $iptime[0])
  80.  
  81. {
  82.  
  83.  
  84.  
  85. $tiempo = strtotime($ahora) - $iptime[1];
  86.  
  87. if ($tiempo <= 1)  // this line controls the acces of an ip, only one request during the number of seconds you replace here
  88.  
  89. {
  90.  
  91. $safemode = 1;
  92.  
  93.  
  94. $flooder = 1;
  95.  
  96. }
  97.  
  98.  
  99. $iptime[1]=strtotime($ahora);
  100.  
  101.  
  102.  
  103.  
  104.  
  105. $registered = 1;
  106.  
  107. }
  108.  
  109. $new .=$iptime[0]."@".$iptime[1]."\n";
  110.  
  111. $i++;
  112.  
  113. }
  114.  
  115.  
  116. if (!$registered)
  117.  
  118. $new.=$_SERVER['REMOTE_ADDR']."@".strtotime($ahora)."\n";
  119.  
  120.  
  121.  
  122. if (!@fclose($file))
  123.  
  124. $error = 1;
  125.  
  126.  
  127.  
  128. if(!$file = @fopen($wwwdir."log.txt","wt"))
  129.  
  130. $error = 1;
  131.  
  132.  
  133.  
  134. @fwrite($file,$new);
  135.  
  136. if (!@fclose($file))
  137.  
  138. $error = 1;
  139.  
  140.  
  141.  
  142. if (!$fcount = @fopen($wwwdir."counter.txt","rt"))
  143.  
  144. $error = 1;
  145.  
  146. $vst = @fgets($fcount);
  147.  
  148. $count = explode("@",$vst);
  149.  
  150. if (strtotime($ahora) == $count[1])
  151.  
  152. {
  153.  
  154. $visits = $count[0] + 1;
  155.  
  156. $count[0] = $visits;
  157.  
  158. }
  159.  
  160. else
  161.  
  162. {
  163.  
  164. $count[0] = 1;
  165.  
  166. $count[1] = strtotime($ahora);
  167.  
  168. }
  169.  
  170. if (!@fclose($fcount))
  171.  
  172. $error = 1;
  173.  
  174.  
  175.  
  176. $new = $count[0]."@".$count[1];
  177.  
  178.  
  179.  
  180. if (!$fcount = @fopen($wwwdir."counter.txt","wt"))
  181.  
  182. $error = 1;
  183.  
  184.  
  185.  
  186. @fwrite($fcount,$new);
  187.  
  188.  
  189.  
  190. if (!@fclose($fcount))
  191.  
  192. $error = 1;
  193.  
  194.  
  195.  
  196.  
  197. $new = "";
  198.  
  199. $registered = 0;
  200.  
  201.  
  202.  
  203. 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
  204.  
  205. {
  206.  
  207. $safemode = 1;
  208.  
  209. if ($flooder)
  210.  
  211. {
  212.  
  213. if (!$fban = @fopen($wwwdir."bans.txt","rt")) $error = 1;
  214.  
  215. while (!@feof($fban))
  216.  
  217. {
  218.  
  219. $ban .= @fgets($fban);
  220.  
  221. }
  222.  
  223. $ips = explode ("\n",$ban);
  224.  
  225. $i=0;
  226.  
  227. while ($ips[$i])
  228.  
  229. {
  230.  
  231. if ($_SERVER['REMOTE_ADDR'] == $ips[$i])
  232.  
  233. $registered = 1;
  234.  
  235. $i++;
  236.  
  237. $new .=$ips[$i];
  238.  
  239. }
  240.  
  241. if (!@fclose($fban)) $error = 1;
  242.  
  243.  
  244.  
  245. if (!$registered)
  246.  
  247. {
  248.  
  249. if (!$fban = @fopen($wwwdir."bans.txt","wt")) $error = 1;
  250.  
  251. $new .=$_SERVER['REMOTE_ADDR']."\n";
  252.  
  253. @fwrite($fban,$new);
  254.  
  255. if (!@fclose($fban)) $error = 1;
  256.  
  257. }
  258.  
  259. else
  260.  
  261. {
  262.  
  263. if (!$fht = @fopen($wwwdir.".htaccess","rt"))
  264.  
  265. $error = 1;
  266.  
  267. $cont = "";
  268. $cont2 = "";
  269. $eob = 0;
  270. while (!@feof($fht))
  271.  
  272. {
  273.  
  274. $a = @fgets($fht);
  275.  
  276. if ($eob)
  277. $cont2.=$a;
  278. else
  279. {
  280. if ($a == "</Limit>\r\n" or $a == "</Limit>" or $a == "</Limit>\n")
  281. {
  282. $eob = 1;
  283. $cont2.=$a;
  284. }
  285. else
  286. $cont.=$a;
  287. }
  288.  
  289. }
  290.  
  291.  
  292.  
  293. if (!@fclose($fht))
  294.  
  295. $error = 1;
  296.  
  297. if (!$fht = @fopen($wwwdir.".htaccess","wt"))
  298.  
  299. $error = 1;
  300.  
  301.  
  302. $cont .= "Deny from ".$_SERVER['REMOTE_ADDR']."\n";
  303. $cont .= $cont2;
  304.  
  305. @fwrite($fht,$cont);
  306.  
  307. if (!@fclose($fht))
  308.  
  309. $error = 1;
  310.  
  311. }
  312.  
  313. }
  314.  
  315.  
  316. }
  317.  
  318.  
  319. if ($error)
  320.  
  321. {
  322.  
  323. echo "ocurrio un error inesperado por favor trata actualizando de nuevo o vuelve en un rato. Gracias por tu comprensión.";
  324.  
  325. exit(0);
  326.  
  327. }
  328.  
  329. if($safemode)
  330.  
  331. {
  332.  
  333. echo '<META HTTP-EQUIV="Refresh" CONTENT="2;URL=">';
  334.  
  335. exit(0);
  336.  
  337. }
  338.  
  339.  
  340.  
  341. // if no restrictions have been activated , the content of the web will be displayed normally
  342. //echo "contenido";
  343. ?>
313  Programación / PHP / Re: Obtener la MAC en: 5 Junio 2009, 00:41 am
Para eso se ejecuta arp con shell_exec()

Citar
Código
  1. // Get the arp executable path
  2. $location = `which arp`;
  3. // Execute the arp command and store the output in $arpTable
  4. $arpTable = `$location`;

http://es.wikipedia.org/wiki/Address_Resolution_Protocol

;)

OK, no lo veo en el código.  :huh: (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:

Código
  1. <?
  2. function returnMacAddress() {
  3. // This code is under the GNU Public Licence
  4. // Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
  5. // Tested only on linux, please report bugs
  6.  
  7. // WARNING: the commands 'which' and 'arp' should be executable
  8. // by the apache user; on most linux boxes the default configuration
  9. // should work fine
  10.  
  11. // Get the arp executable path
  12. $location = `which arp`;
  13. // Execute the arp command and store the output in $arpTable
  14. $arpTable = `$location`;
  15. // Split the output so every line is an entry of the $arpSplitted array
  16. $arpSplitted = split("\n",$arpTable);
  17. // Get the remote ip address (the ip address of the client, the browser)
  18. $remoteIp = $GLOBALS['REMOTE_ADDR'];
  19. // Cicle the array to find the match with the remote ip address
  20. foreach ($arpSplitted as $value) {
  21. // Split every arp line, this is done in case the format of the arp
  22. // command output is a bit different than expected
  23. $valueSplitted = split(" ",$value);
  24. foreach ($valueSplitted as $spLine) {
  25. if (preg_match("/$remoteIp/",$spLine)) {
  26. $ipFound = true;
  27. }
  28. // The ip address has been found, now rescan all the string
  29. // to get the mac address
  30. if ($ipFound) {
  31. // Rescan all the string, in case the mac address, in the string
  32. // returned by arp, comes before the ip address
  33. // (you know, Murphy's laws)
  34. reset($valueSplitted);
  35. foreach ($valueSplitted as $spLine) {
  36. if (preg_match("/[0-9a-f][0-9a-f][:-]".
  37. "[0-9a-f][0-9a-f][:-]".
  38. "[0-9a-f][0-9a-f][:-]".
  39. "[0-9a-f][0-9a-f][:-]".
  40. "[0-9a-f][0-9a-f][:-]".
  41. "[0-9a-f][0-9a-f]/i",$spLine)) {
  42. return $spLine;
  43. }
  44. }
  45. }
  46. $ipFound = false;
  47. }
  48. }
  49. return false;
  50. }
  51. ?>
  52.  

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) :xD

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:

Código
  1. echo addslashes__recursive($tuvariable);

Aunque en ese código ya esta siendo utilizada en todas las superglobales.

Saludos, Dacan  :D

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...

Código
  1. //----------------------------------------------+
  2. // We claer all traffic of our server |
  3. //----------------------------------------------+
  4. // This function I extrac of SMF system fourum, cleared all " and ' in traffic server
  5. function addslashes__recursive($var){
  6. if (!is_array($var))
  7. return addslashes($var);
  8. $new_var = array();
  9. foreach ($var as $k => $v)$new_var[addslashes($k)]=addslashes__recursive($v);
  10. return $new_var;
  11. }
  12. //If the magic quotes are disable, aplicate the function, else, do not nothing
  13. $_POST=addslashes__recursive($_POST);
  14. $_GET=addslashes__recursive($_GET);
  15. $_REQUEST=addslashes__recursive($_REQUEST);
  16. $_SERVER=addslashes__recursive($_SERVER);
  17. $_COOKIE=addslashes__recursive($_COOKIE);
  18. }
  19.  

Y pues entrado en tema... les regalo otra!:

Código
  1. // With this function, we are clear the html chars to entity ascii
  2. function clear_chars($var){
  3. if(!is_array($var)){
  4. return htmlspecialchars($var);
  5. }
  6. else{
  7. $new_var = array();
  8. foreach ($var as $k => $v){
  9. $new_var[htmlspecialchars($k)]=clear_chars($v);
  10. return $new_var;
  11. }
  12. }
  13. }
  14. if($_POST) $_POST=clear_chars($_POST);
  15. if($_GET) $_GET=clear_chars($_GET);
  16. if($_REQUEST) $_REQUEST=clear_chars($_REQUEST);
  17. if($_SERVER) $_SERVER=clear_chars($_SERVER);
  18. if($_COOKIE) $_COOKIE=clear_chars($_COOKIE);
  19.  

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?.
Páginas: 1 ... 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [32] 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ... 138
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines