Use PuPpeteer to crack the pole test

Basic flow:

1. Open the front end network, click Login.

2. Fill in the account, password.

3. Point verification button, pass the sliding verification, and finally log in.

Code Implementation:

GitHub can checkout on CHECKOUB. The specific code is as follows:

Const PuPpeteer = Require (‘PuPpeteer’); Const Devices = Require (‘PuPpeteer / DeviceDescriptors’); const iPhone = Devices [‘iPhone 6 plus’]; let timeout = function (delay) {return new promise => {setTimeout (() => {TRY {Resolve (1)}}}}}}}}, delay);}}}}}}}}}} = NULL Let Times = 0 // Execute the number of times of resilience const distanceRRROR = [-10, 2, 3,5] // Distance error Async function run () {const browser = await puPpeteer.launch ({headless: false // Here I am set to make everyone see the effect, set to true will not open browsing PA}); PAGE = AWAIT BROWSER.NEWPAGE (); // 1. Open front network await page.emulate (iPhone); AWAIT Page.goto (‘https://www.qdfuns.com/’); AWAIT TIMEOUT (1000); / / 2. Open the login page Page.Click (‘a [data-type = login]’) AWAIT TIMEOUT (1000); // 3. Enter the account password Page.Type (‘INPUT [DATA-TYPE = email]’, ‘ Your account ‘) AWAIT TIMEOUT (500); Page.Type (‘ INPUTHOLDER = Password “, ‘Your Password’) AWAIT TIMEOUT (1000); // 4. Click Verification Page.Click (‘. Getest_Radar_tip’ ) AWAIT TIMEOUT (1000); btn_position = await getBtnPosition (); // 5. Slide DRAG (NULL)} / ** * Calculating button Requires Sliding Distance * * / async function calculateDistance () {const distance = await page.evaluate (() => {// comparison pixel, to find the approximate location of the notch function compare (document) {const ctx1 = document.querySelector () ‘geetest_canvas_fullbg.’; // complete image const ctx2 = document.querySelector ( ‘geetest_canvas_bg.’ ); // with gap picture const pixeldiFference = 30; // Pixel difference let res = []; // 保 坐 坐 对 对 对 对 (= 57; i

{const {ClientWidth, ClientHeight} = Document.QuerySelector ( ‘.geetest_popup_ghost’) return {btn_left: clientWidth / 2-104, btn_top: clientHeight / 2 + 59}}) return btn_position;} / ** * * distance attempt sliding distance of the slide button @param * * / async function tryValidation ( Distance) {// Spread to two, simulate normal people’s behavior constance1 = distance – 10 const distance2 = 10 Page.Mouse.click (btn_position.btn_left, btn_position.btn_top, {delay: 2000}) Page. mouse.down (btn_position.btn_left, btn_position.btn_top) page.mouse.move (btn_position.btn_left + distance1, btn_position.btn_top, {steps: 30}) await timeout (800); page.mouse.move (btn_position.btn_left + Distance1 + distance2, btn_position.btn_top, {steps: 20}) AWAIT TIMEOUT (800); Page.Mouse.Up () AWAIt timeout (4000); // determines whether the verification is successful const isSuccess = await page.evaluate await (() => {return document.querySelector ( ‘geetest_success_radar_tip_content.’) && document.querySelector ( ‘geetest_success_radar_tip_content.’) innerHTML.}) timeout (1000); // determines whether to recalculate the distance await page.evaluate const reDistance = (() => {return document.querySelector () && document.querySelector ( ‘geetest_result_content.’) innerHTML ‘geetest_result_content.’.}) AWAIT TIMEOUT (1000); return {Issuccess: Issuccess === ‘Verification success’, redistance: redistance.includes (‘ monster ate “}} / ** * Drag slider * @Param distance slider * * * * * / async function drag (distance) {distance = distance || await calculateDistance (); const result = await tryValidation (distance.min) if (result.isSuccess) {await timeout (1000); // log console.log ( ‘verification Success’) Page.clICK (‘# modal-member-login button)} else if (result.redistance) {console.log (‘ recalculating slipper, resilient ‘) Times = 0 AWAIT DRAG (NULL)} else {ix (DistanceError [Times]) {Times ++ Console.log (‘Sliding’) AWAIT DRAG ({MIN: DISTANCE.MAX, MAX: DISTANCE.MAX + DISTANCEERROR [TIMES]})} Else {Console.log (‘Sliding Failed ” Times = 0 Run ()}}}} run () package.json {“name”: “demo”, “Version”: “1.0”, “dependencies”: {“PuPpeteer”: “^ 1.0.0” }}
  Operation <260;i++){
  for(let j=1;j<160;j++) {
   const imgData1 = ctx1.getContext("2d").getImageData(1*i,1*j,1,1)
   const imgData2 = ctx2.getContext("2d").getImageData(1*i,1*j,1,1)
   const data1 = imgData1.data;
   const data2 = imgData2.data;
   const res1=Math.abs(data1[0]-data2[0]);
   const res2=Math.abs(data1[1]-data2[1]);
   const res3=Math.abs(data1[2]-data2[2]);
    if(!(res1 < pixelDifference && res2 < pixelDifference && res3   
1. Save this two files below the folder, the terminal switches to the current path
2. NPM i

3. Replenish the account number, password

4. Node Run

Demo

The following picture can be divided into four steps:

1. Open the login page, enter the account password written in advance.

2. The first drag slider prompt “Eat is eaten by the monster”, so the gap distance of the new picture is recalculated. 3. Second, three drag prompt “not correct comprehension”, so re-drag. 4. Verification is successful, login.

(Please place the mouse to view the demo effect on GIF, or drag to a new windowOpen GIF)

1. Sliding verification has three Canvas, where only classname is’ getest_canvas_fullbg ‘and’ Getest_canvas_bg ‘performs pixel difference contrast. PS: The former is a full picture, the latter is a picture with a gap.

2. Each picture with a gap has a misleading shadow, so when the contrast is poor, the calculated distance is misleading shadows and gaps, respectively. Therefore, the value of the sliding distance, I take ‘{min: res [0] -7, max: res.lendth-1] -54}’. When the gap is longer than the shadow, the MIN (minimum) value is the sliding distance, otherwise the max (maximum distance) minus the slider width.

使用puppeteer破解极验的滑动验证码 3. Three cases of sliding results: the verification is successful, it is eaten, failed. “Sooked” will reclaim the picture, so recalculate the distance and slide; “fail” is resilient, if the implementation of 4 times is still failed, re-RUN will.

The above is the sliding verification code for the use of PuPpeteer cracking the extreme test, I hope everyone can help everyone, if everyone has any If you have questions, please leave a message, the small package will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment