1. 使用工具

https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html 程序访问该页面, 所有检测项均为绿色,则通过

2. webDriver防检测方法

  1. await page.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36");
  2. await page.evaluateOnNewDocument(() => {
  3. delete navigator.__proto__.webdriver;
  4. });
  5. await page.evaluateOnNewDocument(() => {
  6. Object.defineProperty(navigator, 'plugins', {
  7. get: () => [1, 2, 3, 4, 5],
  8. });
  9. });
  10. await page.evaluateOnNewDocument(() => {
  11. Object.defineProperty(navigator, 'languages', {
  12. get: () => ['en-US', 'en'],
  13. });
  14. });
  15. await page.evaluateOnNewDocument(() => {
  16. Object.defineProperty(navigator, 'platform', {
  17. get: () => "Linux armxxxxx",
  18. configurable: true
  19. });
  20. });
  21. await page.evaluateOnNewDocument(() => {
  22. window.navigator.chrome = {
  23. runtime: {},
  24. getUserMedia: {},
  25. };
  26. });
  27. await page.goto(`https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html`);

2.1 永久注入js, 每次打开新页面注入

  1. await page.evaluateOnNewDocument(() => {
  2. Object.defineProperty(navigator, 'webdriver', {
  3. get: () => false,
  4. });
  5. });

2.2 当前页面注入, 页面跳转后js失效

  1. await page.evaluate(
  2. async () => {
  3. Object.defineProperty(navigator, 'webdriver', {get: () => false})
  4. })

2.3 删除

  1. await page.evaluateOnNewDocument(() => {
  2. delete navigator.__proto__.webdriver;
  3. });

3 检测浏览器指纹

参考git
News: A new detection test is available on this page. It is specifically crafted to distinguish real Chrome browsers from Chrome headless browsers. Feel free to challenge it to see if your advanced Chrome headless crawlers are detected, even when they try to hide their presence.

Your browser fingerprint (collected with Fp-Collect)

Your browser fingerprint is collected using the latest version of Fp-Collect.Thus, you may see attributes that are not available yet in the npm version.

Attribute Value
plugins [“Chrome PDF Plugin::Portable Document Format::internal-pdf-viewer::application/x-google-chrome-pdf~pdf~Portable Document Format”,”Chrome PDF Viewer::::mhjfbmdgcfjbbpaeojofohoefgiehjai::application/pdf~pdf~”,”Native Client::::internal-nacl-plugin::__application/x-naclNative Client Executable,application/x-pnaclPortable Native Client Executable”]
mimeTypes [“application/pdfpdf”,”Portable Document Formatapplication/x-google-chrome-pdfpdf”,”Native Client Executableapplication/x-nacl“,”Portable Native Client Executableapplication/x-pnacl“]
userAgent “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36”
byteLength 1
gamut [true,false,false,true]
anyPointer “fine”
anyHover “hover”
appVersion “5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36”
appName “Netscape”
appCodeName “Mozilla”
onLine true
cookieEnabled true
doNotTrack false
cpuClass undefined
hardwareConcurrency 8
platform “Win32”
oscpu “unknown”
timezone -480
historyLength 2
computedStyleBody “animation-delayanimation-directionanimation-durationanimation-fill-modeanimation-iteration-countanimation-nameanimation-play-stateanimation-timing-functionbackground-attachmentbackground-blend-modebackground-clipbackground-colorbackground-imagebackground-originbackground-positionbackground-repeatbackground-sizeborder-bottom-colorborder-bottom-left-radiusborder-bottom-right-radiusborder-bottom-styleborder-bottom-widthborder-collapseborder-image-outsetborder-image-repeatborder-image-sliceborder-image-sourceborder-image-widthborder-left-colorborder-left-styleborder-left-widthborder-right-colorborder-right-styleborder-right-widthborder-top-colorborder-top-left-radiusborder-top-right-radiusborder-top-styleborder-top-widthbottombox-shadowbox-sizingbreak-afterbreak-beforebreak-insidecaption-sideclearclipcolorcontentcursordirectiondisplayempty-cellsfloatfont-familyfont-kerningfont-sizefont-stretchfont-stylefont-variantfont-variant-ligaturesfont-variant-capsfont-variant-numericfont-variant-east-asianfont-weightheightimage-renderingisolationjustify-itemsjustify-selfleftletter-spacingline-heightlist-style-imagelist-style-positionlist-style-typemargin-bottommargin-leftmargin-rightmargin-topmax-heightmax-widthmin-heightmin-widthmix-blend-modeobject-fitobject-positionoffset-distanceoffset-pathoffset-rotateopacityorphansoutline-coloroutline-offsetoutline-styleoutline-widthoverflow-anchoroverflow-wrapoverflow-xoverflow-ypadding-bottompadding-leftpadding-rightpadding-toppointer-eventspositionresizerightscroll-behaviorspeaktable-layouttab-sizetext-aligntext-align-lasttext-decorationtext-decoration-linetext-decoration-styletext-decoration-colortext-decoration-skip-inktext-underline-positiontext-indenttext-renderingtext-shadowtext-size-adjusttext-overflowtext-transformtoptouch-actiontransition-delaytransition-durationtransition-propertytransition-timing-functionunicode-bidivertical-alignvisibilitywhite-spacewidowswidthwill-changeword-breakword-spacingz-indexzoom-webkit-appearancebackface-visibility-webkit-border-horizontal-spacing-webkit-border-image-webkit-border-vertical-spacing-webkit-box-align-webkit-box-decoration-break-webkit-box-direction-webkit-box-flex-webkit-box-ordinal-group-webkit-box-orient-webkit-box-pack-webkit-box-reflectcolumn-countcolumn-gapcolumn-rule-colorcolumn-rule-stylecolumn-rule-widthcolumn-spancolumn-widthalign-contentalign-itemsalign-selfflex-basisflex-growflex-shrinkflex-directionflex-wrapjustify-content-webkit-font-smoothinggrid-auto-columnsgrid-auto-flowgrid-auto-rowsgrid-column-endgrid-column-startgrid-template-areasgrid-template-columnsgrid-template-rowsgrid-row-endgrid-row-startrow-gap-webkit-highlighthyphens-webkit-hyphenate-character-webkit-line-break-webkit-line-clamp-webkit-locale-webkit-margin-before-collapse-webkit-margin-after-collapse-webkit-mask-box-image-webkit-mask-box-image-outset-webkit-mask-box-image-repeat-webkit-mask-box-image-slice-webkit-mask-box-image-source-webkit-mask-box-image-width-webkit-mask-clip-webkit-mask-composite-webkit-mask-image-webkit-mask-origin-webkit-mask-position-webkit-mask-repeat-webkit-mask-sizeorderperspectiveperspective-origin-webkit-print-color-adjust-webkit-rtl-orderingshape-outsideshape-image-thresholdshape-margin-webkit-tap-highlight-color-webkit-text-combine-webkit-text-decorations-in-effect-webkit-text-emphasis-color-webkit-text-emphasis-position-webkit-text-emphasis-style-webkit-text-fill-color-webkit-text-orientation-webkit-text-security-webkit-text-stroke-color-webkit-text-stroke-widthtransformtransform-origintransform-style-webkit-user-drag-webkit-user-modifyuser-select-webkit-writing-mode-webkit-app-regionbuffered-renderingclip-pathclip-rulemaskfilterflood-colorflood-opacitylighting-colorstop-colorstop-opacitycolor-interpolationcolor-interpolation-filterscolor-renderingfillfill-opacityfill-rulemarker-endmarker-midmarker-startmask-typeshape-renderingstrokestroke-dasharraystroke-dashoffsetstroke-linecapstroke-linejoinstroke-miterlimitstroke-opacitystroke-widthalignment-baselinebaseline-shiftdominant-baselinetext-anchorwriting-modevector-effectpaint-orderdcxcyxyrrxrycaret-colorline-break”
languages [“zh-CN”,”zh”,”en”]
language “zh-CN”
indexedDB true
openDatabase true
screen {“wInnerHeight”:838,”wOuterHeight”:940,”wOuterWidth”:1739,”wInnerWidth”:1740,”wScreenX”:1238,”wPageXOffset”:0,”wPageYOffset”:0,”cWidth”:1740,”cHeight”:726,”sWidth”:1739,”sHeight”:979,”sAvailWidth”:1739,”sAvailHeight”:940,”sColorDepth”:24,”sPixelDepth”:24,”wDevicePixelRatio”:1.1041666269302368}
touchScreen [0,false,false]
videoCard [“Google Inc.”,”ANGLE (Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0)”]
multimediaDevices {“speakers”:3,”micros”:3,”webcams”:1}
productSub “20030107”
product “Gecko”
navigatorPrototype [“vendorSub~function get vendorSub() { [native code] }”,”productSub~function get productSub() { [native code] }”,”vendor~function get vendor() { [native code] }”,”maxTouchPoints~function get maxTouchPoints() { [native code] }”,”hardwareConcurrency~function get hardwareConcurrency() { [native code] }”,”cookieEnabled~function get cookieEnabled() { [native code] }”,”appCodeName~function get appCodeName() { [native code] }”,”appName~function get appName() { [native code] }”,”appVersion~function get appVersion() { [native code] }”,”platform~function get platform() { [native code] }”,”product~function get product() { [native code] }”,”userAgent~function get userAgent() { [native code] }”,”language~function get language() { [native code] }”,”languages~function get languages() { [native code] }”,”onLine~function get onLine() { [native code] }”,”doNotTrack~function get doNotTrack() { [native code] }”,”geolocation~function get geolocation() { [native code] }”,”mediaCapabilities~function get mediaCapabilities() { [native code] }”,”connection~function get connection() { [native code] }”,”plugins~function get plugins() { [native code] }”,”mimeTypes~function get mimeTypes() { [native code] }”,”webkitTemporaryStorage~function get webkitTemporaryStorage() { [native code] }”,”webkitPersistentStorage~function get webkitPersistentStorage() { [native code] }”,”getBattery~function getBattery() { [native code] }”,”sendBeacon~function sendBeacon() { [native code] }”,”getGamepads~function getGamepads() { [native code] }”,”javaEnabled~function javaEnabled() { [native code] }”,”vibrate~function vibrate() { [native code] }”,”requestMIDIAccess~function requestMIDIAccess() { [native code] }”,”userActivation~function get userActivation() { [native code] }”,”mediaSession~function get mediaSession() { [native code] }”,”permissions~function get permissions() { [native code] }”,”registerProtocolHandler~function registerProtocolHandler() { [native code] }”,”unregisterProtocolHandler~function unregisterProtocolHandler() { [native code] }”,”constructor~function Navigator() { [native code] }”,”deviceMemory~function get deviceMemory() { [native code] }”,”clipboard~function get clipboard() { [native code] }”,”credentials~function get credentials() { [native code] }”,”keyboard~function get keyboard() { [native code] }”,”locks~function get locks() { [native code] }”,”mediaDevices~function get mediaDevices() { [native code] }”,”serviceWorker~function get serviceWorker() { [native code] }”,”storage~function get storage() { [native code] }”,”presentation~function get presentation() { [native code] }”,”bluetooth~function get bluetooth() { [native code] }”,”usb~function get usb() { [native code] }”,”requestMediaKeySystemAccess~function () { [native code] }”,”getUserMedia~function () { [native code] }”,”webkitGetUserMedia~function () { [native code] }”,”constructor~function Navigator() { [native code] }”,”defineGetter~”,”defineSetter~”,”hasOwnProperty~”,”lookupGetter~”,”lookupSetter~”,”isPrototypeOf~”,”propertyIsEnumerable~”,”toString~”,”valueOf~”,”proto~”,”toLocaleString~~~”]
etsl 33
screenDesc “function get width() { [native code] }”
phantomJS [false,false,false]
nightmareJS false
selenium [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]
webDriver false
webDriverValue undefined
fmget false
domAutomation false
errorsGenerated [“azeaze is not defined”,null,null,null,null,null,null,”Failed to construct ‘WebSocket’: The URL ‘itsgonnafail’ is invalid.”]
resOverflow {“depth”:11423,”errorMessage”:”Maximum call stack size exceeded”,”errorName”:”RangeError”,”errorStacklength”:774}
accelerometerUsed false
audio {“nt_vc_output”:{“ac-baseLatency”:0.01,”ac-sampleRate”:48000,”ac-state”:”suspended”,”ac-maxChannelCount”:2,”ac-numberOfInputs”:1,”ac-numberOfOutputs”:0,”ac-channelCount”:2,”ac-channelCountMode”:”explicit”,”ac-channelInterpretation”:”speakers”,”an-fftSize”:2048,”an-frequencyBinCount”:1024,”an-minDecibels”:-100,”an-maxDecibels”:-30,”an-smoothingTimeConstant”:0.8,”an-numberOfInputs”:1,”an-numberOfOutputs”:1,”an-channelCount”:2,”an-channelCountMode”:”max”,”an-channelInterpretation”:”speakers”},”pxi_output”:124.0434474653739}
screenMediaQuery true
hasChrome true
detailChrome {“properties”:”unknown”,”connect”:206,”sendMessage”:169}
permissions {“state”:”prompt”,”permission”:”default”}
iframeChrome “object”
debugTool false
battery true
deviceMemory 8
tpCanvas {“0”:0,”1”:0,”2”:0,”3”:0}
canvas image.png
sequentum false
audioCodecs {“ogg”:”probably”,”mp3”:”probably”,”wav”:”probably”,”m4a”:”maybe”,”aac”:”probably”}
videoCodecs {“ogg”:”probably”,”h264”:”probably”,”webm”:”probably”,”mpeg4v”:””,”mpeg4a”:””,”theora”:””}
redPill 0
redPill2 200012
redPill3 “52,54,56,54,58,18,17,14,13,12,13,13,22,149,”

