diff --git a/run-server.bat b/run-server.bat index 8b7b1a3..6010b6c 100644 --- a/run-server.bat +++ b/run-server.bat @@ -1,5 +1,6 @@ SET /P email= Digite seu email da grobo: SET /P senha= Digite sua senha da grobo: +echo "prior | manu | mari" +SET /P voto= Escolha sua vitima: -SET /P voto= Digite sua senha da grobo [prior | manu | mari]: node src/index.js %voto% %email% %senha% \ No newline at end of file diff --git a/src/config/contents.js b/src/config/contents.js index b3a6b75..ddf5d2a 100644 --- a/src/config/contents.js +++ b/src/config/contents.js @@ -15,7 +15,7 @@ smmmmmdhhddo. \`/hmmmmmds- \`:. \`+s. HE4RT DEVELOPERS DISCORD.IO/HE4RT -`; +` const links = { loginUrl: 'https://minhaconta.globo.com', @@ -25,7 +25,7 @@ const links = { challengeAcceptedUrl: 'https://royale.globo.com/polls/8e81660d-89b5-4777-a324-6f2da878c5c7', mainApi: 'http://bots.heartdevs.com/' -}; +} const XPathContents = { email: @@ -34,16 +34,16 @@ const XPathContents = { '/html/body/div[1]/main/div[2]/div/div/div/div[2]/div[1]/form/div[3]/div[1]/input', loginBtn: '/html/body/div[1]/main/div[2]/div/div/div/div[2]/div[1]/form/div[6]/button', - revoteBtn: '/html/body/div[2]/div[4]/div/div[3]/div/div/div[1]/div[2]/button', + revoteBtn: '/html/body/div[1]/div[4]/div/div[3]/div/div/div[1]/div[2]/button', captchaImage: '/html/body/div[2]/div[4]/div/div[1]/div[4]/div[2]/div[2]/div/div/div[2]/div/div[2]/img' -}; +} const users = [ '/html/body/div[2]/div[4]/div/div[1]/div[4]/div[1]/div', '/html/body/div[2]/div[4]/div/div[1]/div[4]/div[2]/div', '/html/body/div[2]/div[4]/div/div[1]/div[4]/div[3]/div' -]; +] /* PRIOR = 0 @@ -56,4 +56,4 @@ module.exports = { XPathContents, logoAscii, users -}; +} diff --git a/src/util.js b/src/util.js index 7641635..53a6091 100644 --- a/src/util.js +++ b/src/util.js @@ -1,37 +1,37 @@ -const { links, XPathContents, logoAscii, users } = require('./config/contents'); -const { getShitDone } = require('./bbb-filter'); -const fs = require('fs'); -const axios = require('axios'); +const { links, XPathContents, logoAscii, users } = require('./config/contents') +const { getShitDone } = require('./bbb-filter') +const fs = require('fs') +const axios = require('axios') const instance = axios.create({ baseURL: links.mainApi -}); +}) -let availableImages = []; +let availableImages = [] -const fsExtra = require('fs-extra'); +const fsExtra = require('fs-extra') -const timeout = ms => new Promise(resolve => setTimeout(resolve, ms)); +const timeout = ms => new Promise(resolve => setTimeout(resolve, ms)) const runLogin = auth => async page => { - await page.goto(links.loginUrl); + await page.goto(links.loginUrl) - const emailField = await page.waitForXPath(XPathContents.email); - const passField = await page.waitForXPath(XPathContents.password); - await emailField.type(auth.email); - await passField.type(auth.password); + const emailField = await page.waitForXPath(XPathContents.email) + const passField = await page.waitForXPath(XPathContents.password) + await emailField.type(auth.email) + await passField.type(auth.password) - const loginBtn = await page.waitForXPath(XPathContents.loginBtn); - await loginBtn.click(); + const loginBtn = await page.waitForXPath(XPathContents.loginBtn) + await loginBtn.click() - await page.waitForNavigation(); - await page.goto(links.voteUrl); - // removeCss(page); -}; + await page.waitForNavigation() + await page.goto(links.voteUrl) + removeCss(page) +} const configs = async () => { // let config = await instance.get("/config"); // results = config.data.results; - availableImages = JSON.parse(fs.readFileSync('results.json')); -}; + availableImages = JSON.parse(fs.readFileSync('results.json')) +} const removeCss = async page => { let css = `* { @@ -50,21 +50,21 @@ const removeCss = async page => { .tag-manager-publicidade-container--visivel div { display: none !important; } - `; - await page.$eval('#banner_votacao1', e => { + ` + /*await page.$eval('#banner_votacao1', e => { var me = $('#banner_votacao1'); var newMe = $( '' ); newMe.html(me.html()); me.replaceWith(newMe); - }); - await page.addStyleTag({ content: css }); -}; + });*/ + await page.addStyleTag({ content: css }) +} -const isWhite = pixel => pixel >= 250; -const isBlack = pixel => pixel <= 10; -const isGrey = pixel => pixel > 10 && pixel < 250; +const isWhite = pixel => pixel >= 250 +const isBlack = pixel => pixel <= 10 +const isGrey = pixel => pixel > 10 && pixel < 250 const checkImage = ({ width, height, lines }) => { let results = { @@ -73,96 +73,96 @@ const checkImage = ({ width, height, lines }) => { black: 0, width, height - }; + } for (let i = 0; i < width; i++) { for (let y = 0; y < height; y++) { - const pixel = lines[y][i]; + const pixel = lines[y][i] if (isGrey(pixel)) { - results.grey++; + results.grey++ } else if (isBlack(pixel)) { - results.black++; + results.black++ } else if (isWhite(pixel)) { - results.white++; + results.white++ } } } - return results; -}; + return results +} const vote = victim => async page => { - const userCard = await page.waitForXPath(users[victim]); - await userCard.click(); -}; + const userCard = await page.waitForXPath(users[victim]) + await userCard.click() +} const revote = victim => async page => { - await new Promise(resolve => setTimeout(resolve, 400)); - const retryBtn = await page.waitForXPath(XPathContents.revoteBtn); + await new Promise(resolve => setTimeout(resolve, 400)) + //const retryBtn = await page.waitForSelector('_3VpV6myQ0E-1rsgh9PoeaN _2RlpFUvPRVdsXs_oOyQ_pN'); - await retryBtn.click(); + //await retryBtn.click(); - await new Promise(resolve => setTimeout(resolve, 400)); - vote(victim)(page); -}; + await page.goto(links.voteUrl) + await new Promise(resolve => setTimeout(resolve, 400)) + vote(victim)(page) +} const cleanFiles = () => { for (let i = 0; i < 5; i++) { fsExtra.emptyDirSync('images/filtered/', err => { - console.log(err); - }); + console.log(err) + }) fsExtra.emptyDirSync('images/chunked/', err => { - console.log(err); - }); + console.log(err) + }) fsExtra.emptyDirSync('images/captchas/', err => { - console.log(err); - }); + console.log(err) + }) } //file removed -}; +} const CAPTCHA_SELECTOR = - '#roulette-root div > div > div > div > img:nth-child(1)'; + '#roulette-root div > div > div > div > img:nth-child(1)' const getBoundingClientRect = (page, selector) => page.$eval(selector, el => { - const position = el.getBoundingClientRect(); - return [position.top, position.left]; - }); + const position = el.getBoundingClientRect() + return [position.top, position.left] + }) const selectCaptcha = async (page, index) => { - const [top, left] = await getBoundingClientRect(page, CAPTCHA_SELECTOR); - await page.mouse.click(index * 53 + left + 25, top + 25); -}; + const [top, left] = await getBoundingClientRect(page, CAPTCHA_SELECTOR) + await page.mouse.click(index * 53 + left + 25, top + 25) +} -const RESET_CAPTCHA = - '#roulette-root div > div > div > div button:nth-child(1)'; +const RESET_CAPTCHA = '#roulette-root div > div > div > div button:nth-child(1)' const resetCaptcha = async page => { - const [top, left] = await getBoundingClientRect(page, RESET_CAPTCHA); - await page.mouse.click(left + 50, top + 10); -}; + const [top, left] = await getBoundingClientRect(page, RESET_CAPTCHA) + await page.mouse.click(left + 50, top + 10) +} const fetchSymbolData = async symbol => { try { symbol = symbol .normalize('NFD') .replace(/[\u0300-\u036f]/g, '') - .replace(' ', '-'); - let response = await instance.get('/symbols/' + symbol); - return response.data; + .replace(' ', '-') + let response = await instance.get('/symbols/' + symbol) + return response.data } catch (e) { - console.log(e.response.data); + console.log(e.response.data) } -}; +} const challengePage = async (page, response, setToSave) => { - let { data } = await response.json(); - let { symbol, image } = data; - let mainSymbol = (await fetchSymbolData(symbol)) || []; + let { data } = await response.json() + let { symbol, image } = data + let mainSymbol = (await fetchSymbolData(symbol)) || [] - cleanFiles(); + cleanFiles() const imageName = `images/captchas/${symbol}-${Math.floor( Math.random() * 8888888 - ) + 99999}.png`; - fs.writeFileSync(imageName, image, 'base64'); - const resultImages = await getShitDone(imageName); + ) + 99999}.png` + fs.writeFileSync(imageName, image, 'base64') + const resultImages = await getShitDone(imageName) - const results = resultImages.map(checkImage); + const results = resultImages.map(checkImage) /* if (true) { @@ -191,11 +191,10 @@ const challengePage = async (page, response, setToSave) => { if (mainSymbol.length === 0) { return false; } - } - */ + }*/ if (mainSymbol.length === 1 && mainSymbol[1] === 'no existe') { - return resetCaptcha(page); + return resetCaptcha(page) } const scoreFiltered = results @@ -216,104 +215,104 @@ const challengePage = async (page, response, setToSave) => { score: result.scores .map(({ grey, black, width, height }) => grey + black + width + height) .sort()[0] - })); + })) const [bestBet, index] = scoreFiltered .slice() .map((el, i) => [el, i]) - .sort(([a], [b]) => a.score - b.score)[0]; + .sort(([a], [b]) => a.score - b.score)[0] - console.log('Symbol', symbol); + console.log('Symbol', symbol) - await timeout(500); + await timeout(500) if (bestBet.score > 120) { - console.log('chute:', index + 1, bestBet.score); - return resetCaptcha(page); + console.log('chute:', index + 1, bestBet.score) + return resetCaptcha(page) } - console.log('score:', index + 1, bestBet.score); - return selectCaptcha(page, index); -}; + console.log('score:', index + 1, bestBet.score) + return selectCaptcha(page, index) +} const challengeAcceptedPage = victim => async ( _page, response, toSave, setToSave ) => { - let status = response.status(); + let status = response.status() if (parseInt(status) === 200) { - revote(victim)(_page); - if (toSave) { - try { - const res = await instance.post('/vote', { - success: true, - data: toSave.value, - image: toSave.key - }); - const { localVotes, totalVotes } = res.data; - console.clear(); - console.log('\x1b[35m', logoAscii); - console.log( - '\x1b[32m', - ` + revote(victim)(_page) + //if (toSave) { + try { + const res = await instance.post('/vote', { + success: true, + data: toSave.value, + image: toSave.key + }) + const { localVotes, totalVotes } = res.data + console.clear() + //console.log('\x1b[35m', logoAscii); + console.log( + '\x1b[32m', + ` [✅] TOTAIS DE VOTOS: ${totalVotes} [✅] VOTOS COMPUTADOS: ${localVotes} ` - ); - } catch (e) { - console.log(e.response.data); - } + ) + } catch (e) { + console.log(e.response.data) } + //} } else { - console.clear(); - console.log('\x1b[35m', logoAscii); + console.clear() + //console.log('\x1b[35m', logoAscii); console.log( '\x1b[31m', ` [❌] VOTO NÃO COMPUTADO! ` - ); + ) } - setToSave(null); -}; + setToSave(null) +} const listenEvents = victim => async (page, browser) => { - let toSave = null; + let toSave = null const setToSave = toSaveData => { - toSave = toSaveData; - }; + toSave = toSaveData + } - await timeout(500); + await timeout(500) browser.on('targetcreated', async target => { - const { type } = target._targetInfo; - const newPage = await target.page(); + const { type } = target._targetInfo + const newPage = await target.page() - if (type !== 'page') return; - console.log('Fechando página com propaganda.'); - await newPage.close(); - }); + if (type !== 'page') return + console.log('Fechando página com propaganda.') + await newPage.close() + }) page.on('response', async response => { - let hookUrl = response.url(); - let request = response.request(); + let hookUrl = response.url() + let request = response.request() if (hookUrl.startsWith(links.voteUrl)) { - vote(victim)(page); + vote(victim)(page) } if ( hookUrl.startsWith(links.challengeAcceptedUrl) && request.method() === 'POST' ) { - challengeAcceptedPage(victim)(page, response, toSave, setToSave); + challengeAcceptedPage(victim)(page, response, toSave, setToSave) } if (hookUrl.startsWith(links.challengeUrl)) { - challengePage(page, response, setToSave); + challengePage(page, response, setToSave) } - }); -}; + }) +} module.exports = ({ victim, login }) => ({ runLogin: runLogin(login), @@ -321,4 +320,4 @@ module.exports = ({ victim, login }) => ({ listenEvents: listenEvents(victim), configs, fetchSymbolData -}); +})