Python Selenium 抓包注入记录
模拟登录淘宝
https://segmentfault.com/q/1010000022661044/a-1020000022674394
试了一下是可以正常登录的,没有要求滑块等任何验证。
环境:火狐Developer 66.0b14 (64 位),电信ip
部分注入脚本:
JavaScript 全选
function callInPageContent(func) {
// run in html script
// 此实现为FF特性, 仅在FF可用
// 其他浏览器可以插入script来实现
window.eval("(" + func.toSource() + ")();");
}
(() => {
// run in content script
callInPageContent(() => {
Object.defineProperty(window.navigator, 'webdriver', {
get: () => undefined
});
Object.defineProperty(window.navigator, 'platform', {
get: () => 'Win64'
});
Object.defineProperty(window.navigator, 'hardwareConcurrency', {
get: () => 4
});
Object.defineProperty(window.navigator, 'oscpu', {
get: () => 'Win64'
});
const rawGetContext = window.HTMLCanvasElement.prototype.getContext;
Object.defineProperty(window.HTMLCanvasElement.prototype, 'getContext', {
get: () => function (s) {
if (s === 'experimental-webgl') {
return {
VENDOR: 7936,
RENDERER: 7937,
getExtension: function () {
return null;
},
getParameter: function (s) {
if (s === 7936 || s === 7937) {
return 'Mozilla';
}
return null;
},
getSupportedExtensions: function () {
return [
"ANGLE_instanced_arrays",
"EXT_blend_minmax",
"EXT_color_buffer_half_float",
"EXT_texture_compression_rgtc",
"EXT_frag_depth",
"EXT_sRGB",
"EXT_shader_texture_lod",
"EXT_texture_filter_anisotropic",
"OES_element_index_uint",
"OES_standard_derivatives",
"OES_texture_float",
"OES_texture_float_linear",
"OES_texture_half_float",
"OES_texture_half_float_linear",
"OES_vertex_array_object",
// "WEBGL_color_buffer_float",
// "WEBGL_compressed_texture_s3tc",
// "WEBGL_compressed_texture_s3tc_srgb",
// "WEBGL_debug_renderer_info",
// "WEBGL_debug_shaders",
// "WEBGL_depth_texture",
// "WEBGL_draw_buffers",
// "WEBGL_lose_context",
];
}
};
}
return rawGetContext.call(this, s);
}
});
const overwrite = function (name) {
const OLD = window.HTMLCanvasElement.prototype[name];
Object.defineProperty(window.HTMLCanvasElement.prototype, name, {
"value": function () {
const shift = {
'r': Math.floor(Math.random() * 10) - 5,
'g': Math.floor(Math.random() * 10) - 5,
'b': Math.floor(Math.random() * 10) - 5,
'a': Math.floor(Math.random() * 10) - 5
};
const width = this.width, height = this.height, context = this.getContext("2d");
const imageData = context.getImageData(0, 0, width, height);
for (let i = 0; i < height; i++) {
for (let j = 0; j < width; j++) {
const n = ((i * (width * 4)) + (j * 4));
imageData.data[n] = imageData.data[n] + shift.r;
imageData.data[n + 1] = imageData.data[n + 1] + shift.g;
imageData.data[n + 2] = imageData.data[n + 2] + shift.b;
imageData.data[n + 3] = imageData.data[n + 3] + shift.a;
}
}
context.putImageData(imageData, 0, 0);
return OLD.apply(this, arguments);
}
});
};
overwrite('toBlob');
overwrite('toDataURL');
// noinspection JSUnresolvedVariable
const originalQuery = window.navigator.permissions.query;
// noinspection JSUnresolvedVariable
window.navigator.permissions.query = (parameters) => (
parameters.name === 'notifications' ?
Promise.resolve({state: Notification.permission}) :
originalQuery(parameters)
);
const getParameter = window.WebGLRenderingContext.prototype.getParameter;
window.WebGLRenderingContext.prototype.getParameter = function (parameter) {
// UNMASKED_VENDOR_WEBGL
if (parameter === 37445) {
return 'Intel Open Source Technology Center';
}
// UNMASKED_RENDERER_WEBGL
if (parameter === 37446) {
return 'Mesa DRI Intel(R) Ivybridge Mobile ';
}
return getParameter(parameter);
};
});
// noinspection JSUnresolvedVariable
window.document.addEventListener('mousemove', evt => window.wrappedJSObject._adb_plugin_mm_evt = evt);
})();
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post 管理员