DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

SockVortx.cpp

02.01.2008
| 980 views |
  • submit to reddit
        #include <stdio.h>
#include <winsock2.h>

int main(int argc, char *argv[]) {
	WSADATA wd;
	SOCKET s;
	SOCKADDR_IN addr;
	HOSTENT* he;
	unsigned int tmp,sol,i;
	char pwd[256];
	
	printf("[-] pulltheplug vortex - level0\n   by netfish\n\n");
	
	// winsock start
	if (WSAStartup(MAKEWORD(2,0),&wd))
		return 0;
	printf("[-] Winsock Started\n");
	
	if (!(s = socket(AF_INET,SOCK_STREAM,0)))
		return 0;
	printf("[-] Socket Initialization\n");
	
	// Connect 
	memset(&addr,0,sizeof(SOCKADDR_IN));
	addr.sin_family = AF_INET;
	addr.sin_port = htons(5842);
	addr.sin_addr.s_addr = inet_addr("69.55.233.82");
	
	if 
((connect(s,(SOCKADDR_IN*)&addr,sizeof(SOCKADDR_IN)))==SOCKET_ERROR)
		return 0;
	printf("[-] Socket Connection Accomplished!\n");
	
	// integer hohlen
	sol=0;
	for (i=0;i!=4;i++) {
		recv(s,&tmp,sizeof(unsigned int),0);
		sol += tmp;
	}
	printf("[-] integer \n Sum: %i\n",sol);
	
	send(s,&sol,sizeof(unsigned int),0);
	recv(s,&pwd,255,0);
	printf("[-] pwd:\n%s",pwd);
	return 0;
}