FlyFar

Bypass store.steam-powered.com/join Recaptcha Enterprise V2

Feb 24th, 2024
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 6.17 KB | Cybersecurity | 0 0
  1. //npm install puppeteer fs @antiadmin/anticaptchaofficial
  2. // run with command: "node store.steam-powered.com.js"
  3.  
  4. //IMPORTANT:
  5. //1. Steam utilizes Recaptcha Enterprise V2, which is not the same as usual Recaptcha V2.
  6. //Several attempts may be required to bypass captcha. Try this script at least 10 times.
  7. //
  8. //2. Script "_store.steam-powered.com.js" is what the original page is including in joinsteam.js, with little modifications:
  9. // - variable "recaptchaToken" is added
  10. // - function "CaptchaText" returns recaptchaToken variable
  11. // - added "sValueResolve" variable which we replace later with our promise-resolve function
  12. // - in function RenderRecaptcha added call of sValueResolve function to pass s-value to our script
  13. //3. If something gets broken on the page, replace content of "_store.steam-powered.com.js" with updated code
  14. //and add modifications I've described above to it.
  15. //
  16.  
  17. const anticaptcha = require("@antiadmin/anticaptchaofficial");
  18. const pup = require("puppeteer");
  19. const fs = require('fs');
  20.  
  21.  
  22. //API key for anti-captcha.com
  23. const anticaptchaAPIKey = 'API_KEY_HERE';
  24.  
  25. const url = 'https://store.steampowered.com/join';
  26. const sitekey = '6LdIFr0ZAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH';
  27. const login = makeid(10)+'@gmail.com';
  28.  
  29. let browser = null;
  30. let page = null;
  31. let token = null;
  32.  
  33.  
  34. const userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36";
  35.  
  36.  
  37. (async () => {
  38.    
  39.     anticaptcha.setAPIKey(anticaptchaAPIKey);
  40.     const balance = await anticaptcha.getBalance();
  41.     if (balance <= 0) {
  42.         console.log('Buy your anticaptcha balance!');
  43.         return;
  44.     } else {
  45.         console.log('API key balance is '+balance+', continuing');
  46.         // anticaptcha.shutUp(); //uncomment for silent captcha recognition
  47.     }
  48.    
  49.     try {
  50.         console.log('opening browser ..');
  51.  
  52.  
  53.         let options = {
  54.             headless: false,
  55.             ignoreHTTPSErrors: true,
  56.             devtools: true,
  57.             args: [
  58.                 '--disable-web-security',
  59.                 '--disable-features=IsolateOrigins,site-per-process'
  60.             ]
  61.         };
  62.         console.log(options);
  63.         browser = await pup.launch(options);
  64.  
  65.  
  66.         console.log('creating new page ..');
  67.         page = await browser.newPage();
  68.     } catch (e) {
  69.         failCallback("could not open browser: "+e);
  70.         return false;
  71.     }
  72.  
  73.     await page.setUserAgent(userAgent);
  74.     await page.evaluateOnNewDocument(() => {
  75.         Object.defineProperty(navigator, 'platform', { get:() => 'Macintosh' });
  76.         Object.defineProperty(navigator, 'productSub', { get:() => '20030107' });
  77.         Object.defineProperty(navigator, 'vendor', { get:() => 'Google Inc.' });
  78.     });
  79.  
  80.     page.on('console', msg => console.log('EVAL LOG:', msg.text()));
  81.  
  82.     await page.setRequestInterception(true);
  83.     page.on('request', (request) => {
  84.         //abort to replace with out version of this file
  85.         if (request.url().indexOf('joinsteam.js') !== -1) {
  86.             console.log('aborting '+request.url());
  87.             request.abort();
  88.         } else {
  89.             request.continue();
  90.         }
  91.     });
  92.     page.on('response', (response) => {
  93.         if (response.url().indexOf('login') !== -1 && response.request().method() === 'POST') {
  94.             console.log("\n\n==== captcha check response ====\n\n");
  95.             console.log('status: '+response.status());
  96.             if (response.status() !== 302) {
  97.                 failCallback("captcha result not accepted");
  98.             } else {
  99.                 successCallback("successfully passed test");
  100.             }
  101.         }
  102.     });
  103.  
  104.  
  105.  
  106.  
  107.  
  108.     console.log("going to "+url);
  109.     try {
  110.         await page.goto(url, {
  111.             waitUntil: "domcontentloaded"
  112.         });
  113.     } catch (e) {
  114.         console.log("error loading: "+e);
  115.     }
  116.  
  117.  
  118.     console.log('injecting a script');
  119.     try {
  120.  
  121.         const path = require('path');
  122.         let file = fs.readFileSync(path.resolve('.', '_store.steam-powered.com.js'), 'utf8');
  123.         await page.addScriptTag({ content: file });
  124.     } catch (e) {
  125.         console.log('failed to insert script: '+e);
  126.     }
  127.  
  128.  
  129.     const getSValue = () => {
  130.         return page.evaluate(async () => {
  131.  
  132.             return await new Promise(resolve => {
  133.  
  134.                 sValueResolve = resolve;
  135.  
  136.  
  137.                 RefreshCaptcha();
  138.  
  139.             })
  140.         });
  141.     };
  142.  
  143.  
  144.     const sValue = await getSValue();
  145.     console.log('s value:');
  146.     console.log(sValue);
  147.  
  148.  
  149.     console.log('solving captcha');
  150.  
  151.     const loginInput= await page.$(`#email`)
  152.     await loginInput.focus();
  153.     await page.type(`#email`,login)
  154.  
  155.     await delay(500);
  156.  
  157.     const loginInput2= await page.$(`#reenter_email`)
  158.     await loginInput2.focus();
  159.     await page.type(`#reenter_email`,login)
  160.  
  161.     await delay(500);
  162.  
  163.     await page.evaluate(() => {
  164.         document.querySelector("#i_agree_check").parentElement.click();
  165.     });
  166.  
  167.  
  168.  
  169.     try {
  170.         token = await anticaptcha.solveRecaptchaV2EnterpriseProxyless(
  171.             url,
  172.             sitekey,
  173.             {
  174.                 s: sValue.s
  175.             });
  176.     } catch (e) {
  177.         failCallback("could not solve captcha: "+e);
  178.         return;
  179.     }
  180.  
  181.     console.log('token is ready: '+token);
  182.  
  183.  
  184.     await page.evaluate(async (token) => {
  185.  
  186.         recaptchaToken = token;
  187.  
  188.  
  189.         StartCreationSession();
  190.  
  191.  
  192.     }, token);
  193.  
  194.  
  195. })();
  196.  
  197.  
  198.  
  199. function delay(time) {
  200.    return new Promise(function(resolve) {
  201.        setTimeout(resolve, time)
  202.    });
  203. }
  204.  
  205.  
  206.  
  207. function successCallback() {
  208.     console.log('Successfully passed: ');
  209.     // console.log('closing browser .. ');
  210.     // browser.close();
  211. }
  212.  
  213. function failCallback(code) {
  214.     console.log('Failed to pass: '+code);
  215.     // console.log('closing browser .. ');
  216.     // browser.close();
  217. }
  218.  
  219.  
  220. function makeid(length) {
  221.    let result           = '';
  222.    let characters       = 'abcdefghijklmnopqrstuvwxyz';
  223.    let charactersLength = characters.length;
  224.    for ( let i = 0; i < length; i++ ) {
  225.       result += characters.charAt(Math.floor(Math.random() * charactersLength));
  226.    }
  227.    return result;
  228. }
Add Comment
Please, Sign In to add comment