You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main2.js:This file was generated by the npx extract-stealth-evasions command.
code:(({_utilsFns:_utilsFns,_mainFunction:_mainFunction,_args:_args})=>{const utils=Object.fromEntries(Object.entries(_utilsFns).map((([key,value])=>[key,eval(value)])));utils.init(),eval(_mainFunction)(utils,..._args)})({_utilsFns:{init:"() => {\n utils.preloadCache()\n}",stripProxyFromErrors:"(handler = {}) => {\n const newHandler = {\n setPrototypeOf: function (target, proto) {\n if (proto === null)\n throw new TypeError('Cannot convert object to primitive value')\n if (Object.getPrototypeOf(target) === Object.getPrototypeOf(proto)) {\n throw new TypeError('Cyclic __proto__ value')\n }\n return Reflect.setPrototypeOf(target, proto)\n }\n }\n // We wrap each trap in the handler in a try/catch and modify the error stack if they throw\n const traps = Object.getOwnPropertyNames(handler)\n traps.forEach(trap => {\n newHandler[trap] = function () {\n try {\n // Forward the call to the defined proxy handler\n return handler[trap].apply(this, arguments || [])\n } catch (err) {\n // Stack traces differ per browser, we only support chromium based ones currently\n if (!err || !err.stack || !err.stack.includes(at )) {\n throw err\n }\n\n // When something throws within one of our traps the Proxy will show up in error stacks\n // An earlier implementation of this code would simply strip lines with a blacklist,\n // but it makes sense to be more surgical here and only remove lines related to our Proxy.\n // We try to use a known \"anchor\" line for that and strip it with everything above it.\n // If the anchor line cannot be found for some reason we fall back to our blacklist approach.\n\n const stripWithBlacklist = (stack, stripFirstLine = true) => {\n const blacklist = [\n at Reflect.${trap} , // e.g. Reflect.get or Reflect.apply\n at Object.${trap} , // e.g. Object.get or Object.apply\n at Object.newHandler. [as ${trap}] // caused by this very wrapper :-)\n ]\n return (\n err.stack\n .split('\\n')\n // Always remove the first (file) line in the stack (guaranteed to be our proxy)\n .filter((line, index) => !(index === 1 && stripFirstLine))\n // Check if the line starts with one of our blacklisted strings\n ...-----------------------Omit------------------------------省略----------Omit......_srcdoc\n })\n _iframe.srcdoc = newValue\n }\n })\n return iframe\n }\n\n // Adds a hook to intercept iframe creation events\n const addIframeCreationSniffer = () => {\n /* global document */\n const createElementHandler = {\n // Make toString() native\n get(target, key) {\n return Reflect.get(target, key)\n },\n apply: function(target, thisArg, args) {\n const isIframe =\n args && args.length &&${args[0]}.toLowerCase() === 'iframe'\n if (!isIframe) {\n // Everything as usual\n return target.apply(thisArg, args)\n } else {\n return handleIframeCreation(target, thisArg, args)\n }\n }\n }\n // All this just due to iframes with srcdoc bug\n utils.replaceWithProxy(\n document,\n 'createElement',\n createElementHandler\n )\n }\n\n // Let's go\n addIframeCreationSniffer()\n } catch (err) {\n // console.warn(err)\n }\n }",_args:[]});
Ultimately it is how do I call this main2.js file correctly to effectively insert stealth related robot monitoring?
The text was updated successfully, but these errors were encountered:
Rod Version: v0.114.8
The code to demonstrate your question
Clone Rod to your local and cd to the repository:
git clone https://github.com/go-rod/rod cd rod
Use your code to replace the content of function
TestRod
in filerod_test.go
.Test your code with:
go test -run TestRod
, make sure it fails as expected.Replace ALL THE CONTENT under "The code to demonstrate your question" with your
TestRod
function, like below:What you got
Such as what error you see.
What you expect to see
Such as what you want to do.
What have you tried to solve the question
Such as after modifying some source code of Rod you are able to get rid of the problem.
Is it correct for me to call stealth like this? I want the entire browser to pass detection effectively, not a single page. Code:
`package main
import (
"fmt"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/devices"
"github.com/go-rod/rod/lib/launcher"
"path/filepath"
"time"
)
var MyDevice = devices.Device{
Title: "Chrome computer",
Capabilities: []string{"touch", "mobile"},
UserAgent: "Mozilla/5.0 (Windows NT 18.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
AcceptLanguage: "cn",
Screen: devices.Screen{
DevicePixelRatio: 2,
Horizontal: devices.ScreenSize{
Width: 1920,
Height: 1080,
},
Vertical: devices.ScreenSize{
Width: 1920,
Height: 1080,
},
},
}
func main() {
//path, _ := launcher.LookPath()
extPath, err := filepath.Abs("fixtures/chrome-extension")
if err != nil {
fmt.Println("出错了:", err)
}
u := launcher.New().Set("--disable-blink-features", "AutomationControlled").Set("no-first-run").Set("disable-default-apps").
Set("load-extension", extPath).
Headless(false).MustLaunch()
}
`
The following is the manifest.json file under the chrome-extension directory under my fixtures directory code:
`{
"manifest_version": 2,
"name": "test",
"description": "Test extension",
"version": "1.0",
"content_scripts": [
{
"js": ["main2.js"],
"matches": ["<all_urls>"]
}
]
}`
main2.js:This file was generated by the npx extract-stealth-evasions command.
code:
(({_utilsFns:_utilsFns,_mainFunction:_mainFunction,_args:_args})=>{const utils=Object.fromEntries(Object.entries(_utilsFns).map((([key,value])=>[key,eval(value)])));utils.init(),eval(_mainFunction)(utils,..._args)})({_utilsFns:{init:"() => {\n utils.preloadCache()\n}",stripProxyFromErrors:"(handler = {}) => {\n const newHandler = {\n setPrototypeOf: function (target, proto) {\n if (proto === null)\n throw new TypeError('Cannot convert object to primitive value')\n if (Object.getPrototypeOf(target) === Object.getPrototypeOf(proto)) {\n throw new TypeError('Cyclic __proto__ value')\n }\n return Reflect.setPrototypeOf(target, proto)\n }\n }\n // We wrap each trap in the handler in a try/catch and modify the error stack if they throw\n const traps = Object.getOwnPropertyNames(handler)\n traps.forEach(trap => {\n newHandler[trap] = function () {\n try {\n // Forward the call to the defined proxy handler\n return handler[trap].apply(this, arguments || [])\n } catch (err) {\n // Stack traces differ per browser, we only support chromium based ones currently\n if (!err || !err.stack || !err.stack.includes(
at)) {\n throw err\n }\n\n // When something throws within one of our traps the Proxy will show up in error stacks\n // An earlier implementation of this code would simply strip lines with a blacklist,\n // but it makes sense to be more surgical here and only remove lines related to our Proxy.\n // We try to use a known \"anchor\" line for that and strip it with everything above it.\n // If the anchor line cannot be found for some reason we fall back to our blacklist approach.\n\n const stripWithBlacklist = (stack, stripFirstLine = true) => {\n const blacklist = [\n
at Reflect.${trap}, // e.g. Reflect.get or Reflect.apply\n
at Object.${trap}, // e.g. Object.get or Object.apply\n
at Object.newHandler. [as ${trap}]// caused by this very wrapper :-)\n ]\n return (\n err.stack\n .split('\\n')\n // Always remove the first (file) line in the stack (guaranteed to be our proxy)\n .filter((line, index) => !(index === 1 && stripFirstLine))\n // Check if the line starts with one of our blacklisted strings\n ...-----------------------Omit------------------------------省略----------Omit......_srcdoc\n })\n _iframe.srcdoc = newValue\n }\n })\n return iframe\n }\n\n // Adds a hook to intercept iframe creation events\n const addIframeCreationSniffer = () => {\n /* global document */\n const createElementHandler = {\n // Make toString() native\n get(target, key) {\n return Reflect.get(target, key)\n },\n apply: function(target, thisArg, args) {\n const isIframe =\n args && args.length &&
${args[0]}.toLowerCase() === 'iframe'\n if (!isIframe) {\n // Everything as usual\n return target.apply(thisArg, args)\n } else {\n return handleIframeCreation(target, thisArg, args)\n }\n }\n }\n // All this just due to iframes with srcdoc bug\n utils.replaceWithProxy(\n document,\n 'createElement',\n createElementHandler\n )\n }\n\n // Let's go\n addIframeCreationSniffer()\n } catch (err) {\n // console.warn(err)\n }\n }",_args:[]});
Ultimately it is how do I call this main2.js file correctly to effectively insert stealth related robot monitoring?
The text was updated successfully, but these errors were encountered: