【AE脚本开发】给脚本写个联网激活机制

/*
激活流程:
1.用户填写授权码;
2.利用授权码与机器码生成网页链接;
3.脚本调用curl程序访问链接。如果授权码有效,得到服务器通过机器码计算出来的激活码;否则得到服务器返回的授权码不可用。
4.将激活码存于本地。

说明:重装系统等原因导致本地激活码丢失,电脑需要再次激活时,只需联网验证机器码即可,无需再次填授权码。这个步骤自己扩展,这里写首次激活的示例。
*/

//打开注册面板
function zhuCe(){

    if(pc.pcJQM.length == 0 && (!isMac ())){
        alert ("请先启用已禁用的网卡!\n然后关闭脚本重新打开。","无法验证激活状态!");
        system.callSystem("cmd.exe /c ncpa.cpl");
        return;
        }
    var zhuCeW = new Window("dialog", "注册");
    var res =
               "group {\
                          orientation:'column', alignment:['fill','fill'],preferredSize:[0,0] \
                               GG: Group { \
                                orientation:'row', alignment:['fill','fill'],preferredSize:[0,0] \
                                  }, \
                              fen: Panel { alignment:['fill','top'],preferredSize:[300,2] }, \
                              GG2: Group{\
                              orientation:'column', alignment:['fill','fill'],preferredSize:[0,0] \
                                  t1 : Group { alignment:['fill','center']\
                                    text: StaticText { text:'注册码:', alignment:['left','center'] }, \
                                    passText: EditText { text:'', characters:20, alignment:['fill','center'] }, \
                                    },\
                                  btn: Group { \
                                  orientation:'row', alignment:['fill','fill'],preferredSize:[0,0] \
                                    zhuCe: Button { text:'注册', alignment:['right','center'],preferredSize:[150,30] }, \
                                    gouMai: Button { text:'去淘宝购买注册码', alignment:['left','center'],preferredSize:[150,30] }, \
                                  }, \
                              },\
                          }"; 

    zhuCeW.gr = zhuCeW.add(res); 

    //注册
    zhuCeW.gr.GG2.btn.zhuCe.onClick = function(){
        var sma = zhuCeW.gr.GG2.t1.passText.text.replace (/\W/g, "");
        //app.settings.saveSetting(Hound.name,"sma" , strToUrl (sma));
        if(pc.pcJQM.length == 0){alert("识别主板失败!\n请先启用以太网卡(win7:本地连接)。")}
        if(sma.length == 30){
            if(web_jihuo (sma, pc.pcJQM.toString ().replace (/,/g, ''))){alert("注册成功!");zhuCeW.close ()}
            }
        else{alert("注册码输入有误!")}

        }

    //去淘宝购买注册码
    //zhuCeW.gr.GG2.btn.gouMai.onClick = function(){ openURL(url.taobao) ;zhuCeW.close();};

    zhuCeW.show();
}

//获取机器码
function getPcMac(){
    if(isMac ()){
        var macId = system.callSystem("ifconfig en0 | awk '/ether/{print $2}'");
        macId = macId.substr(0,17);
        if(macId.substr (0, 8) !=="ifconfig"){
            pc.pcJQM.push (mac2jqm (macId));
            }
        var patt = new RegExp(/[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}/ig);
        var s , j;
        macId = system.callSystem("ifconfig");
        while((s = patt.exec(macId)) != null){
            j = s.toString().replace (/\:/g, "").replace(/\s/g,"");
            if(pc.pcJQM.toString ().indexOf (j) == -1  && pc.pcJQM.length < 5){pc.pcJQM.push(j)};
            }
        }
    else{
        var idtf = system.callSystem("WMIC Path Win32_NetworkAdapter WHERE PhysicalAdapter=TRUE GET MACADDRESS,Description,PNPDeviceID").split ("\n");

        var idIndex  = idtf[0].indexOf("MACAddress");
        var pnpIndex = idtf[0].indexOf("PNPDeviceID");

        var j ;
        for(var i = 1 ; i<idtf.length ; i++){
            if(idtf[i].substr (pnpIndex, 3) == "PCI"){
                j = idtf[i].substr (idIndex, 17).replace (/\:/g, "").replace(/\s/g,"");
                if(pc.pcJQM.toString().indexOf (j) == -1 && pc.pcJQM.length < 5){pc.pcJQM.push (j)}
                }
            else if(idtf[i].substr (pnpIndex, 3) == "USB"){pc.usbMAC = idtf[i].substr (idIndex, 17).replace (/:/g, "")}
            }
        }
    }

//获取网页数据
function web_get(cmd){
    var web = system.callSystem("curl"+cmd);
    return web;
    }

//激活码激活
function web_jihuo(s , j){
    var cmd = " \"https://xmvfx.com/getcode/test/?sqm="+s+"&jqm="+j+"\"";
    var web = web_get (cmd);
    if(web != null){
        if(web.indexOf("key:\"abcdefg\"") > -1){ //这里只是简单解析服务器返回的数据
            alert("注册成功!")
        }else{
            alert("授权码错误!\n填“012345678901234567890123456789”试试!\n(3个0-9)")
        }
    }
    else{alert("网络卡了一下,请再试一次!");return false;}
    }

//判断系统
function isMac(){return ($.os.indexOf("Win") == -1)}

var pc = new Object;
pc.usbMAC = "";
pc.pcJQM = [];
getPcMac()
zhuCe()

 

给TA充电
共{{data.count}}人
人已充电
AE开发脚本开发

【AE脚本开发】验证系统 | 在线

2022-3-3 14:20:11

脚本开发

【AE 脚本】只在时间轴打开选择的合成的一种实现方法

2022-3-20 22:01:34

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
搜索