1. 使用工具
https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html 程序访问该页面, 所有检测项均为绿色,则通过
2. webDriver防检测方法
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");
await page.evaluateOnNewDocument(() => {
delete navigator.__proto__.webdriver;
});
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'plugins', {
get: () => [1, 2, 3, 4, 5],
});
});
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'languages', {
get: () => ['en-US', 'en'],
});
});
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'platform', {
get: () => "Linux armxxxxx",
configurable: true
});
});
await page.evaluateOnNewDocument(() => {
window.navigator.chrome = {
runtime: {},
getUserMedia: {},
};
});
await page.goto(`https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html`);
2.1 永久注入js, 每次打开新页面注入
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
});
});
2.2 当前页面注入, 页面跳转后js失效
await page.evaluate(
async () => {
Object.defineProperty(navigator, 'webdriver', {get: () => false})
})
2.3 删除
await page.evaluateOnNewDocument(() => {
delete navigator.__proto__.webdriver;
});
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-nacl |
mimeTypes | [“ |
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 |
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 | ![]() |
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:
- Consistent: The scanner did not detect any anomaly.
- 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.
- 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-nacl |
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”} |