Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////
- /* ATTACK AUTOMATION TOOL FOR SAPHEADS */
- ////////////////////////////////////////////////////
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/tcp.h>
- #include <arpa/inet.h>
- #include <netinet/in.h>
- #include <netdb.h>
- ////////////////////////////////
- /* SERVER CONFIGURATION */
- ////////////////////////////////
- char *servers[] =
- {
- "10.10.1.1",
- "10.10.2.1",
- "10.10.3.1",
- "10.10.4.1"
- };
- int port=4444;
- /////////////////////////
- /* NEEDLE FUNCTION */
- /////////////////////////
- //cd: socket desc.
- int needle(int cd){
- char buf[128];
- strcpy(buf, "Hello World!");
- send(cd, &buf, strlen(buf), 0);
- return 0;
- }
- //////////////////////
- /* MAIN FUNCTION */
- //////////////////////
- int main()
- {
- struct sockaddr_in sin;
- struct hostent * he;
- size_t socklen;
- int sockfd;
- int nServer;
- int i,j,k;
- nServer=sizeof(servers)/sizeof(int);
- printf("[=] Attack Automation Tool - Sapheads \n");
- printf("[=] --------------------------------\n");
- //iterate on servers
- for(i=0;i<nServer;i++)
- {
- printf("[+] #%d: Trying to connect to %s...\n", i+1, servers[i]);
- //determine address by name
- if ((he = gethostbyname(servers[i])) == NULL)
- {
- printf("[-] Failed to determine the host\n");
- continue;
- }
- //connect to server
- memset((void*)&sin, 0, sizeof(struct sockaddr_in));
- sin.sin_family = PF_INET;
- memcpy((void*)&sin.sin_addr,he->h_addr_list[0],sizeof(struct in_addr));
- sin.sin_port = htons(port);
- bzero((void*)&(sin.sin_zero), 8);
- //server socket
- if ((sockfd = socket(PF_INET,SOCK_STREAM,0))<0)
- {
- printf("[-] Failed to set up socket descriptor\n");
- continue;
- }
- //connect to server
- if(connect(sockfd, (struct sockaddr *) &sin, (size_t)socklen)==-1)
- {
- printf("[-] Failed to connect to the server\n");
- continue;
- }
- printf("[+] Attack on the server started.\n");
- //Attack the server!
- needle(sockfd);
- close(sockfd);
- }
- printf("[=] Attack Automation is finished\n");
- return 0;
- }
Add Comment
Please, Sign In to add comment