I'm currently building a Java app that could detect USB drive, and can identify the difference between a personal USB drive and an unauthorized USB drive by using vendor serial number, my goal is to whitelist the identified USB drive and so only the unauthorized vendor serial number is shown.
Preferably I'd like to add a feature where I could add the more authorized USB drive as a list.
SRC code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package serialnumber;
import java.nio.file.FileStore;
import java.nio.file.FileSystems;
/**
*
* @author Verdatabo
*/
public class SerialNumber {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
StringBuilder sb=new StringBuilder();
String saved_vsn ="Windows (C:) vsn:-1024236825" +"Can-a-bees (D:) vsn:-2142019920";
// while(true)
//{
for (FileStore store : FileSystems.getDefault().getFileStores())
{
sb.append(String.format("%-20s vsn:%s\n", store, store.getAttribute("volume:vsn")));
// if (!saved_vsn.equals(sb.append))
// {
// System.out.println("SKIP");
// }
System.out.println(sb.toString());
}
//}
}
}
Output:
Windows (C:) vsn:-1024236825
Windows (C:) vsn:-1024236825
Can-a-bees (D:) vsn:-2142019920
Windows (C:) vsn:-1024236825
Can-a-bees (D:) vsn:-2142019920
Fuscus (E:) vsn:1719839436
Disconnected from the target VM, address: '127.0.0.1:17429', transport: 'socket'
Process finished with exit code 0