/* Bind socket to port 8888 on localhost */ #include #include #include #include #include #pragma comment(lib,"ws2_32.lib") //Winsock Library int My_value =(int) &VirtualAlloc; int exit1 = 0; int * pepe; int len1 = 0x1000; int main(int argc, char *argv[]) { WSADATA wsa; SOCKET s, new_socket; struct sockaddr_in server, client; int c, d; char message[]= "Hello Client , I have received your connection.\n"; char buffer[0x1000]; char bite; char desti[200]; pepe =(int *) malloc(0x2000); LoadLibraryA((LPCSTR) "MObexDll.dll"); printf("\nInitialising Winsock..."); if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) { printf("Failed. Error Code : %d", WSAGetLastError()); return 1; } printf("Initialised.\n"); //Create a socket if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { printf("Could not create socket : %d", WSAGetLastError()); } printf("Socket created.\n"); //Prepare the sockaddr_in structure server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(8888); //Bind if (bind(s, (struct sockaddr *)&server, sizeof(server)) == SOCKET_ERROR) { printf("Bind failed with error code : %d", WSAGetLastError()); } puts("Bind done"); //Listen to incoming connections listen(s, 3); //Accept and incoming connection puts("Waiting for incoming connections...port 8888"); c = sizeof(struct sockaddr_in); while (1){ new_socket = accept(s, (struct sockaddr *)&client, &c); if (new_socket == INVALID_SOCKET) { printf("accept failed with error code : %d", WSAGetLastError()); } puts("Connection accepted\n"); //Reply to client strcpy(desti, message); send(new_socket, desti, 200, 0); d = My_value; recv(new_socket, (char *)pepe, 0x2000, 0); int resul = *pepe + *(pepe + 1); printf("%x\n\n", resul); if (resul == 0xFFFFFFFF) { len1 = *(pepe + 2); exit1 = *(pepe + 3); } memcpy(buffer, (char *)pepe, len1); for (int x = 0; x < len1; x++) { bite = buffer[x]; if (bite == 0x0) { exit(1); } } if (exit1 == 0x89765432) { return 0; } } closesocket(s); WSACleanup(); return 0; }