Merge pull request #632 from milo2012/master
Fixes Issue 567: if browser != Chrome, an unsigned java applet is injected in the DOM to verify if Java is really enabled and working.
This commit is contained in:
@@ -499,11 +499,33 @@ beef.browser = {
|
||||
*
|
||||
* @example: if(beef.browser.hasJava()) { ... }
|
||||
*/
|
||||
|
||||
hasJava: function() {
|
||||
if(!this.type().IE && window.navigator.javaEnabled && window.navigator.javaEnabled()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
//If chrome detected, return false. Do not run java applet
|
||||
if(beef.browser.isC()){
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
//Create java applet here and test for execution
|
||||
var applet_archive = 'http://'+beef.net.host+ ':' + beef.net.port + '/demos/checkJava.jar';
|
||||
var applet_id = 'checkJava';
|
||||
var applet_name = 'checkJava';
|
||||
var output;
|
||||
beef.dom.attachApplet(applet_id, 'Microsoft_Corporation', 'checkJava' ,
|
||||
null, applet_archive, null);
|
||||
output = document.Microsoft_Corporation.getInfo();
|
||||
beef.dom.detachApplet('checkJava');
|
||||
if(output=1){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}return false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
beef.net.local = {
|
||||
|
||||
sock: false,
|
||||
checkJava: false,
|
||||
hasJava: false,
|
||||
|
||||
/**
|
||||
* Initializes the java socket. We have to use this method because
|
||||
@@ -29,16 +31,30 @@ beef.net.local = {
|
||||
* is invalid:
|
||||
* sock: new java.net.Socket();
|
||||
*/
|
||||
|
||||
initializeSocket: function() {
|
||||
if(! beef.browser.hasJava()) return -1;
|
||||
|
||||
try {
|
||||
this.sock = new java.net.Socket();
|
||||
} catch(e) {
|
||||
return -1;
|
||||
if(this.checkJava){
|
||||
if(!beef.browser.hasJava()) {
|
||||
this.checkJava=True;
|
||||
this.hasJava=False;
|
||||
return -1;
|
||||
}else{
|
||||
this.checkJava=True;
|
||||
this.hasJava=True;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(!this.hasJava) return -1;
|
||||
else{
|
||||
try {
|
||||
this.sock = new java.net.Socket();
|
||||
} catch(e) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -47,7 +63,7 @@ beef.net.local = {
|
||||
* @error: return -1 if the internal ip cannot be retrieved.
|
||||
*/
|
||||
getLocalAddress: function() {
|
||||
if(! beef.browser.hasJava()) return false;
|
||||
if(!this.hasJava) return false;
|
||||
|
||||
this.initializeSocket();
|
||||
|
||||
@@ -65,7 +81,7 @@ beef.net.local = {
|
||||
* @error: return -1 if the hostname cannot be retrieved.
|
||||
*/
|
||||
getLocalHostname: function() {
|
||||
if(! beef.browser.hasJava()) return false;
|
||||
if(!this.hasJava) return false;
|
||||
|
||||
this.initializeSocket();
|
||||
|
||||
@@ -79,4 +95,4 @@ beef.net.local = {
|
||||
|
||||
};
|
||||
|
||||
beef.regCmp('beef.net.local');
|
||||
beef.regCmp('beef.net.local');
|
||||
|
||||
BIN
extensions/demos/html/checkJava.class
Normal file
BIN
extensions/demos/html/checkJava.class
Normal file
Binary file not shown.
BIN
extensions/demos/html/checkJava.jar
Normal file
BIN
extensions/demos/html/checkJava.jar
Normal file
Binary file not shown.
19
extensions/demos/html/checkJava.java
Executable file
19
extensions/demos/html/checkJava.java
Executable file
@@ -0,0 +1,19 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.net.*;
|
||||
import java.applet.*;
|
||||
|
||||
// Keith Lee
|
||||
// Twitter: @keith55
|
||||
// http://milo2012.wordpress.com
|
||||
// keith.lee2012[at]gmail.com
|
||||
|
||||
public class checkJava extends Applet{
|
||||
public static int results = 0;
|
||||
public void init() {
|
||||
}
|
||||
public int getInfo() {
|
||||
results = 1;
|
||||
return results;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user