package _VisualDVM.Passes.All; import Common.Passes.Pass; import java.io.BufferedReader; import java.io.File; import java.io.FileWriter; import java.io.InputStreamReader; public class TestPass extends Pass { public static String getMotherboardSN() { String result = ""; try { File file = File.createTempFile("realhowto",".vbs"); file.deleteOnExit(); FileWriter fw = new java.io.FileWriter(file); String vbs = "Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n" + "Set colItems = objWMIService.ExecQuery _ \n" + " (\"Select * from Win32_BaseBoard\") \n" + "For Each objItem in colItems \n" + " Wscript.Echo objItem.SerialNumber \n" + " exit for ' do the first cpu only! \n" + "Next \n"; fw.write(vbs); fw.close(); Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath()); BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream())); String line; while ((line = input.readLine()) != null) { result += line; } input.close(); } catch(Exception e){ e.printStackTrace(); } return result.trim(); } @Override protected void body() throws Exception { // String cpuId = getMotherboardSN(); // UI.Info(cpuId); /* SystemInfo systemInfo = new SystemInfo(); HardwareAbstractionLayer hardware = systemInfo.getHardware(); CentralProcessor processor = hardware.getProcessor(); CentralProcessor.ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier(); System.out.println("Processor Vendor: " + processorIdentifier.getVendor()); System.out.println("Processor Name: " + processorIdentifier.getName()); System.out.println("Processor ID: " + processorIdentifier.getProcessorID()); System.out.println("Identifier: " + processorIdentifier.getIdentifier()); System.out.println("Microarchitecture: " + processorIdentifier.getMicroarchitecture()); System.out.println("Frequency (Hz): " + processorIdentifier.getVendorFreq()); System.out.println("Frequency (GHz): " + processorIdentifier.getVendorFreq() / 1000000000.0); */ /* String serial = ""; Scanner sc = null; Process process = null; try { process = Runtime.getRuntime().exec(new String[] { "wmic", "cpu", "get", "ProcessorId" }); process.getOutputStream().close(); sc = new Scanner(process.getInputStream()); sc.next(); serial = sc.next(); } catch (IOException e) { } dummy UI.Info(Utils_.Brackets(serial)); */ /* KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); SecureRandom secureRandom = new SecureRandom(); int keyBitSize = 256; keyGenerator.init(keyBitSize, secureRandom); SecretKey secretKey = keyGenerator.generateKey(); System.out.println("===="); System.out.println(secretKey.getEncoded()); System.out.println("===="); */ } }