From 3bcf1b66cdcbea8332b6ed86786a2c4812871f9e Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Mon, 4 Apr 2016 11:16:11 +0200 Subject: [PATCH] Pad timestamp values date in client-side logging --- core/main/client/beef.js | 121 +++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/core/main/client/beef.js b/core/main/client/beef.js index bb327b8b1..b30d49eb8 100644 --- a/core/main/client/beef.js +++ b/core/main/client/beef.js @@ -12,73 +12,72 @@ $j = jQuery.noConflict(); if(typeof beef === 'undefined' && typeof window.beef === 'undefined') { - - var BeefJS = { - - version: '<%= @beef_version %>', - - // This get set to true during window.onload(). It's a useful hack when messing with document.write(). - pageIsLoaded: false, - - // An array containing functions to be executed by the window.onpopstate() method. - onpopstate: new Array(), - - // An array containing functions to be executed by the window.onclose() method. - onclose: new Array(), - - // An array containing functions to be executed by Beef. - commands: new Array(), - - // An array containing all the BeEF JS components. - components: new Array(), - /** - * Adds a function to display debug messages (wraps console.log()) - * @param: {string} the debug string to return - */ - debug: function(msg) { - if (!<%= @client_debug %>) return; - if (typeof console == "object" && typeof console.log == "function") { - var currentdate = new Date(); - var datetime = currentdate.getFullYear() + "-" - + (currentdate.getMonth()+1) + "-" - + currentdate.getDate() + " " - + currentdate.getHours() + ":" - + currentdate.getMinutes() + ":" - + currentdate.getSeconds(); - console.log('['+datetime+'] '+msg); - } else { - // TODO: maybe add a callback to BeEF server for debugging purposes - //window.alert(msg); - } - }, + var BeefJS = { - /** - * Adds a function to execute. - * @param: {Function} the function to execute. - */ - execute: function(fn) { - if ( typeof beef.websocket == "undefined"){ - this.commands.push(fn); - }else{ - fn(); + version: '<%= @beef_version %>', + + // This get set to true during window.onload(). It's a useful hack when messing with document.write(). + pageIsLoaded: false, + + // An array containing functions to be executed by the window.onpopstate() method. + onpopstate: new Array(), + + // An array containing functions to be executed by the window.onclose() method. + onclose: new Array(), + + // An array containing functions to be executed by Beef. + commands: new Array(), + + // An array containing all the BeEF JS components. + components: new Array(), + + /** + * Adds a function to display debug messages (wraps console.log()) + * @param: {string} the debug string to return + */ + debug: function(msg) { + if (!<%= @client_debug %>) return; + if (typeof console == "object" && typeof console.log == "function") { + var currentdate = new Date(); + var pad = function(n){return ("0" + n).slice(-2);} + var datetime = currentdate.getFullYear() + "-" + + pad(currentdate.getMonth()+1) + "-" + + pad(currentdate.getDate()) + " " + + pad(currentdate.getHours()) + ":" + + pad(currentdate.getMinutes()) + ":" + + pad(currentdate.getSeconds()); + console.log('['+datetime+'] '+msg); + } else { + // TODO: maybe add a callback to BeEF server for debugging purposes + //window.alert(msg); } }, + /** + * Adds a function to execute. + * @param: {Function} the function to execute. + */ + execute: function(fn) { + if ( typeof beef.websocket == "undefined"){ + this.commands.push(fn); + }else{ + fn(); + } + }, + /** + * Registers a component in BeEF JS. + * @params: {String} the component. + * + * Components are very important to register so the framework does not + * send them back over and over again. + */ + regCmp: function(component) { + this.components.push(component); + } - /** - * Registers a component in BeEF JS. - * @params: {String} the component. - * - * Components are very important to register so the framework does not - * send them back over and over again. - */ - regCmp: function(component) { - this.components.push(component); - } - }; - - window.beef = BeefJS; + + window.beef = BeefJS; }