Result of Fp-scanner

Each test can have 3 different values:

  1. Consistent: The scanner did not detect any anomaly.
  2. Unsure: The scanner considers that the attributes tested could indicate the presence of a bot, but there is still a chance that it is a human.
  3. Inconsistent: The scanner considers that the attributes tested indicate the presence of a bot.

The fingerprints we collect through this page help us improve Fp-scanner. We analyze the data to create new tests as well as to remove false positives and false negatives.

Test Result Data
PHANTOM_UA Consistent {“userAgent”:”Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36”}
PHANTOM_PROPERTIES Consistent {“attributesFound”:[false,false,false]}
PHANTOM_ETSL Consistent {“etsl”:33}
PHANTOM_LANGUAGE Consistent {“languages”:[“zh-CN”,”zh”,”en”]}
PHANTOM_WEBSOCKET Consistent {“error”:”Failed to construct ‘WebSocket’: The URL ‘itsgonnafail’ is invalid.”}
MQ_SCREEN Consistent {}
PHANTOM_OVERFLOW Consistent {“depth”:11423,”errorMessage”:”Maximum call stack size exceeded”,”errorName”:”RangeError”,”errorStacklength”:774}
PHANTOM_WINDOW_HEIGHT Consistent {“wInnerHeight”:838,”wOuterHeight”:940,”wOuterWidth”:1739,”wInnerWidth”:1740,”wScreenX”:1238,”wPageXOffset”:0,”wPageYOffset”:0,”cWidth”:1740,”cHeight”:726,”sWidth”:1739,”sHeight”:979,”sAvailWidth”:1739,”sAvailHeight”:940,”sColorDepth”:24,”sPixelDepth”:24,”wDevicePixelRatio”:1.1041666269302368}
HEADCHR_UA Consistent {“userAgent”:”Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36”}
WEBDRIVER Consistent {}
HEADCHR_CHROME_OBJ Consistent {}
HEADCHR_PERMISSIONS Consistent {}
HEADCHR_PLUGINS Consistent {“plugins”:[“Chrome PDF Plugin::Portable Document Format::internal-pdf-viewer::application/x-google-chrome-pdf~pdf~Portable Document Format”,”Chrome PDF Viewer::::mhjfbmdgcfjbbpaeojofohoefgiehjai::application/pdf~pdf~”,”Native Client::::internal-nacl-plugin::__application/x-naclNative Client Executable,application/x-pnaclPortable Native Client Executable”]}
HEADCHR_IFRAME Consistent {}
CHR_DEBUG_TOOLS Consistent {}
SELENIUM_DRIVER Consistent {“attributesFound”:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}
CHR_BATTERY Consistent {}
CHR_MEMORY Consistent {}
TRANSPARENT_PIXEL Consistent {“0”:0,”1”:0,”2”:0,”3”:0}
SEQUENTUM Consistent {}
VIDEO_CODECS Consistent {“h264”:”probably”}