Advertisement
FlyFar

Bypass Wallmart's PerimeterX screen using an AntiGate template

Feb 24th, 2024
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 3.18 KB | Cybersecurity | 0 0
  1. /*
  2.  
  3. Perimeter bypass.
  4. Install dependencies:
  5.  
  6. npm install puppeteer @antiadmin/anticaptchaofficial
  7.  
  8. Run in head-on mode:
  9. node perimeterx.js
  10.  
  11. * */
  12.  
  13. const anticaptcha = require("@antiadmin/anticaptchaofficial");
  14. const pup = require('puppeteer');
  15.  
  16. //Anti-captcha.com API key
  17. const apiKey = 'API_KEY_HERE';
  18.  
  19. //control address with PerimeterX captcha
  20. const url = 'https://www.walmart.com/blocked?url=L3Byb2R1Y3QvOTU0MjE4MjUyL3NlbGxlcnM=&uuid=9957eb60-f319-11eb-afcc-5b8dc3dc9e62&vid=98d54de1-f319-11eb-8873-ed95dbe093ae&g=b';
  21.  
  22. let browser = null;
  23. let page = null;
  24.  
  25.  
  26. (async () => {
  27.  
  28.     anticaptcha.setAPIKey(apiKey);
  29.     const balance = await anticaptcha.getBalance();
  30.     if (balance <= 0) {
  31.         console.log('Topup your anti-captcha.com balance!');
  32.         return;
  33.     } else {
  34.         console.log('API key balance is '+balance+', continuing');
  35.         // anticaptcha.shutUp(); //uncomment for silent captcha recognition
  36.     }
  37.  
  38.  
  39.     try {
  40.         antigateResult = await anticaptcha.solveAntiGateTask(
  41.             url,
  42.             'Anti-bot screen bypass',
  43.             {
  44.                 "css_selector": ".sign-in-widget" //this CSS selector '.sign-in-widget' is present only at the captcha page
  45.             });
  46.     } catch (e) {
  47.         console.error("could not solve captcha: "+e.toString());
  48.         return;
  49.     }
  50.  
  51.  
  52.     const fingerPrint = antigateResult.fingerprint;
  53.  
  54.     try {
  55.         console.log('opening browser ..');
  56.  
  57.  
  58.         let options = {
  59.             headless: false,
  60.             ignoreHTTPSErrors: true,
  61.             devtools: true,
  62.             args: [
  63.                 '--window-size='+fingerPrint['self.screen.width']+','+fingerPrint['self.screen.height']
  64.             ]
  65.         };
  66.         browser = await pup.launch(options);
  67.  
  68.         console.log('creating new page ..');
  69.         page = await browser.newPage();
  70.     } catch (e) {
  71.         console.log("could not open browser: "+e);
  72.         return false;
  73.     }
  74.  
  75.     //screen size
  76.     console.log('setting view port to '+fingerPrint['self.screen.width']+'x'+fingerPrint['self.screen.height']);
  77.     await page.setViewport({width: fingerPrint['self.screen.width'], height: fingerPrint['self.screen.height']});
  78.  
  79.     //user agent
  80.     let userAgent = '';
  81.     if (fingerPrint['self.navigator.userAgent']) {
  82.         userAgent = fingerPrint['self.navigator.userAgent'];
  83.     } else {
  84.         if (fingerPrint['self.navigator.appVersion'] && fingerPrint['self.navigator.appCodeName']) {
  85.             userAgent = fingerPrint['self.navigator.appCodeName'] + '/' + fingerPrint['self.navigator.appVersion']
  86.         }
  87.     }
  88.     console.log('setting browser user agent to '+userAgent);
  89.     await page.setUserAgent(userAgent);
  90.  
  91.     console.log('setting cookies');
  92.     let cookies = [];
  93.     for (const name in antigateResult.cookies) {
  94.         cookies.push({ name: name, value: antigateResult.cookies[name], domain: antigateResult.domain })
  95.     }
  96.     await page.setCookie(...cookies);
  97.  
  98.  
  99.     try {
  100.         await page.goto(antigateResult.url, {
  101.             waitUntil: "networkidle0"
  102.         });
  103.     } catch (e) {
  104.         console.log('err while loading the page: '+e);
  105.     }
  106.  
  107.  
  108.     console.log('done');
  109.  
  110.  
  111.  
  112. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement