berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.39k stars 738 forks source link

[Stealth] Is it possible to change platform type? #203

Open thegeekybaniya opened 4 years ago

thegeekybaniya commented 4 years ago

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 commented 4 years ago

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") `

txrp0x9 commented 4 years ago

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

StevenVeshkini commented 4 years ago

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);
sktnetwork commented 8 months ago

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

dannyokec commented 7 months ago

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 commented 7 months ago

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

StackedQueries commented 7 months ago

@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?