Created
April 3, 2015 00:25
-
-
Save pironic/a499d8f169ed6e9bbd01 to your computer and use it in GitHub Desktop.
Krieger@Home node.js auto attack app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var attack = { | |
timeoutID: null, | |
storedRequest: null, | |
config: { | |
attack_url: "http://algersoft.net/kriegerathome/attack.php", | |
status_url: "http://algersoft.net/kriegerathome/get_totals.php", | |
interval: 30, //seconds | |
payload: "activity=record_progress", | |
verboseErrors: true | |
}, | |
init: function(obj) { | |
console.log("Welcome to the KRIEGER@HOME auto attack node.js application"); | |
attack.doAttack(); | |
}, | |
scheduleNext: function(attackInterval) | |
{ | |
if (attack.timeoutID !== null) { | |
// We've got a timeout scheduled already, let's clear it. | |
clearTimeout(attack.timeoutID); | |
} | |
if (attackInterval == null) | |
attackInterval = attack.config.interval * 1000 ; // Conversion from seconds -> milliseconds | |
// Schedule a single timeout | |
attack.timeoutID = setTimeout(attack.doAttack, attackInterval); | |
}, | |
doAttack: function() | |
{ | |
console.log("----"); | |
var http = require('http'); | |
var url = require('url'); | |
// The timeout has executed, we don't need the handle anymore. | |
attack.timeoutID = null; | |
console.log("attack started:" + attack.config.attack_url); | |
var link = url.parse(attack.config.attack_url, true, true); | |
var options = { | |
host: link.hostname, | |
port: link.port, | |
path: link.pathname, | |
method: 'POST', | |
headers: { | |
'User-Agent':'node.js app designed to attack kriegerathome, devpd by [email protected]', | |
'Content-Type':'application/x-www-form-urlencoded', | |
'Content-Length': attack.config.payload.length | |
} | |
}; | |
link = null; | |
var req = http.request(options, function(resp) { | |
console.log('attack response code: '+resp.statusCode); | |
resp.on('data', function(chunk) { | |
if (resp.statusCode != 200 && attack.config.verboseErrors) { | |
console.log('Seems the attack is probobly done or something weird happened.') | |
console.log('BODY: ' + chunk); | |
console.log('HEADERS: '+JSON.stringify(resp.headers)); | |
return; | |
} | |
var body = JSON.parse(chunk); | |
console.log('attack body status: ' + body.status); | |
console.log('attack body message: ' + body.message); | |
if (body.remaining_time > 0) { | |
console.log('attack rescheduled for '+body.remaining_time/1000+' seconds from now.'); | |
attack.scheduleNext(body.remaining_time); | |
} | |
}) | |
}); | |
req.on('error', function(e) { | |
console.log('attack error caught: ' + e.message); | |
}); | |
req.write(attack.config.payload); | |
req.end(); | |
console.log("status started:" + attack.config.status_url); | |
http.get(attack.config.status_url, function(res) { | |
console.log("status response code: " + res.statusCode); | |
res.setEncoding('utf8'); | |
res.on('data', function (chunk) { | |
console.log(" " + chunk+" Attacks of 1,000,000 : " + Math.round((chunk/10000),2) + "%"); | |
}); | |
}).on('error', function(e) { | |
console.log("status ERROR: " + e.message); | |
}); | |
// Reschedule ourselves | |
attack.scheduleNext(); | |
} | |
}; | |
var round = Math.round; | |
Math.round = function (value, decimals) { | |
decimals = decimals || 0; | |
return Number(round(value + 'e' + decimals) + 'e-' + decimals); | |
} | |
attack.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment