From c40c29dd35e88313387a861457e85b0a8ff7ae56 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sun, 24 Feb 2019 11:13:41 +0000 Subject: [PATCH] AdminUI: Allow linking directly to browser #1003 --- .../media/javascript/ui/panel/PanelViewer.js | 32 +++++++++++++++++++ .../javascript/ui/panel/zombiesTreeList.js | 8 +---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/extensions/admin_ui/media/javascript/ui/panel/PanelViewer.js b/extensions/admin_ui/media/javascript/ui/panel/PanelViewer.js index eaf706aa9..a466eb5b5 100644 --- a/extensions/admin_ui/media/javascript/ui/panel/PanelViewer.js +++ b/extensions/admin_ui/media/javascript/ui/panel/PanelViewer.js @@ -32,6 +32,7 @@ Ext.onReady(function() { mainPanel ] }); + setTimeout("locationHashChanged()", 1000); new DoLogout(); }); @@ -81,3 +82,34 @@ Ext.TaskMgr.start({ interval: <%= (BeEF::Core::Configuration.instance.get("beef.extension.admin_ui.panel_update_interval") || 10).to_i * 1_000 %> }); + +/* + * Allow selecting a browser with #id= in the /ui/panel URL +*/ +function locationHashChanged() { + var id = location_hash('id'); + + if (id === null) return; + + id = id.replace(/[^a-z0-9]/gi, ''); + console.log("Loading hooked browser with ID: " + id); + mainPanel.remove(mainPanel.getComponent('current-browser')); + if(!mainPanel.getComponent('current-browser')) { + mainPanel.add(new ZombieTab({session: id})); + } + + mainPanel.activate(mainPanel.getComponent('current-browser')); + //removeHash(); +} + +function location_hash(key) { + var matches = location.hash.match(new RegExp(key+'=([^&]*)')); + return matches ? matches[1] : null; +} + +function removeHash () { + history.pushState("", document.title, window.location.pathname + window.location.search); +} + +window.onhashchange = locationHashChanged; + diff --git a/extensions/admin_ui/media/javascript/ui/panel/zombiesTreeList.js b/extensions/admin_ui/media/javascript/ui/panel/zombiesTreeList.js index fe6d7a3f2..5cd3b779d 100644 --- a/extensions/admin_ui/media/javascript/ui/panel/zombiesTreeList.js +++ b/extensions/admin_ui/media/javascript/ui/panel/zombiesTreeList.js @@ -168,13 +168,7 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, { click: function(node, e) { globalnode = node; if(!node.leaf) return; - - mainPanel.remove(mainPanel.getComponent('current-browser')); - if(!mainPanel.getComponent('current-browser')) { - mainPanel.add(new ZombieTab(node.attributes)); - } - - mainPanel.activate(mainPanel.getComponent('current-browser')); + window.location.hash = "#id=" + node.attributes.session; }, //show the context menu when a HB is right-clicked contextmenu: function(node, event){