comment
IRC Chat
play_arrow
Este sitio utiliza cookies propias y de terceros. Si continúa navegando consideramos que acepta el uso de cookies. OK Más Información.

Spread USB [C]

  • 0 Respuestas
  • 1618 Vistas

0 Usuarios y 1 Visitante están viendo este tema.

Conectado ANTRAX

  • *
  • Administrator
  • Mensajes: 5331
  • Actividad:
    60%
  • Reputación 29
  • ANTRAX
    • Ver Perfil
    • Underc0de
    • Email
  • Skype: underc0de.org
  • Twitter: @Underc0de
« en: Mayo 22, 2011, 09:59:57 pm »
Código: C
  1. #include <windows.h>
  2.  
  3. #include <stdio.h>
  4.  
  5. #define COPY_LOCATION "C:\\copy.exe"
  6.  
  7. void copyFile()
  8. {
  9.  
  10.  
  11.     char location[MAX_PATH];
  12.  
  13.     GetModuleFileName(NULL, location, MAX_PATH); // Gets the full location of the currently running process
  14.  
  15.     You are not allowed to view links. Register or Login(location); // Print it out
  16.  
  17.     FILE * original;
  18.  
  19.     original = You are not allowed to view links. Register or Login(location, "rb"); // Open the file for reading binary
  20.  
  21.     if(original == NULL) // Error opening
  22.     {
  23.  
  24.         You are not allowed to view links. Register or Login(stderr, "Error opening file [%s]\r\n", GetLastError());
  25.  
  26.         You are not allowed to view links. Register or Login();
  27.  
  28.         ExitProcess(0);
  29.  
  30.     }
  31.  
  32.     You are not allowed to view links. Register or Login(original, 0, SEEK_END); // Seek to the end of the file
  33.  
  34.     long size = You are not allowed to view links. Register or Login(original); // Get our file size
  35.  
  36.     You are not allowed to view links. Register or Login(original); // Go back to the start of the file
  37.  
  38.     char bytes[size];
  39.  
  40.     int result = You are not allowed to view links. Register or Login (bytes,1,size,original); // Read our bytes from this file
  41.  
  42.     if(result != size) // Didn't get it all
  43.     {
  44.  
  45.         You are not allowed to view links. Register or Login(stderr, "Error reading file [%s]\r\n", GetLastError());
  46.  
  47.         You are not allowed to view links. Register or Login(original);
  48.  
  49.         You are not allowed to view links. Register or Login();
  50.  
  51.         ExitProcess(0);
  52.  
  53.     }
  54.  
  55.     FILE * copied;
  56.  
  57.     copied = You are not allowed to view links. Register or Login(COPY_LOCATION, "wb"); // Open to write-binary
  58.  
  59.     int wrote = You are not allowed to view links. Register or Login(bytes, 1, size, copied);
  60.  
  61.     if(wrote != size) // Didn't write it all
  62.     {
  63.  
  64.         You are not allowed to view links. Register or Login(stderr, "Error copying file [%s]\r\n", GetLastError());
  65.  
  66.         You are not allowed to view links. Register or Login(original);
  67.  
  68.         You are not allowed to view links. Register or Login();
  69.  
  70.         ExitProcess(0);
  71.  
  72.     }
  73.  
  74.     You are not allowed to view links. Register or Login(copied); // Close copy
  75.    
  76.     You are not allowed to view links. Register or Login(original); // Close original
  77.  
  78.     You are not allowed to view links. Register or Login("Copy complete!");
  79.  
  80.     You are not allowed to view links. Register or Login();
  81.  
  82. }
  83.  
  84. int main(int argc, char **argv)
  85. {
  86.  
  87.     copyFile();
  88.  
  89. }
  90.  
« Última modificación: Febrero 08, 2014, 05:48:43 pm por Expermicid »


 

¿Te gustó el post? COMPARTILO!



Spread Kazaa

Iniciado por ANTRAX

Respuestas: 0
Vistas: 1417
Último mensaje Mayo 22, 2011, 09:57:43 pm
por ANTRAX