diff --git a/extensions/admin_ui/controllers/panel/index.html b/extensions/admin_ui/controllers/panel/index.html
index 31c92c23c..c49b0c3d5 100644
--- a/extensions/admin_ui/controllers/panel/index.html
+++ b/extensions/admin_ui/controllers/panel/index.html
@@ -28,7 +28,12 @@
<%= script_tag 'ui/panel/tabs/ZombieTabRider.js' %>
<%= script_tag 'ui/panel/tabs/ZombieTabXssRays.js' %>
- <%= script_tag 'ui/panel/PanelViewer.js' %>
+ <%= script_tag 'wterm/wterm.jquery.js' %>
+ <%= stylesheet_tag 'wterm.css' %>
+
+ <%= script_tag 'ui/panel/tabs/ZombieTabIpec.js' %>
+
+ <%= script_tag 'ui/panel/PanelViewer.js' %>
<%= script_tag 'ui/panel/DataGrid.js' %>
<%= script_tag 'ui/panel/MainPanel.js' %>
<%= script_tag 'ui/panel/ZombieTab.js' %>
diff --git a/extensions/admin_ui/media/css/wterm.css b/extensions/admin_ui/media/css/wterm.css
new file mode 100644
index 000000000..064e8cd41
--- /dev/null
+++ b/extensions/admin_ui/media/css/wterm.css
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012 Wade Alcorn wade@bindshell.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* Basic Terminal CSS */
+.wterm_terminal { background: #000; color: #fff; font-size: 1em; font-family: monospace; padding: 3px; width: 100%; height: 100%; display: block; overflow-x: none; overflow-y: auto; }
+
+/* TODO: Input Box Width is faulty */
+.wterm_terminal input { background: transparent; border: 0; color: #fff; width: 100%; font-size: 1em; font-family: monospace; outline: none; }
+.wterm_terminal div:first { margin-bottom: 1em; }
+.wterm_terminal .wterm_prompt { float: left; clear: left; }
+.wterm_terminal form { float: left; margin: 0px; width: 75%; }
+
+/* Themes */
+.wterm_theme_green_on_black { background: #000; color: #0f0; }
+.wterm_theme_green_on_black input { background: transparent; border: 0; color: #0f0; }
+
diff --git a/extensions/admin_ui/media/javascript/ui/panel/ZombieTab.js b/extensions/admin_ui/media/javascript/ui/panel/ZombieTab.js
index cea031726..3e8466e55 100644
--- a/extensions/admin_ui/media/javascript/ui/panel/ZombieTab.js
+++ b/extensions/admin_ui/media/javascript/ui/panel/ZombieTab.js
@@ -20,8 +20,10 @@ ZombieTab = function(zombie) {
commands_tab = new ZombieTab_Commands(zombie);
requester_tab = new ZombieTab_Requester(zombie);
xssrays_tab = new ZombieTab_XssRaysTab(zombie);
-
- ZombieTab.superclass.constructor.call(this, {
+ ipec_tab = new ZombieTab_IpecTab(zombie);
+
+
+ ZombieTab.superclass.constructor.call(this, {
id:"current-browser",
activeTab: 0,
loadMask: {msg:'Loading browser...'},
@@ -32,7 +34,7 @@ ZombieTab = function(zombie) {
forceFit: true,
type: 'fit'
},
- items:[main_tab, log_tab, commands_tab, requester_tab, xssrays_tab]
+ items:[main_tab, log_tab, commands_tab, requester_tab, xssrays_tab, ipec_tab]
});
};
diff --git a/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabIpec.js b/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabIpec.js
new file mode 100644
index 000000000..ca4dbb325
--- /dev/null
+++ b/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabIpec.js
@@ -0,0 +1,357 @@
+//
+// Copyright 2012 Wade Alcorn wade@bindshell.net
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/*
+ * The Ipec Tab panel for the selected zombie.
+ */
+
+ZombieTab_IpecTab = function(zombie) {
+
+ var commands_statusbar = new Beef_StatusBar('ipec-bbar-zombie-'+zombie.session);
+
+ var req_pagesize = 30;
+
+ var ipec_config_panel = new Ext.Panel({
+ id: 'ipec-config-zombie-'+zombie.session,
+ title: 'Scan Config',
+ layout: 'fit',
+ autoscroll: true
+ });
+
+ function get_rest_token(){
+ var token = "";
+ var url = "/ui/modules/getRestfulApiToken.json";
+ $jwterm.ajax({
+ contentType: 'application/json',
+ dataType: 'json',
+ type: 'GET',
+ url: url,
+ async: false,
+ processData: false,
+ success: function(data){
+ token = data.token;
+ console.log(token);
+ },
+ error: function(){
+ console.log("Error getting RESTful API token");
+ }
+ });
+ return token;
+ }
+
+ function get_module_id(name, token){
+ var id = "";
+ var url = "/api/modules/search/" + name + "?token=" + token;
+ $jwterm.ajax({
+ contentType: 'application/json',
+ dataType: 'json',
+ type: 'GET',
+ url: url,
+ async: false,
+ processData: false,
+ success: function(data){
+ id = data.id;
+ },
+ error: function(){
+ console.log("Error getting module id.");
+ }
+ });
+ return id;
+ }
+
+
+ function escape_html(str) {
+ str = str.toString();
+ str = str.replace(//g, '>');
+// str = str.replace(/\u0022/g, '"');
+ str = str.replace(/\u0027/g, ''');
+ str = str.replace(/\"\"/g, '');
+ str = str.replace(/\\r/g, '');
+ str = str.replace(/\\n/g, '
');
+ str = str.replace(/\\\\/g, '\\');
+ str = str.replace(/\\t/g, ' ');
+// str = str.replace(/\\/g, '\');
+ return str;
+ }
+
+
+ function initTerminal(zombie){
+ String.prototype.reverse = function() {
+ return this.split('').reverse().join('');
+ };
+
+ $jwterm( document ).ready( function() {
+ $jwterm('#wterm').wterm( { WIDTH: '100%', HEIGHT: '100%', WELCOME_MESSAGE: 'Welcome to BeEF Bind interactive shell. To Begin Using type \'help\'' });
+ });
+
+ var target_ip = "";
+ var target_port = "";
+
+ var command_directory = {
+ 'eval': function( tokens ) {
+ tokens.shift();
+ var expression = tokens.join( ' ' );
+ var result = '';
+ try {
+ result = eval( expression );
+ } catch( e ) {
+ result = 'Error: ' + e.message;
+ }
+ return result;
+ },
+
+ 'date': function( tokens ) {
+ var now = new Date();
+ return now.getDate() + '-' +
+ now.getMonth() + '-' +
+ ( 1900 + now.getYear() )
+ },
+
+ 'cap': function( tokens ) {
+ tokens.shift();
+ return tokens.join( ' ' ).toUpperCase();
+ },
+
+ 'go': function( tokens ) {
+ var url = tokens[1];
+ document.location.href = url;
+ },
+
+ 'target': function(tokens){
+ target_ip = tokens[1];
+ target_port = tokens[2];
+ return "Target is now " + tokens[1] + ":" + tokens[2];
+ },
+
+
+ 'exec': function(tokens){
+ if(target_ip.length == 0 || target_port.length == 0)
+ return "Error: target ip or port not set."
+
+ tokens.shift(); //remove the first element (exec)
+ var cmd = tokens.join(' '); //needed in case of commands with options
+ cmd = cmd.replace(/\\/g, '\\\\'); //needed to prevent JS errors (\ need to be escaped)
+
+ var token = get_rest_token();
+ var mod_id = get_module_id("BeEF_bind_shell", token);
+
+ var uri = "/api/modules/" + zombie.session + "/" + mod_id + "?token=" + token;
+
+ var result = null;
+
+ $jwterm.ajax({
+ contentType: 'application/json',
+ data: JSON.stringify({"rhost":target_ip, "rport":target_port, "path":"/", "cmd":cmd}),
+ dataType: 'json',
+ type: 'POST',
+ url: uri,
+ async: false,
+ processData: false,
+ success: function(data){
+ console.log("data: " + data.command_id);
+ result = "Command [" + data.command_id + "] sent successfully";
+ },
+ error: function(){
+ console.log("Error sending command");
+ return "Error sending command";
+ }
+ });
+
+ return result;
+ },
+
+ 'get': function(tokens){
+ var command_id = tokens[1];
+
+ if(command_id != null){
+
+ var token = get_rest_token();
+ var mod_id = get_module_id("BeEF_bind_shell", token);
+
+ var uri_results = "/api/modules/" + zombie.session + "/" + mod_id + "/"
+ + command_id + "?token=" + token;
+ var results = "";
+ $jwterm.ajax({
+ contentType: 'application/json',
+ dataType: 'json',
+ type: 'GET',
+ url: uri_results,
+ async: false,
+ processData: false,
+ success: function(data){
+ $jwterm.each(data, function(i){
+ console.log("result [" + i +"]: " + $jwterm.parseJSON(data[i].data).data);
+ results += $jwterm.parseJSON(data[i].data).data;
+ });
+
+ },
+ error: function(){
+ console.log("Error sending command");
+ return "Error sending command";
+ }
+ });
+ results = escape_html(results);
+ if(results.charAt(0) == '"' && results.charAt(results.length-1) == '"')
+ results = results.slice(1,results.length-1);
+
+ return results;
+ }
+ },
+
+ 'strrev': {
+ PS1: 'strrev $',
+
+ EXIT_HOOK: function() {
+ return 'exit interface commands';
+ },
+
+ START_HOOK: function() {
+ return 'exit interface commands';
+ },
+
+ DISPATCH: function( tokens ) {
+ return tokens.join('').reverse();
+ }
+ }
+ };
+
+ for( var j in command_directory ) {
+ $jwterm.register_command( j, command_directory[j] );
+ }
+
+ $jwterm.register_command( 'help', function() {
+ return 'target - Usage: target <IP> <port> - Send commands to the specified IP:port
' +
+ 'exec - Usage exec <command> <command options> - Exec a command, returns the command id.
' +
+ 'get - Usage get <command id> - Retrieve command results given a specified command id.
'
+
+ });
+ };
+
+
+ var ipec_terminal_panel = new Ext.Panel({
+ id: 'ipec-terminal-zombie-'+zombie.session,
+ title: 'Terminal',
+ layout: 'fit',
+ padding: '1 1 1 1',
+ autoScroll: true,
+ html: "