找回密码
 立即注册

微信登录

只需一步,快速开始

QQ登录

只需一步,快速开始

搜索
查看: 1283|回复: 3

[分享] wx机器人框架

[复制链接]
  • TA的每日心情
    郁闷
    2024-7-23 22:37
  • 签到天数: 5 天

    连续签到: 2 天

    [LV.2]偶尔看看I

    1

    主题

    6

    回帖

    49

    积分

    新手上路

    积分
    49
    QQ
    来自: 美国
    发表于 2024-2-22 15:26:19 | 显示全部楼层 |阅读模式 来自: 美国
    非业余 - aardio 编程语言 - 非官方问答社区
    限时85折!暑假期间,用aardio培训班充实自己!https://mp.weixin.qq.com/s/c4Z8sZPOiMh_OTG2VPOJmA
    Aardio培训大揭秘,轻松上手打造个人项目!https://mp.weixin.qq.com/s/cr47qhp_Cpz0p57lbbPwug
    aardio风行者第二期培训班https://mp.weixin.qq.com/s/uB6XHUDnGSk0JlWuiBE9AA
    因为可爱猫框架使用的3.4.0.38版本微信被封号过一次,后来找到了3.6.0.18版本微信的千寻框架
    但千寻框架启动报错 所以用千寻的大恩wxhook模块的dll写一个注入器顺便加载js逻辑脚本
    使用aar+web.view+vue 逻辑都用js写

    main.aardio:
    [AAuto] 纯文本查看 复制代码
    import win.ui;
    /*DSG{{*/
    mainForm = win.form(text="wxdemo";right=299;bottom=399;border="none";exmode="none")
    mainForm.add()
    /*}}*/
    
    /*import{{*/
    import process.popen;
    import fsys.localfile;
    import process.apiHook;
    import web.json;
    import web.view;
    import inet.http
    var http=inet.http()
    /*}}*/
    
    wb = web.view(mainForm,"/data");
    
    /*无边框窗口{{*/
    
    //添加阴影边框
    import win.ui.shadow;
    win.ui.shadow(mainForm);
    //设置窗口缩放范围
    import win.ui.minmax;
    win.ui.minmax(mainForm);
    
    //切换最大化、还原按钮
    mainForm.adjust = function( cx,cy,wParam ) {
    	if( wParam == 0x2/*_SIZE_MAXIMIZED*/ ){ 
    		wb.doScript(`document.getElementById("max-btn").innerText="2";`)
    	}
    	elseif( wParam == 0x0/*_SIZE_RESTORED*/ ){
    		wb.doScript(`document.getElementById("max-btn").innerText="1";`)
    	} 
    };
    /*}}*/
    
    /*释放资源{{*/
    //查询微信路径
    import win.reg
    var wxver = "3.6.0.18"
    var wxpath = win.reg.query("HKEY_CURRENT_USER\Software\Tencent\WeChat","InstallPath") ++ "\[" + wxver + "]"
    //import fsys.res
    //fsys.res.saveRes("/web","~/web")
    if(win.reg.query("HKEY_CURRENT_USER\Software\Tencent\WeChat","Version")==1661337618){
    	if(!io.exist(wxpath++"\HPSocket4C.dll")){
    		string.save(wxpath++"\HPSocket4C.dll",$"D:\x\www\aardio\daenwx\dist\web.src\HPSocket4C.dll")
    	}	
    }
    if(!io.exist("/data/Scripts/Cron/cron.js")){
    	string.save("/data/Scripts/Cron/cron.js",$"D:\x\www\aardio\daenwx\dist\web.src\cron.js")
    }
    if(!io.exist("/data/Scripts/Callback/callback.js")){
    	string.save("/data/Scripts/Callback/callback.js",$"D:\x\www\aardio\daenwx\dist\web.src\callback.js")
    }
    if(!io.exist("/data/Scripts/Callback/111.js")){
    	string.save("/data/Scripts/Callback/111.js",$"D:\x\www\aardio\daenwx\dist\web.src\111.js")
    }
    if(!io.exist("/data/Scripts/Callback/222.js")){
    	string.save("/data/Scripts/Callback/222.js",$"D:\x\www\aardio\daenwx\dist\web.src\222.js")
    }
    //if(!io.exist("/DaenWxHook.dll")){
    //	string.save("/DaenWxHook.dll",$"D:\x\www\aardio\daenwx\dist\web.src\DaenWxHook.dll")
    //}
    /*}}*/
    
    mainForm.doScript = function(script){
    	wb.doScript("(function(){"+script+"})()");
    }
    // 开启HTTP服务
    import wsock.tcp.simpleHttpServer;
    var app = function(response,request,session){
    	response.headers = {"Access-Control-Allow-Headers"="*";"Access-Control-Allow-Origin"="*"};//允许跨域
    	import web.json
    	if(string.left(request.path,5,true)=='/api/'){//WX回调监听
    		..mainForm.doScript("logdbAdd("+request.postData()+")");
    		response.write("")
    	}else{
    		response.loadcode(request.path);
    	}
    };
    server = wsock.tcp.simpleHttpServer.mainThread(app);
    server.documentRoot = '/';
    server.documentBase = '/web/';
    server.defalutDocument = 'index.html';
    //server.onThreadCreated = self.onThreadCreated;
    server.threadGlobal = {
    	mainForm = ..mainForm;
    };
    server.threadNum = 1;
    server.start("127.0.0.1",8809);//..wsock.getFreePort()//获取未使用端口 //TODO:编译8809改0
    //server.serverPort
    
    var url = server.getUrl("/");
    
    /*导出浏览器调用的方法{{*/
    wb.external = {
    	close = function(){
        	mainForm.close();
        };
        hitCaption = function(){
        	mainForm.hitCaption();
        };
        hitMin = function(){
        	mainForm.hitMin();
        };
    	hitMax = function(){
        	mainForm.hitMax();
        };
        msgbox = function(msg,title){
        	mainForm.msgbox(msg,title);
        };
        setSize = function(w,h){
        	mainForm.width = w;
        	mainForm.height = h;
        	mainForm.center();
        };
        api = function(data="{}",method="POST"){
    		var url = "http://127.0.0.1:8805/DaenWxHook/client/"
    		return http.post(url,data,{"Content-Type"="application/json"})
    	};
    	picsrc = function(name=""){
    		if(string.charAt(name,2)==":"){
    			name = string.right(name,-string.len(io.localpath('/data/Image/')));
    		}
    		return "http://127.0.0.1:8805/DaenWxHook/client/view/?name="++name;
    	};
    	fdlg = function(ftype="*.*",title="选择文件"){
    		import fsys.dlg;
    		return fsys.dlg.open(ftype,title);
    	};
    };
    wb.export({
    	log = function(text){
    		mainForm.msgbox(text)
    	};
    	startwx = function(port=8805){
    		//查询微信路径
    		if(!io.exist(wxpath)){
    			if(win.reg.query("HKEY_CURRENT_USER\Software\Tencent\WeChat","Version")!=1661337618){
    				mainForm.msgboxErr("未安装对应版本微信")
    			}
    		}
    		//return {code:0,msg:"ok",url:server.getUrl("/wechat/")};// TODO:
    		if(string.len(process.popen.cmd("netstat -aon|findstr :"+port).read(-1))>0){
    			return {code:1,msg:"端口被占用"};
    		}
    		//D:\Program Files (x86)\Tencent\WeChat\[3.6.0.18]
    		import fsys;
    		var dllpath = fsys.localfile($"D:\x\www\aardio\daenwx\dist\web.src\DaenWxHook.dll").path();//释放dll
    		fsys.move(dllpath,dllpath++".dll");
    		dllpath = dllpath++".dll";
    		var callbackUrl = server.getUrl("/api/");
    		var imgPath = io.localpath('/data/Image/');
    		var params = "callBackUrl="+callbackUrl+"&port="++port++"&imgData="++imgPath++"&decryptImg=1&autoLogin=1&=1&g=0";
    		var p=process.apiHook(wxpath++"\WeChat.exe",params,{suspended=true});// 启动并暂停微信进程
    		p.loadLibrary(dllpath);//注入dll
    		p.resume();// 恢复进程
    		return {code:0,msg:"ok"};
    	};
    	listcron = function(){
    		import fsys;
    		var crons = {};
    		fsys.enum("/data/Scripts/Cron", "*.js",
    				function(dir,filename,fullpath,findData){
    					if(filename){
    						var content = string.load(fullpath);
    						i,j,reminder,id,title,rule,lastrun,nextrun,enable,updated,content = string.find(content,"//\s*=======cron=======\s*\n//\s*@reminder\s*(.*)\n//\s*@id\s*(.*)\n//\s*@title\s*(.*)\n//\s*@rule\s*(.*)\n//\s*@lastrun\s*(.*)\n//\s*@nextrun\s*(.*)\n//\s*@enable\s*(.*)\n//\s*@updated\s*(.*)\n//\s*=======/cron=======\s*\n(.*)")
    						table.push(crons,{
    								"filename":filename;
    								"content":content;
    								"title":string.trim(title?title:"");
    								"rule":string.trim(rule?rule:"");
    								"lastrun":tonumber(string.trim(lastrun?lastrun:"0"));
    								"nextrun":tonumber(string.trim(nextrun?nextrun:"0"));
    								"enable":string.trim(enable?enable:"false")=="true"?1:0;
    								"updated":string.trim(updated?updated:"");
    							});
        				}
    				},false);
    		return web.json.stringifyArray(crons);
    	};
    	updatecron = function(cron){
    		var content = /*
    // =======cron=======
    // @reminder   请不要删除这部分代码注释,这是脚本能正常工作的基本条件!当然,你可以按需修改这里的内容!
    // @id         id_1707489528977
    // @title      %s
    // @rule       %s
    // @lastrun    %s
    // @nextrun    %s
    // @enable     %s
    // @updated    %s
    // =======/cron=======
    %s
    */
    		content = string.format(content,
    							cron.title,
    							cron.rule,
    							cron.lastrun,
    							cron.nextrun,
    							cron.enable?"true":"false",
    							cron.updated,
    							cron.content?'\n'+cron.content:""
    						);
    		string.save("/data/Scripts/Cron/"+cron.filename,content,false);
    	};
    	listcallback = function(){
    		var callbacks = {};
    		fsys.enum("/data/Scripts/Callback", "*.js",
    				function(dir,filename,fullpath,findData){
    					if(filename){
    						var content = string.load(fullpath);
    						i,j,reminder,id,title,event,scope,enable,updated,content = string.find(content,"//\s*=======callback=======\s*\n//\s*@reminder\s*(.*)\n//\s*@id\s*(.*)\n//\s*@title\s*(.*)\n//\s*@event\s*(.*)\n//\s*@scope\s*(.*)\n//\s*@enable\s*(.*)\n//\s*@updated\s*(.*)\n//\s*=======/callback=======\s*\n(.*)")
    						table.push(callbacks,{
    								"filename":filename;
    								"content":content;
    								"title":string.trim(title?title:"");
    								"event":string.trim(event?event:"");
    								"scope":string.trim(scope?scope:"");
    								"enable":string.trim(enable?enable:"false")=="true"?1:0;
    								"updated":string.trim(updated?updated:"");
    							});
        				}
    				},false);
    		return web.json.stringifyArray(callbacks);
    	};	
    	init = function(){
    		return wb.doScript($"D:\x\www\aardio\daenwx\dist\web.src\wx.js")
    	};
    });
    /*}}*/
    
    wb.go(url);//TODO:前端调试端口5173,编译需要去掉
    
    mainForm.show();
    win.loopMessage();




    忘了 可以发附件来着。。。

    附件不能超过100k。。。vue代码单独打包了







    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×
    非业余 - aardio 编程语言 - 非官方问答社区
    限时85折!暑假期间,用aardio培训班充实自己!https://mp.weixin.qq.com/s/c4Z8sZPOiMh_OTG2VPOJmA
    Aardio培训大揭秘,轻松上手打造个人项目!https://mp.weixin.qq.com/s/cr47qhp_Cpz0p57lbbPwug
    aardio风行者第二期培训班https://mp.weixin.qq.com/s/uB6XHUDnGSk0JlWuiBE9AA
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2024-7-21 16:57
  • 签到天数: 15 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    0

    主题

    16

    回帖

    183

    积分

    培训会员

    积分
    183
    来自: 中国
    发表于 2024-2-22 22:45:19 | 显示全部楼层 来自: 中国
    能不能直接上传到网盘上下载呢?
            if(!io.exist(wxpath++"\HPSocket4C.dll")){
                    string.save(wxpath++"\HPSocket4C.dll",$"D:\x\www\aardio\daenwx\dist\web.src\HPSocket4C.dll")
            }工程里面是没有这个DLL的。
    回复

    使用道具 举报

  • TA的每日心情
    郁闷
    2024-7-23 22:37
  • 签到天数: 5 天

    连续签到: 2 天

    [LV.2]偶尔看看I

    1

    主题

    6

    回帖

    49

    积分

    新手上路

    积分
    49
    QQ
    来自: 美国
     楼主| 发表于 2024-2-23 22:46:58 | 显示全部楼层 来自: 美国
    shzhbook 发表于 2024-2-22 22:45
    能不能直接上传到网盘上下载呢?
            if(!io.exist(wxpath++"\HPSocket4C.dll")){
                    string.save(wxpath++"\HP ...

    大恩模块地址
    https://gitee.com/daenmax/pc-wec ... ee/36018/DaenWxHook
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2024-2-23 16:41
  • 签到天数: 2 天

    连续签到: 1 天

    [LV.1]初来乍到

    0

    主题

    3

    回帖

    21

    积分

    培训会员

    积分
    21
    来自: 中国贵州贵阳
    发表于 2024-4-15 14:15:44 | 显示全部楼层 来自: 中国贵州贵阳
    大佬,有成品吗?
    回复

    使用道具 举报

    *滑块验证:
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|非业余 - aardio 编程语言 - 非官方问答社区

    GMT+8, 2024-9-17 03:45 , Processed in 0.127218 second(s), 30 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表