#include #include #include #include #include #include #include #include #include #include #include /* * vortex.labs.pulltheplug.org * port 5842 * connect() and receive 4 unsigned integers. * send() back the sum to obtain level1 user/pass * zz */ #define HOST "vortex.labs.pulltheplug.org" #define BIND_HOST "src.ip.ad.dr" #define PORT 5842 int main( void ) { struct hostent *he; struct sockaddr_in their_addr; // connector's address information struct sockaddr_in vhost; // vhost struct int sockfd; if ((he=gethostbyname(HOST)) == NULL) // lazy { herror("gethostbyname"); exit(1); } if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } their_addr.sin_family = AF_INET; // host byte order their_addr.sin_port = htons(PORT); // short, network byte order their_addr.sin_addr = *((struct in_addr *)he->h_addr); vhost.sin_addr.s_addr = ( BIND_HOST ? inet_addr(BIND_HOST) : INADDR_ANY ); // set vhost addr memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct if(bind(sockfd, (struct sockaddr *)&vhost, sizeof(vhost)) == -1 ) //bind to source address { perror("bind"); exit(1); } if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) { perror("connect"); exit(1); } int buf=0; int sum=0; int bytesin=0; // get the key bytes while( bytesin < (sizeof(int)*4) ) { bytesin+=recv(sockfd, (int*)&buf, sizeof(int), 0); if ( buf >= 0 ) { printf("[+] key value: %d!\n", buf); sum += buf; } } // send answer printf("[+] Answer: %d\n", sum ); send( sockfd, (int*)&sum, sizeof(int), 0 ); printf("[+] sent answer bytes\n"); // recv password int MAXDATA=1024; char ansbuf[MAXDATA]; memset( ansbuf, 0, MAXDATA); bytesin=0; bytesin=recv( sockfd, ansbuf, MAXDATA-1, 0 ); printf("[+] server response: %s", ansbuf); memset( ansbuf, 0, MAXDATA ); close(sockfd); return 0; }