news 2026/6/19 11:45:48

一个cdp的检测

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
一个cdp的检测

那么cdp 有没有办法被检测呢?(这是极简的一篇)

这里让ai给出了一个代码

importtimefromDrissionPageimportChromium# 连接浏览器browser=Chromium()tab=browser.latest_tab tab.get('https://www.baidu.com')# 修改后的JS代码 - 关键是最后要同步返回结果# 纯同步检测版本(去掉端口扫描)js=""" var aa=function(){ const result = { isBot: false, riskLevel: 'LOW', suspiciousCount: 0, detections: {} }; // 1. WebDriver检测 const webDriver = { 'navigator.webdriver': navigator.webdriver === true, 'document.$cdc_*': !!(document.$cdc_asdjflasutopfhvcZLmcfl_ || document.$chrome_asyncScriptInfo), '__webdriver_*': !!(window.__webdriver_evaluate || window.__selenium_evaluate || window.__webdriver_script_function), 'callPhantom': typeof window.callPhantom === 'function', '_phantom': typeof window._phantom !== 'undefined', '__nightmare': typeof window.__nightmare !== 'undefined', }; // 2. Chrome自动化检测 const chromeAuto = { 'chrome.runtime异常': (() => { if (!window.chrome || !window.chrome.runtime) return false; try { window.chrome.runtime.sendMessage('test'); return false; } catch (e) { return e.message.includes('Extension'); } })(), 'chrome.loadTimes': typeof window.chrome?.loadTimes === 'function', 'chrome.csi': typeof window.chrome?.csi === 'function', 'plugins为空': navigator.plugins.length === 0, 'languages异常': navigator.languages.length === 0, 'headless UA': /HeadlessChrome/i.test(navigator.userAgent), 'window尺寸为0': window.outerWidth === 0 || window.outerHeight === 0, }; // 3. 高级特征检测 const advanced = { 'Function.toString被修改': (() => { const testFunc = function test() {}; const str = Function.prototype.toString.call(testFunc); return !str.includes('test'); })(), 'CDP全局污染': ['__coverage__', '__playwright', '__puppeteer_evaluation_script__'] .some(marker => marker in window), 'webdriver descriptor被修改': (() => { const desc = Object.getOwnPropertyDescriptor(Navigator.prototype, 'webdriver'); return desc && desc.get !== undefined; })(), 'permissions异常': (() => { try { const desc = Object.getOwnPropertyDescriptor(Permissions.prototype, 'query'); return desc && desc.value.toString() === 'function query() { [native code] }'; } catch { return false; } })(), }; // 4. 计算可疑项 let suspiciousCount = 0; suspiciousCount += Object.values(webDriver).filter(v => v).length; suspiciousCount += Object.values(chromeAuto).filter(v => v).length; suspiciousCount += Object.values(advanced).filter(v => v).length; // 5. 判断风险等级 let riskLevel = 'LOW'; if (suspiciousCount >= 10) riskLevel = 'CRITICAL'; else if (suspiciousCount >= 5) riskLevel = 'HIGH'; else if (suspiciousCount >= 2) riskLevel = 'MEDIUM'; result.isBot = suspiciousCount >= 2; result.riskLevel = riskLevel; result.suspiciousCount = suspiciousCount; result.detections = { webDriver, chromeAuto, advanced }; return result; }; return aa(); """# 执行JS并获取结果print('🔍 开始检测CDP特征...\n')result=tab.run_js(js)print(result)# 格式化输出print('='*70)print(' '*25+'CDP检测报告')print('='*70)# 主要结果ifresult['isBot']:print(f"🤖 检测结果:{'是机器人 ❌':>30}")else:print(f"🤖 检测结果:{'正常浏览器 ✅':>30}")print(f"⚠️ 风险等级:{result['riskLevel']:>30}")print(f"🎯 可疑项数:{result['suspiciousCount']:>30}")print('='*70)# 详细检测项detections=result['detections']print('\n【WebDriver 特征检测】')print('-'*70)forkey,valueindetections['webDriver'].items():status='🔴 检测到'ifvalueelse'🟢 未检测'print(f"{status:<12}{key}")print('\n【Chrome 自动化特征】')print('-'*70)forkey,valueindetections['chromeAuto'].items():status='🔴 检测到'ifvalueelse'🟢 未检测'print(f"{status:<12}{key}")print('\n【高级特征检测】')print('-'*70)forkey,valueindetections['advanced'].items():status='🔴 检测到'ifvalueelse'🟢 未检测'print(f"{status:<12}{key}")print('\n'+'='*70)# 给出建议ifresult['isBot']:print('\n⚠️ 警告: 检测到自动化控制特征!')print('\n💡 改进建议:')ifdetections['webDriver']['navigator.webdriver']:print(' • 使用 --disable-blink-features=AutomationControlled')ifdetections['chromeAuto']['plugins为空']:print(' • 添加fake plugins配置')ifdetections['chromeAuto']['headless UA']:print(' • 使用正常的User-Agent')ifdetections['advanced']['webdriver descriptor被修改']:print(' • 使用stealth.js插件')else:print('\n✅ 未检测到明显的自动化特征,伪装良好!')print('\n'+'='*70)time.sleep(5)

