Código: Seleccionar todo
package _1000_;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author adwind
*/
public class InfoAv extends Thread {
private ObjectInputStream in;
private ObjectOutputStream out;
public InfoAv(ObjectInputStream in, ObjectOutputStream out) {
this.in = in;
this.out = out;
}
private String getNameSpace() {
if (System.getProperty("os.name").startsWith("Win")) {
String SoVersion = System.getProperty("os.version");
Double version = Double.parseDouble(SoVersion);
if (version >= 6) {
return "SecurityCenter2";
} else {
return "SecurityCenter";
}
} else {
return null;
}
}
public void getInfo(String nameSpace) {
try {
out.writeUTF("##########Antivirus#########");
out.flush();
Process p = Runtime.getRuntime().exec(new String[]{"WMIC", "/Node:localhost", "/Namespace:\\\\root\\" + nameSpace, ""
+ "Path", "AntiVirusProduct", "Get", "/Format:List"});
String T;
p.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(), "Cp850"));
while ((br.ready())) {
T = br.readLine();
if (T.isEmpty()) {
continue;
}
out.writeUTF(T);
out.flush();
}
out.writeUTF("##########Firewall#########");
out.flush();
p = Runtime.getRuntime().exec(new String[]{"WMIC", "/Node:localhost", "/Namespace:\\\\root\\" + nameSpace, ""
+ "Path", "FirewallProduct", "Get", "/Format:List"});
p.waitFor();
br = new BufferedReader(new InputStreamReader(p.getInputStream(), "Cp850"));
while ((br.ready())) {
T = br.readLine();
if (T.isEmpty()) {
continue;
}
out.writeUTF(T);
out.flush();
}
} catch (Exception ex) {
System.out.println("termina");
System.out.println(ex.getMessage());
}
}
public void run() {
String tmp = getNameSpace();
if (tmp == null) {
try {
out.writeUTF("Error dont support");
out.flush();
} catch (IOException ex) {
Logger.getLogger(InfoAv.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
getInfo(tmp);
}
try {
while (true) {
String texto = in.readUTF();
}
} catch (IOException ex) {
// Logger.getLogger(mensaje.class.getName()).log(Level.SEVERE, null, ex);
}
}
}