Path: blob/master/extensions/admin_ui/media/javascript/ui/common/beef_common.js
1155 views
//1// Copyright (c) 2006-2025 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56/*!7* BeEF Web UI commons8*/910if(typeof beefwui === 'undefined' && typeof window.beefwui === 'undefined') {1112var BeefWUI = {1314rest_token: "",15hooked_browsers: {},1617/**18* Retrieve the token needed to call the RESTful API.19* This is obviously a post-auth call.20*/21get_rest_token: function() {22if(this.rest_token.length == 0){23var url = "<%= @base_path %>/modules/getRestfulApiToken.json";24jQuery.ajax({25contentType: 'application/json',26dataType: 'json',27type: 'GET',28url: url,29async: false,30processData: false,31success: function(data){32beefwui.rest_token = data.token;33},34error: function(){35beefwui.rest_token = "";36}37});38}39return this.rest_token;40},4142/**43* Get hooked browser ID from session44*/45get_hb_id: function(sess){46var id = "";47jQuery.ajax({48type: 'GET',49url: "/api/hooks/?token=" + this.get_rest_token(),50async: false,51processData: false,52success: function(data){53for (var k in data['hooked-browsers']['online']) {54if (data['hooked-browsers']['online'][k].session === sess) {55id = data['hooked-browsers']['online'][k].id;56}57}5859if (id === "") {60for (var k in data['hooked-browsers']['offline']) {61if (data['hooked-browsers']['offline'][k].session === sess) {62id = data['hooked-browsers']['offline'][k].id;63}64}65}66},67error: function(){68commands_statusbar.update_fail("Error getting hb id");69}70});71return id;72},7374/**75* Get hooked browser info from ID76*/77get_info_from_id: function(id) {78var info = {};79jQuery.ajax({80type: 'GET',81url: "/api/hooks/?token=" + this.get_rest_token(),82async: false,83processData: false,84success: function(data){85for (var k in data['hooked-browsers']['online']) {86if (data['hooked-browsers']['online'][k].id === id) {87info = data['hooked-browsers']['online'][k];88}89}9091if (jQuery.isEmptyObject(info)) {92for (var k in data['hooked-browsers']['offline']) {93if (data['hooked-browsers']['offline'][k].id === id) {94info = data['hooked-browsers']['offline'][k];95}96}97}98},99error: function(){100commands_statusbar.update_fail("Error getting hb ip");101}102});103console.log(info);104return info;105}106};107108window.beefwui = BeefWUI;109}110111112