Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "main.h"
- int main(int argc, char *argv[])
- {
- if (argc != 2) { return 1; }
- int port = atoi(argv[1]);
- WSADATA wsaData; SOCKET sock;
- wsaData = WSAStartup(MAKEWORD(2,2), &wsaData);
- sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == INVALID_SOCKET) { WSACleanup(); return 1; }
- sockaddr_in service;
- service.sin_family = AF_INET;
- service.sin_addr.s_addr = inet_addr("127.0.0.1");
- service.sin_port = htons(port);
- if (bind(sock, (SOCKADDR)&service, sizeof(service)) == SOCKET_ERROR)
- {
- closesocket(sock);
- return 1;
- }
- if (listen(sock, 1) == SOCKET_ERROR) { return 1; }
- SOCKET acceptSock;
- int bytesSent; int bytesRecv = SOCKET_ERROR;
- char sendbuff[1] = "0"; char recvbuff[9] = "";
- while (1)
- {
- acceptSock = SOCKET_ERROR;
- while (acceptSock == SOCKET_ERROR)
- {
- acceptSock = accept(sock, NULL, NULL);
- }
- bytesRecv = recv(acceptSock, recvbuff, 9, 0);
- if (bytesRecv != SOCKET_ERROR)
- {
- DWORD targs[3];
- targs[0] = atoi(recvbuff[0]);
- char tempbuff[4];
- tempbuff[0] = recvbuff[1];
- tempbuff[1] = recvbuff[2];
- tempbuff[2] = recvbuff[3];
- tempbuff[3] = recvbuff[4];
- targs[1] = atoi(tempbuff);
- tempbuff[0] = recvbuff[5];
- tempbuff[1] = recvbuff[6];
- tempbuff[2] = recvbuff[7];
- tempbuff[3] = recvbuff[8];
- targs[2] = atoi(tempbuff);
- doAct(targs);
- }
- }
- return 0;
- }
- int doAct(DWORD args[])
- {
- if (args[0] == -1 || args[1] == -1 || args[2] == -1) { return 0; }
- if (args[0] == ACT_KEYBOARD_PRESS && args[1] != -1 && args[2] != -1)
- {
- keybd_event(args[1], NULL, 0, NULL);
- Sleep(args[2]);
- keybd_event(args[1], NULL, KEYEVENTF_KEYUP, NULL);
- return 1;
- }
- else if (args[0] == ACT_KEYBOARD_DOWN && args[1] != -1)
- {
- keybd_event(args[1], NULL, 0, NULL);
- return 1;
- }
- else if (args[0] == ACT_KEYBOARD_UP && args[1] != -1)
- {
- keybd_event(args[1], NULL, KEYEVENTF_KEYUP, NULL);
- return 1;
- }
- else if (args[0] == ACT_MOUSE_CLICK && args[1] != -1 && args[2] != -1)
- {
- switch(args[1])
- {
- case 1:
- mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
- Sleep(args[2]);
- mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
- break;
- case 2:
- mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
- Sleep(args[2]);
- mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
- break;
- case 3:
- mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
- Sleep(args[2]);
- mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
- break;
- }
- return 1;
- }
- else if (args[0] == ACT_MOUSE_MOVE && args[1] != -1 && args[2] != -1)
- {
- SetCursorPos(args[1], args[2]);
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement