Skip to content

Instantly share code, notes, and snippets.

@chtzvt
Created October 8, 2015 22:10
Show Gist options
  • Save chtzvt/f5bc43c0a10c21ba3667 to your computer and use it in GitHub Desktop.
Save chtzvt/f5bc43c0a10c21ba3667 to your computer and use it in GitHub Desktop.
A bot I used to cast votes for my high school's football coach.
/*
Roids.js by Charlton Trezevant - 2015
This is a bot I used to cast votes for my high school's Football coach.
It is written specifically for that poll, and in the interest of keeping the skiddies away
I will leave it to you to reverse-engineer PollDaddy.
Enjoy!
*/
// The Request library is an excellent HTTP library. Install it with "npm install request".
var request = require('request');
// Get the number of votes to cast from the CLI argument. Example: "node roids.js 15".
var NUM_VOTES = process.argv[2];
// The unique URL used to grab nonces from PollDaddy. This must be changed for each poll!
var NONCE_URL = "https://polldaddy.com/n/711916d3fe16565e59dac750e893be87/9051564";
console.log("Juicing started, casting " + NUM_VOTES + " votes...");
for (var i = 0; i < NUM_VOTES; i++) {
//Rate limiting for votes, assign each
setTimeout(castVote, (Math.floor(Math.random() * 20) + 1000), [i]);
}
function castVote(vote) {
// Vote is an array when setTimeout calls this function. Convert this to an int.
vote = vote[0];
// This generates a semi-unique user-agent header with varying version numbers.
var uagent = "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/" + Math.floor(Math.random() * 200) + "." + Math.floor(Math.random() * 56) + " (KHTML, like Gecko) Chrome/" + Math.floor(Math.random() * 45) + ".0." + Math.floor(Math.random() * 3000) + "." + Math.floor(Math.random() * 153) + " Safari/" + Math.floor(Math.random() * 537) + "." + Math.floor(Math.random() * 36);
(function(voteNumber, uagent) {
// Include headers that make us look like less of a bot.
var settings = {
url: NONCE_URL,
headers: {
'User-Agent': uagent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.8',
'DNT': 1,
},
method: 'GET'
};
request(settings, function cb(err, httpResponse, body) {
if (err) {
console.error("Fetching nonce failed!! Server response: " + httpResponse);
} else {
// Extract nonce from URL.
// The returned value looks like: "PDV_n9051564='f300a26c69|901';PD_vote9051564(0);", and we just want what's between ' and ';.
var nonce = body.slice(body.indexOf("'"), body.indexOf("';"));
//Construct the URL for the poll, which contains our nonce. This must be changed for each poll!
var url = "https://polls.polldaddy.com/vote-js.php?p=9051564&b=2&a=41197959,&o=&va=0&cookie=0&n=" + nonce + "&url=http%3A//www.buccaneers.com/community/coach-of-the-week.html";
var settings = {
url: url,
headers: {
'User-Agent': uagent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.8',
'DNT': 1,
},
method: 'GET'
};
request(settings, function cb(err, httpResponse, body) {
if (err) {
console.error("Error casting vote " + (voteNumber + 1) + "!! Got response: " + httpResponse);
} else {
console.log("Cast vote " + (voteNumber + 1) + " SUCCESSFULLY!");
}
});
}
});
})(vote, uagent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment