Skip to content

Instantly share code, notes, and snippets.

@dzt
Created November 21, 2017 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dzt/fba7d4629de4e2e18b1753e0d650c4ed to your computer and use it in GitHub Desktop.
Save dzt/fba7d4629de4e2e18b1753e0d650c4ed to your computer and use it in GitHub Desktop.
undefeated raffle script (use node undefeated.js to run it)
var request = require('request');
var getToken = function(sitekey, key, callback) {
var twoCapID;
var checkCaptcha = function() {
request({
url: 'http://2captcha.com/res.php',
method: 'get',
qs: {
key: key,
action: 'get',
id: twoCapID
}
}, function(err, res, body) {
//console.log('body', body)
if (body.substring(0, 2) == "OK") {
console.log(`Captcha Token Retrieved from 2captcha`);
var gCapRes = body.split('|')[1]
return callback(null, gCapRes);
} else if (body == 'CAPCHA_NOT_READY') {
setTimeout(checkCaptcha, 2000);
} else if (body == 'ERROR_CAPTCHA_UNSOLVABLE') {
return callback(`Captcha Unsolvable`, null);
}
});
}
if (key == '' || key == null) {
console.error(`No 2captcha key present.`);
return callback(`No 2captcha key present.`, null);
} else {
request({
url: 'http://2captcha.com/in.php',
method: 'get',
qs: {
key: key,
method: 'userrecaptcha',
googlekey: sitekey,
pageurl: 'enter.undefeated.com'
}
}, function(err, res, body) {
if (body.substring(0, 2) == "OK") {
twoCapID = body.split('|')[1];
console.log(`Token request sent via 2captcha (${twoCapID})`);
checkCaptcha();
} else {
console.log(`Error occured while trying to request for 2captcha.`);
return callback(`Captcha Unsolvable`, null);
}
});
}
}
module.exports = {
getToken: getToken
};
{
"name": "undefeated-raffle",
"version": "1.0.0",
"description": "Undefeated Raffle Sign Up Script",
"main": "undefeated.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Peter Soboyejo <thepcmrtim@gmail.com>",
"license": "MIT",
"dependencies": {
"cheerio": "^1.0.0-rc.2",
"console-stamp": "^0.2.6",
"request": "^2.83.0"
}
}
host:port:username:password
or
host:port
line by line
if you're not using any proxies just clear all the text in this file and save it.
require('console-stamp')(console, {
colors: {
stamp: 'yellow',
label: 'cyan',
label: true,
metadata: 'green'
}
});
const j = require('request').jar();
const request = require('request').defaults({
gzip: true,
jar: j
});
const cheerio = require('cheerio');
const twoCap = require('./2cap');
const fs = require('fs');
function formatProxy(proxy) {
if (proxy && ['localhost', ''].indexOf(proxy) < 0) {
proxy = proxy.replace(' ', '_');
const proxySplit = proxy.split(':');
if (proxySplit.length > 3)
return "http://" + proxySplit[2] + ":" + proxySplit[3] + "@" + proxySplit[0] + ":" + proxySplit[1];
else
return "http://" + proxySplit[0] + ":" + proxySplit[1];
} else
return undefined;
}
const firstName = 'Main';
const lastName = 'Dev';
const emailAddress = 'maindev@dashe.io';
const fourDigit = '4444';
const twoCapToken = '2 captcha token here';
function main() {
const proxyInput = fs.readFileSync('proxies.txt').toString().split('\n');
const proxyList = [];
for (let p = 0; p < proxyInput.length; p++) {
proxyInput[p] = proxyInput[p].replace('\r', '').replace('\n', '');
if (proxyInput[p] != '')
proxyList.push(proxyInput[p]);
}
console.log('Found ' + proxyList.length + ' proxies.');
request({
method: 'get',
url: 'https://enter.undefeated.com/user/register',
headers: {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'accept-language': 'en-US,en;q=0.9',
'cache-control': 'max-age=0',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'
},
proxy: formatProxy(proxyList[Math.floor(Math.random() * proxyList.length)])
}, (err, resp, body) => {
if (err) {
console.error('Error when making a request to raffle page: ' + err);
} else if (resp.statusCode != 200) {
console.error('Got bad response code ' + resp.statusCode);
} else {
var $ = cheerio.load(body);
var formData = {
'botcha': $('#botcha').val(),
'captcha_response': 'Google no captcha',
'captcha_sid': $('#captcha_sid').val(),
'field_first_name[und][0][value]': firstName,
'field_last_4_id[und][0][value]': fourDigit,
'field_last_name[und][0][value]': lastName,
'form_build_id': $('#form_build_id').val(),
'form_id': 'user_register_form',
'g-recaptcha-response': null,
'mail': emailAddress,
'name': 'unset_username',
'op': 'Create new account',
'timegate': $('#timegate').val(),
'timezone': $('#timezone').val()
}
// Set Dynamic Form Values
$('.user-info-from-cookie input').map(function(i, el) {
if (formData[$(this).attr('name')] == undefined) {
formData[$(this).attr('name')] = $(this).val();
}
});
var v = formData['botcha'].slice(-7);
console.log('v value: ' + v);
var actionObj = body.split(`$("#user-register-form").get(0).setAttribute('action', '`)[1].split(`');`)[0];
console.log('Form Action Link: ' + actionObj.split(`'+v+'`)[0] + v + actionObj.split(`'+v+'`)[1]);
twoCap.getToken($('.g-recaptcha').attr('data-sitekey'), twoCapToken, (err, gcapres) => {
if (err) {
console.error(err);
return err;
}
formData['g-recaptcha-response'] = gcapres;
console.log(formData);
request({
method: 'post',
url: 'https://enter.undefeated.com' + actionObj.split(`'+v+'`)[0] + v + actionObj.split(`'+v+'`)[1],
headers: {
'Origin': 'https://enter.undefeated.com',
'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryJWTM00XGJ72lXWsU',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.9'
},
formData: formData,
proxy: formatProxy(proxyList[Math.floor(Math.random() * proxyList.length)])
}, (err, resp, body) => {
if (err) {
console.error('Error occured when submitting to raffle page: ' + err);
} else if (resp.statusCode != 200) {
console.error('Got bad response code when submitting to raffle page:' + resp.statusCode);
} else {
console.log(body);
}
})
});
}
})
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment