Python 2.7.14
mitmproxy 4.0.4
mitmproxy api 0.18.3
安装mimtproxy后,运行mitmdump并没有在运行目录下生成证书,需要以下步骤
.设置chrome代理为mitmproxy
.在chrome中打开http://mitm.it
.下载证书
.安装证书
目的是绕过目标网站对selenuim的屏蔽.
方法如下:
1.修改index.js中的代码,使其检测为false
function r() {
return "$cdc_asdjflasutopfhvcZLmcfl_"in u || f.webdriver
}
2.修改window.navigator.webdriver为false
3.禁用cache
通过mitmproxy代理执行脚本,修改index.js的内容.脚本(addons.py)如下:
import mitmproxy.http
from mitmproxy import ctx
class Filter:
def response(self,flow:mitmproxy.http.HTTPFlow):
if '/3.6.8/index.js' in flow.request.url:
flow.response.text = flow.response.text.replace('$cdc_asdjflasutopfhvcZLmcfl_', 'kddkalse')
flow.response.text = flow.response.text.replace('f.webdriver', 'false')
flow.response.text = flow.response.text.replace('ChromeDriver', '')
addons = [
Filter()
]
启动代理:
>mitmdump -s addons.py
Loading script addons.py
Proxy server listening at http://*:8080
设置chrome代理:
127.0.0.1 8080
java测试程序
禁用cache
ChromeOptions Options = new ChromeOptions();
Options.addArguments("disable-cache");
修改window.navigator.webdriver为false
String js = "Object.defineProperty(navigator, 'webdriver', { get: () => false, });";
JavascriptExecutor jse=(JavascriptExecutor) driver;
jse.executeScript(js);
经检查对比:
--index.js代码已修改
--window.navigator.webdriver为false
自动登录仍然失败.自动连续测试全部失败.
java测试程序断点停住或者退出,再手动操作,拖动滑块也失败.
以下手动操作会成功:
.刷新页面
.在开发者工具console中执行
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
});
.输入账号,密码
.此时没有滑动条出现,可点击登录,登录成功.
程序模拟这些步骤,仍然失败.
甚至,手动准备好,程序执行登录点击操作,也是失败。
nc.js 4265行: _.jsonp调用. 难道去分析代码?
_.jsonp({
url: ajaxURL.analyze,
callback: "callback",
data: {
a: opt.appkey,
t: opt.token,
n: me.__uab.getUA && me.__uab.getUA(me.__uaoption) || win[UA_Opt.LogVal || "_n"] || "",
p: _.obj2str(trans),
scene: opt.scene || (inn_vars.has_pointman ? pointman.config.common.scene : "") || "",
asyn: 0,
lang: opt.language,
v: inn_vars.v
},
准备用autoit试试.
Mitmproxy 拦截、mock移动设备网络请求
https://blog.csdn.net/countofdane/article/details/82055173
pyppeteer 绕过selenium检测,实现淘宝登陆
https://blog.csdn.net/Chen_chong__/article/details/82950968
探测selenium-webdriver及破解淘宝对selenium-webdriver的拦截
https://www.kebook.cn/9060/
反爬虫中chrome无头浏览器的几种检测与绕过方式
https://blog.csdn.net/Revivedsun/article/details/81785000
Can a website detect when you are using selenium with chromedriver?
https://stackoverflow.com/questions/33225947/can-a-website-detect-when-you-are-using-selenium-with-chromedriver