博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Chrome插件:本地程序实现验证码破解(浏览器与本地进程通信)
阅读量:4344 次
发布时间:2019-06-07

本文共 2540 字,大约阅读时间需要 8 分钟。

利用chrome调用本地程序破解图片验证码

background.js 

var port = null, tabId, fname = "vcode.chrome.v1.item.01";//对应注册表HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHostsvar hostname = 'com.dbing.net.host';//onNativeDisconnectfunction onDisconnected() {      port = null;}//function connect(data) {    port = chrome.runtime.connectNative(hostname);    port.onDisconnect.addListener(onDisconnected);    port.onMessage.addListener(onNativeMessage);    port.postMessage(data);}function onNativeMessage(msg) {    chrome.tabs.sendMessage(tabId, { cmd: 'setCode', code:msg });}// 监听消息chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {        tabId= sender.tab['id'];        if (!request.cmd) return;    if (request.cmd=='getCode')        connect(request.url);});

test.js

var nodeCode = document.getElementsByClassName('login-code');var nodeImg, timer;send();function send() {    if (nodeCode && nodeCode[0] && nodeCode[0].nextElementSibling) {         nodeCode[0].children[0].innerText = '';        nodeImg = nodeCode[0].nextElementSibling;        nodeImg.onload = function () { sendMsg(); }     }};function sendMsg() {   var r = nodeImg.getBoundingClientRect();        var rect = { x: r.x, y: r.y + window.outerHeight - window.innerHeight, width: r.width, height: r.height }       var rs = Math.round(rect.x) + ',' + Math.round(rect.y) + ',' + Math.round(rect.width) + ',' + Math.round(rect.height);       chrome.runtime.sendMessage({ cmd: 'getCode', url: rs });}// 监听消息chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {        if (request.cmd == 'setCode') {                console.log('setCode,login-code.length:', nodeCode.length)        if (!nodeCode) return;        nodeCode[0].children[1].value = request.code;        sendResponse({ status: 1 });    } });

app.json

{  "name": "com.dbing.net.host", //名称需跟注册表的项名称一致  "description": "open host pro",  "path": "C:\\Users\\Administrator\\Pro\\Demo\\Pro.AI\\bin\\Debug\\Pro.AI.exe",  "type": "stdio",  "allowed_origins": [    "chrome-extension://blejflebmbmpebolcigedgkclijabeop/"   ]}

manifest.json

{  "name": "本地管道通信", //名称  "description": "chrome.本地通讯.管道流", //介绍  "version": "1.0.1", //版本  "manifest_version": 2, //必须为2  "permissions": [    //必须,定义权限,需要和本地应用程序通信    "nativeMessaging",    "downloads"     ],  "content_scripts": [    {      "matches": [ "*://*.google.com/*" ],      "js": [ "test.js" ],      "run_at": "document_end"    }  ],  "background": { "scripts": [ "background.js" ] } }

 

转载于:https://www.cnblogs.com/he-bo/p/10127259.html

你可能感兴趣的文章
图论知识,博客
查看>>
[原创]一篇无关技术的小日记(仅作暂存)
查看>>
20145303刘俊谦 Exp7 网络欺诈技术防范
查看>>
原生和jQuery的ajax用法
查看>>
iOS开发播放文本
查看>>
20145202马超《java》实验5
查看>>
JQuery 事件
查看>>
main(argc,argv[])
查看>>
第四阶段 15_Linux tomcat安装与配置
查看>>
NAS 创建大文件
查看>>
学习笔记-模块之xml文件处理
查看>>
接口测试用例
查看>>
Sybase IQ导出文件的几种方式
查看>>
linux 系统下 tar 的压缩与解压缩命令
查看>>
阿里负载均衡,配置中间证书问题(在starcom申请免费DV ssl)
查看>>
转:How to force a wordbreaker to be used in Sharepoint Search
查看>>
MySQL存储过程定时任务
查看>>
Python中and(逻辑与)计算法则
查看>>
POJ 3267 The Cow Lexicon(动态规划)
查看>>
设计原理+设计模式
查看>>