运行结果:

======================================================================CDP检测报告======================================================================🤖 检测结果:是机器人 ❌ ⚠️ 风险等级:MEDIUM 🎯 可疑项数:4======================================================================【WebDriver 特征检测】----------------------------------------------------------------------🟢 未检测 navigator.webdriver 🟢 未检测 document.$cdc_*🟢 未检测 __webdriver_*🟢 未检测 callPhantom 🟢 未检测 _phantom 🟢 未检测 __nightmare 【Chrome 自动化特征】----------------------------------------------------------------------🟢 未检测 chrome.runtime异常 🔴 检测到 chrome.loadTimes 🔴 检测到 chrome.csi 🟢 未检测 plugins为空 🟢 未检测 languages异常 🟢 未检测 headless UA 🟢 未检测 window尺寸为0【高级特征检测】----------------------------------------------------------------------🟢 未检测 Function.toString被修改 🟢 未检测 CDP全局污染 🔴 检测到 webdriver descriptor被修改 🔴 检测到 permissions异常======================================================================⚠️ 警告:检测到自动化控制特征!

打开浏览器9222 后运行js ,检测截图如下:

解法的话待后面再开新坑 <-_-!>

更多文章,敬请关注gzh:零基础爬虫第一天

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/9 21:01:35

实战指南:轻松解决Windows启动盘制作中的常见故障

在制作Windows启动盘的过程中&#xff0c;许多用户会遇到各种意想不到的问题&#xff0c;这些问题往往让原本简单的操作变得复杂。作为一款广受欢迎的USB启动盘制作工具&#xff0c;Rufus在帮助用户创建启动盘时也会遇到一些典型的故障情况。本文将为您详细解析这些问题的根源&…

作者头像 李华
网站建设 2026/6/15 18:30:27

如何快速掌握Kafka可视化:现代化管理工具终极指南

如何快速掌握Kafka可视化&#xff1a;现代化管理工具终极指南 【免费下载链接】Kafka-King A modern and practical kafka GUI client 项目地址: https://gitcode.com/gh_mirrors/ka/Kafka-King 在当今分布式系统架构中&#xff0c;Kafka作为核心消息队列组件&#xff0…

作者头像 李华
网站建设 2026/6/18 18:45:09

微信小程序二维码生成终极指南:掌握weapp-qrcode核心技巧

微信小程序二维码生成终极指南&#xff1a;掌握weapp-qrcode核心技巧 【免费下载链接】weapp-qrcode 微信小程序快速生成二维码&#xff0c;支持回调函数返回二维码临时文件 项目地址: https://gitcode.com/gh_mirrors/weap/weapp-qrcode 微信小程序二维码生成是现代小程…

作者头像 李华
网站建设 2026/6/10 18:09:00

Python打包终极指南:三步将.py文件转换为专业级exe可执行程序

还在为Python程序分发而烦恼吗&#xff1f;Auto PY to EXE正是你需要的解决方案&#xff01;这款免费工具通过直观的图形界面&#xff0c;让你轻松将Python脚本转换为独立的Windows可执行文件。本指南将带你从零开始&#xff0c;用实战演练的方式掌握这个强大工具的开发与贡献技…

作者头像 李华
网站建设 2026/6/19 2:36:50

ST7789显示屏驱动终极指南:MicroPython快速上手完整教程

还在为嵌入式设备的显示问题而烦恼吗&#xff1f;想要快速掌握ST7789显示屏的驱动方法却不知从何入手&#xff1f;本指南将带你从零开始&#xff0c;轻松玩转ST7789显示屏的MicroPython驱动。无论你是嵌入式开发新手还是有一定经验的开发者&#xff0c;都能在这里找到实用的解决…

作者头像 李华
网站建设 2026/6/10 9:23:59

PaddlePaddle边缘计算部署方案:Jetson Nano实测

PaddlePaddle边缘计算部署方案&#xff1a;Jetson Nano实测 在智能安防摄像头需要实时识别行人、工业质检设备要毫秒级响应缺陷检测的今天&#xff0c;把AI模型“搬”到终端设备上已不再是可选项&#xff0c;而是刚需。然而&#xff0c;当我们在树莓派上跑一个简单的图像分类都…

作者头像 李华