Guest User

Untitled

a guest
Jun 22nd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. ////////////////////////////////////////////////////
  2. /* ATTACK AUTOMATION TOOL FOR SAPHEADS */
  3. ////////////////////////////////////////////////////
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <sys/types.h>
  9. #include <sys/socket.h>
  10. #include <netinet/tcp.h>
  11. #include <arpa/inet.h>
  12. #include <netinet/in.h>
  13. #include <netdb.h>
  14.  
  15. ////////////////////////////////
  16. /* SERVER CONFIGURATION */
  17. ////////////////////////////////
  18.  
  19. char *servers[] =
  20. {
  21. "10.10.1.1",
  22. "10.10.2.1",
  23. "10.10.3.1",
  24. "10.10.4.1"
  25. };
  26.  
  27. int port=4444;
  28.  
  29. /////////////////////////
  30. /* NEEDLE FUNCTION */
  31. /////////////////////////
  32. //cd: socket desc.
  33.  
  34. int needle(int cd){
  35.  
  36. char buf[128];
  37. strcpy(buf, "Hello World!");
  38. send(cd, &buf, strlen(buf), 0);
  39.  
  40. return 0;
  41. }
  42.  
  43. //////////////////////
  44. /* MAIN FUNCTION */
  45. //////////////////////
  46.  
  47. int main()
  48. {
  49.  
  50. struct sockaddr_in sin;
  51. struct hostent * he;
  52. size_t socklen;
  53. int sockfd;
  54. int nServer;
  55. int i,j,k;
  56. nServer=sizeof(servers)/sizeof(int);
  57.  
  58. printf("[=] Attack Automation Tool - Sapheads \n");
  59. printf("[=] --------------------------------\n");
  60.  
  61. //iterate on servers
  62. for(i=0;i<nServer;i++)
  63. {
  64.  
  65. printf("[+] #%d: Trying to connect to %s...\n", i+1, servers[i]);
  66.  
  67. //determine address by name
  68. if ((he = gethostbyname(servers[i])) == NULL)
  69. {
  70. printf("[-] Failed to determine the host\n");
  71. continue;
  72. }
  73.  
  74. //connect to server
  75. memset((void*)&sin, 0, sizeof(struct sockaddr_in));
  76. sin.sin_family = PF_INET;
  77. memcpy((void*)&sin.sin_addr,he->h_addr_list[0],sizeof(struct in_addr));
  78. sin.sin_port = htons(port);
  79. bzero((void*)&(sin.sin_zero), 8);
  80.  
  81. //server socket
  82. if ((sockfd = socket(PF_INET,SOCK_STREAM,0))<0)
  83. {
  84. printf("[-] Failed to set up socket descriptor\n");
  85. continue;
  86. }
  87.  
  88. //connect to server
  89. if(connect(sockfd, (struct sockaddr *) &sin, (size_t)socklen)==-1)
  90. {
  91. printf("[-] Failed to connect to the server\n");
  92. continue;
  93. }
  94.  
  95. printf("[+] Attack on the server started.\n");
  96.  
  97. //Attack the server!
  98. needle(sockfd);
  99.  
  100. close(sockfd);
  101.  
  102. }
  103.  
  104. printf("[=] Attack Automation is finished\n");
  105.  
  106. return 0;
  107.  
  108. }
Add Comment
Please, Sign In to add comment