Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing window.navigator within puppeteer to bypass antibot system

I'm trying to make my online bot undetectable. I read number of articles how to do it and I took all tips together and used them. One of them is to change window.navigator.webdriver.

I managed to change window.navigator.webdriver within puppeteer by this code:

await page.evaluateOnNewDocument(() => {
    Object.defineProperty(navigator, 'webdriver', {
        get: () => undefined
    });
});

I'm bypassing this test just fine:

enter image description here

However this test is still laughing at me somehow:

enter image description here

Why WEBDRIVER is inconsistent?

like image 542
BT101 Avatar asked Dec 31 '22 22:12

BT101


1 Answers

Try this,

First, remove the definition, it will not work if you define and delete from prototype.

Object.defineProperty(navigator, 'webdriver', ()=>{}) // <-- delete this part

Replace your code with this one.

delete navigator.__proto__.webdriver;

Result: enter image description here

Why does it work?

Removing directly just remove the instance of the object rather than the actual definition. The getter and setter is still there, so browser can find it.

enter image description here

However if you remove from the actual prototype, it will not exist at all in any instance anymore.

enter image description here

Additional Tips

You mentioned you want to make your app undetectable, there are many plugins which achieve the same, for example this package called puppeteer-extra-plugin-stealth includes some cool anti-bot detection techniques. Sometimes it's better to just reuse some packages than to re-create a solution over and over again.

PS: I might be wrong above the above explanation, feel free to guide me so I can improve the answer.

like image 195
Md. Abu Taher Avatar answered Jan 03 '23 11:01

Md. Abu Taher