📜 ⬆️ ⬇️

Dripstat again

Got out of the drafts to share with friends, the post is quite old, you can not pay attention

This post is inspired by this post: tyts .

I read it and thought, do browser processes get automated in a similar way?
A clicker is somehow too straightforward, and it is not fitting for a programmer to use such automation.
In my opinion this is too much, forcing the browser to handle clicks one at a time, when we have the full source code of the application in our hands.
image

So, let's start to understand:
')
1. A superficial analysis of the messaging protocol between the server and the client showed that the substitution of messages will not work - the server has internal verification mechanisms.


Is it really? We look carefully into the code and see, indeed, the objects are encrypted with some sort of XORCipher ...
But do we need it? We look at the method of sending the event to the server,
- the event object comes to it,
- encrypted
- sent to server

Analyze the event object before encryption, this is a simple json:

{
userid: "userid",
events: [ ]
}


The events themselves contain information
- about the accumulated amount of memory
- about the past tense (this is generally brilliant)
- about purchases

By slightly modifying this method, we can achieve that
- the server will think that a lot of time has passed since the last save (it was empirically found out that this value could not be more than two minutes)
- change error handling (in order not to reload the page in case of anything)

So let's get down to writing the miner.
Plan
- Startup, configuration
- Periodic save. Here I preferred the “sliding” mode setTimeout, because with setInterval the inevitable collapse at the network lags
- Rollback to the last valid state in case of validation error (too greedy :))

Constructor:

 function Miner(incr, dripK, delay) { var that = this; this.incr = incr || localStats.bps*1e3; //       this.dripK = dripK || 0.5; //    this.delay = delay || 100; //    document.hasFocus = function () {return true;}; NO_PINGY=1; //       ,  // Redefine postEvent RestEventManager.prototype.postEventData = function(e,t,next) //    next,    { var r=XORCipher.encode(DataSaver.key,JSON.stringify(e)); //  , ! //  : return $.ajax({type:"POST",async:!0,url:GAME_URL+(loggedIn?"events":"eventsanon"),data:r,contentType:"text/plain", success: function() { var self = this; that.lastCorrect = localStats.byteCount; //  t.apply(self, arguments); //  callback setTimeout(function(){ if(localStats.byteCount > localStats.memoryCapacity * that.dripK) $('#btn-addGlobalMem').trigger('click'); //   }, 0); if(typeof next == 'function')next(); }, error: function(e) { localStats.byteCount = that.lastCorrect; //  console.error(e.responseText); // show error text if(typeof next == 'function') next(); // ,   }}) } } 


Next, we need to build an event:

 Miner.prototype.postEvent = function(mem, time, next) { var d = { userid: networkUser.userId, events: [{ generatedMem: mem, power: null, timeElapsed: time, type: 1 }] } RestEventManager.prototype.postEventData(d, function(){}, next); }; 


Is done.

Bind the start / stop:
 Miner.prototype.start = function() { var that = this; this.stopped = false; this.lastCorrect = localStats.byteCount; // save before the action function post(){ localStats.byteCount+=that.incr; // mine some bytes that.postEvent(localStats.byteCount, 120000, function(){ // tell to server that 2minutes passed if(!that.stopped) that.sI = setTimeout(post, that.delay); // next iteration on response }) } if(this.sI) clearTimeout(this.sI); if(!this.stopped) this.sI = setTimeout(post, this.delay); // first call }; Miner.prototype.stop = function() { this.stopped = true; }; 


Run!

  var miner = new Miner(); miner.start(); 


It is worth noting here that the validation of the bytes you have accumulated depends on your “ability to generate”, i.e. the number of purchased units. Therefore, at the start, I acquire, 1 piece of all devices, and 50-60 clusters, gradually increasing / playing at the speed of production ...

Result: for half an hour of writing and 4-5 hours of work, the script led to the top 1-2 two accounts arth / Arth :)



The full text of the script

PS: Thanks for the invite :)

Source: https://habr.com/ru/post/219889/


All Articles