puppeteer-extra icon indicating copy to clipboard operation
puppeteer-extra copied to clipboard

[Stealth] Is it possible to change platform type?

Open thegeekybaniya opened this issue 4 years ago • 7 comments

image

I am trying to make my scripts look like they are from apple and windows devices I can easily change the userAgent in puppeteer using

await page.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36") but I am unable to find a way to change this navigator.platform setting even though I pass all the tests.

thegeekybaniya avatar May 18 '20 08:05 thegeekybaniya

image

Just putting it here I also tried this test with both Windows and mac User Agents and both of them passed, even though platform in both cases was showing Linux. Surprising.

`await page.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36")

await page.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36") `

thegeekybaniya avatar May 18 '20 09:05 thegeekybaniya

Have you tried something like Object.defineProperty(navigator,"platform", { get: function () { return "MacIntel"; }, set: function (a) {} });

txrp0x9 avatar May 27 '20 20:05 txrp0x9

If you are using the latest stealth plugin version:

const puppeteerExtra = addExtra(puppeteer);
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
const stealthPlugin = StealthPlugin();
const puppeteerExtraPluginUserAgentOverride = require("puppeteer-extra-plugin-stealth/evasions/user-agent-override");
stealthPlugin.enabledEvasions.delete("user-agent-override");
puppeteerExtra.use(stealthPlugin);
const pluginUserAgentOverride = puppeteerExtraPluginUserAgentOverride({
   userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"
   platform: "MacIntel",
});
puppeteerExtra.use(pluginUserAgentOverride);

StevenVeshkini avatar May 28 '20 08:05 StevenVeshkini

Shows error:

const puppeteerExtra = addExtra(puppeteer); ^

ReferenceError: addExtra is not defined at Object. (/home/skt/puppet/try2.js:3:24) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49

Node.js v20.10.0

sktnetwork avatar Jan 05 '24 17:01 sktnetwork

This is quite an issue, I noticed my adsense bot were getting banned for this years ago. The solution is to edit the binary of your puppeteer using a dis-assembler and link the value to a place in memory. Its quite simple but the issue is when ever you npm Install or update you have to Re crack the binary again

dannyokec avatar Feb 14 '24 14:02 dannyokec

Shows error:

const puppeteerExtra = addExtra(puppeteer);

                   ^

ReferenceError: addExtra is not defined

at Object.<anonymous> (/home/skt/puppet/try2.js:3:24)

at Module._compile (node:internal/modules/cjs/loader:1376:14)

at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)

at Module.load (node:internal/modules/cjs/loader:1207:32)

at Module._load (node:internal/modules/cjs/loader:1023:12)

at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)

at node:internal/main/run_main_module:28:49

Node.js v20.10.0

Use a dis-assembler. Google owns puppeteer remember??. The platform is part of an anti bot detection to avoid bot traffics. This is why userAgent and stealth can only do a few and google patches up any update against bot detection

dannyokec avatar Feb 14 '24 14:02 dannyokec

@dannyokec Is that issue in relation to the chromium binary that's installed w/ puppeteer, and would the same issue be present running something like chrome/another chromium based browser? Also, what tooling/funcs is Google using to pull browser binary data out?

StackedQueries avatar Feb 14 '24 14:02 StackedQueries