最近有朋友问我的卡密验证界面是怎么写的,今天把源码分享出来。先上一个卡密验证界面的效果图:

源码第646行中的main.js替换为你的卡密验证通过后要跳转的js文件。这里路径为相对路径,跟本卡密验证.js为同级目录。

完整源码:(遇到问题,一键加群咨询。)

"ui";
var storage = storages.create("攒外快网");
ui.layout(//背景图<vertical gravity="center" bg="file://bg.jpg"><text textSize="19sp" textColor="red" w="auto"text="请输入攒外快网脚本通用卡密登录"/><input id="card" textSize="16sp" text="{{storage.get('卡密','')}}" textColorHint="yellow"hint="请输入您的卡密"/><button id="login"  style="Widget.AppCompat.Button.Colored"text="登录"/><button id="gm"  style="Widget.AppCompat.Button.Colored"text="购买攒外快网脚本通用卡密"/><button id="logout" style="Widget.AppCompat.Button.Colored"text="退出"/></vertical>
);const PJYSDK = (function(){function PJYSDK(app_key, app_secret){http.__okhttp__.setMaxRetries(0);http.__okhttp__.setTimeout(10*1000);this.event = events.emitter();this.debug = true;this._lib_version = "v1.08";this._protocol = "https";this._host = "api.paojiaoyun.com";this._device_id = this.getDeviceID();this._retry_count = 9;this._app_key = "c2tgra4o6itbdn9h98f6"this._app_secret = "WS6RMyA35AgHq1NkHlo2Pb0pZtjd0jcm"this._card = null;this._username = null;this._password = null;this._token = null;this.is_trial = false;  // 是否是试用用户this.login_result = {"card_type": "","expires": "","expires_ts": 0,"config": "",};this._auto_heartbeat = true;  // 是否自动开启心跳任务this._heartbeat_gap = 60 * 1000; // 默认60秒this._heartbeat_task = null;this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};this._prev_nonce = null;}PJYSDK.prototype.SetCard = function(card) {this._card = card.trim();}PJYSDK.prototype.SetUser = function(username, password) {this._username = username.trim();this._password = password;}PJYSDK.prototype.getDeviceID = function() {let id = device.serial;if (id == null || id == "" || id == "unknown") {id = device.getAndroidId();}if (id == null || id == "" || id == "unknown") {id = device.getIMEI();}return id;}PJYSDK.prototype.MD5 = function(str) {try {let digest = java.security.MessageDigest.getInstance("md5");let result = digest.digest(new java.lang.String(str).getBytes("UTF-8"));let buffer = new java.lang.StringBuffer();for (let index = 0; index < result.length; index++) {let b = result[index];let number = b & 0xff;let str = java.lang.Integer.toHexString(number);if (str.length == 1) {buffer.append("0");}buffer.append(str);}return buffer.toString();} catch (error) {alert(error);return "";}}PJYSDK.prototype.getTimestamp = function() {try {let res = http.get("http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp");let data = res.body.json();return Math.floor(data["data"]["t"]/1000);} catch (error) {return Math.floor(new Date().getTime()/1000);}}PJYSDK.prototype.genNonce = function() {const ascii_str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';let tmp = '';for(let i = 0; i < 20; i++) {tmp += ascii_str.charAt(Math.round(Math.random()*ascii_str.length));}return this.MD5(this.getDeviceID() + tmp);}PJYSDK.prototype.joinParams = function(params) {let ps = [];for (let k in params) {ps.push(k + "=" + params[k])}ps.sort()return ps.join("&")}PJYSDK.prototype.CheckRespSign = function(resp) {if (resp.code != 0 && resp.nonce === "" && resp.sign === "") {return resp}let ps = "";if (resp["result"]) {ps = this.joinParams(resp["result"]);}let s = resp["code"] + resp["message"] + ps + resp["nonce"] + this._app_secret;let sign = this.MD5(s);if (sign === resp["sign"]) {if (this._prev_nonce === null) {this._prev_nonce = resp["nonce"];return {"code":0, "message":"OK"};} else {if (resp["nonce"] > this._prev_nonce) {this._prev_nonce = resp["nonce"];return {"code": 0, "message": "OK"};} else {return {"code": -98, "message": "轻点,疼~"};}}}return {"code": -99, "message": "轻点,疼~"};}PJYSDK.prototype.retry_fib = function(num) {if (num > 9) {return 34}let a = 0;let b = 1;for (i = 0; i < num; i++) {let tmp = a + b;a = bb = tmp}return a}PJYSDK.prototype._debug = function(path, params, result) {if (this.debug) {log("\n" + path, "\nparams:", params, "\nresult:", result);}}PJYSDK.prototype.Request = function(method, path, params) {// 构建公共参数params["app_key"] = this._app_key;method = method.toUpperCase();let url = this._protocol + "://" + this._host + pathlet max_retries = this._retry_count;let retries_count = 0;let data = {"code": -1, "message": "连接服务器失败"};do {retries_count++;let sec = this.retry_fib(retries_count);delete params["sign"]params["nonce"] = this.genNonce();params["timestamp"] = this.getTimestamp();let ps = this.joinParams(params);let s = method + this._host + path + ps + this._app_secret;let sign = this.MD5(s);params["sign"] = sign;let resp, body;try {    if (method === "GET") {resp = http.get(url + "?" + ps + "&sign=" + sign);} else {  // POSTresp = http.post(url, params);}body = resp.body.string();data = JSON.parse(body);this._debug(method+'-'+path+':', params, data);let crs = this.CheckRespSign(data);if (crs.code !== 0) {return crs;} else {return data;}} catch (error) {log("[*] request error: ", error, sec + "s后重试");this._debug(method+'-'+path+':', params, body)sleep(sec*1000);}} while (retries_count < max_retries);return data;}/* 通用 */PJYSDK.prototype.GetHeartbeatResult = function() {return this._heartbeat_ret;}PJYSDK.prototype.GetTimeRemaining = function() {let g = this.login_result.expires_ts - this.getTimestamp();if (g < 0) {return 0;} return g;}/* 卡密相关 */PJYSDK.prototype.CardLogin = function() {  // 卡密登录if (!this._card) {return {"code": -4, "message": "请先填入卡密"};}let method = "POST";let path = "/v1/card/login";let data = {"card": this._card, "device_id": this._device_id};let ret = this.Request(method, path, data);if (ret.code == 0) {this._token = ret.result.token;this.login_result = ret.result;if (this._auto_heartbeat) {this._startCardHeartheat();}}return ret;}PJYSDK.prototype.CardHeartbeat = function() {  // 卡密心跳,默认会自动调用if (!this._token) {return {"code": -2, "message": "请在卡密登录成功后调用"};}let method = "POST";let path = "/v1/card/heartbeat";let data = {"card": this._card, "token": this._token};let ret = this.Request(method, path, data);if (ret.code == 0) {this.login_result.expires = ret.result.expires;this.login_result.expires_ts = ret.result.expires_ts;}return ret;}PJYSDK.prototype._startCardHeartheat = function() {  // 开启卡密心跳任务if (this._heartbeat_task) {this._heartbeat_task.interrupt();this._heartbeat_task = null;}this._heartbeat_task = threads.start(function(){setInterval(function(){}, 10000);});this._heartbeat_ret = this.CardHeartbeat();this._heartbeat_task.setInterval((self) => {self._heartbeat_ret = self.CardHeartbeat();if (self._heartbeat_ret.code != 0) {self.event.emit("heartbeat_failed", self._heartbeat_ret);}}, this._heartbeat_gap, this);this._heartbeat_task.setInterval((self) => {if (self.GetTimeRemaining() == 0) {self.event.emit("heartbeat_failed", {"code": 10210, "message": "卡密已过期!"});}}, 1000, this);}PJYSDK.prototype.CardLogout = function() {  // 卡密退出登录this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};if (this._heartbeat_task) { // 结束心跳任务this._heartbeat_task.interrupt();this._heartbeat_task = null;}if (!this._token) {return {"code": 0, "message": "OK"};}let method = "POST";let path = "/v1/card/logout";let data = {"card": this._card, "token": this._token};let ret = this.Request(method, path, data);// 清理this._token = null;this.login_result = {"card_type": "","expires": "","expires_ts": 0,"config": "",};return ret;}PJYSDK.prototype.CardUnbindDevice = function() { // 卡密解绑设备,需开发者后台配置if (!this._token) {return {"code": -2, "message": "请在卡密登录成功后调用"};}let method = "POST";let path = "/v1/card/unbind_device";let data = {"card": this._card, "device_id": this._device_id, "token": this._token};return this.Request(method, path, data);}PJYSDK.prototype.SetCardUnbindPassword = function(password) { // 自定义设置解绑密码if (!this._token) {return {"code": -2, "message": "请在卡密登录成功后调用"};}let method = "POST";let path = "/v1/card/unbind_password";let data = {"card": this._card, "password": password, "token": this._token};return this.Request(method, path, data);}PJYSDK.prototype.CardUnbindDeviceByPassword = function(password) { // 用户通过解绑密码解绑设备let method = "POST";let path = "/v1/card/unbind_device/by_password";let data = {"card": this._card, "password": password};return this.Request(method, path, data);}PJYSDK.prototype.CardRecharge = function(card, use_card) { // 以卡充卡let method = "POST";let path = "/v1/card/recharge";let data = {"card": card, "use_card": use_card};return this.Request(method, path, data);}/* 用户相关 */PJYSDK.prototype.UserRegister = function(username, password, card) {  // 用户注册(通过卡密)let method = "POST";let path = "/v1/user/register";let data = {"username": username, "password": password, "card": card, "device_id": this._device_id};return this.Request(method, path, data);}PJYSDK.prototype.UserLogin = function() {  // 用户账号登录if (!this._username || !this._password) {return {"code": -4, "message": "请先设置用户账号密码"};}let method = "POST";let path = "/v1/user/login";let data = {"username": this._username, "password": this._password, "device_id": this._device_id};let ret = this.Request(method, path, data);if (ret.code == 0) {this._token = ret.result.token;this.login_result = ret.result;if (this._auto_heartbeat) {this._startUserHeartheat();}}return ret;}PJYSDK.prototype.UserHeartbeat = function() {  // 用户心跳,默认会自动开启if (!this._token) {return {"code": -2, "message": "请在用户登录成功后调用"};}let method = "POST";let path = "/v1/user/heartbeat";let data = {"username": this._username, "token": this._token};let ret = this.Request(method, path, data);if (ret.code == 0) {this.login_result.expires = ret.result.expires;this.login_result.expires_ts = ret.result.expires_ts;}return ret;}PJYSDK.prototype._startUserHeartheat = function() {  // 开启用户心跳任务if (this._heartbeat_task) {this._heartbeat_task.interrupt();this._heartbeat_task = null;}this._heartbeat_task = threads.start(function(){setInterval(function(){}, 10000);});this._heartbeat_ret = this.UserHeartbeat();this._heartbeat_task.setInterval((self) => {self._heartbeat_ret = self.UserHeartbeat();if (self._heartbeat_ret.code != 0) {self.event.emit("heartbeat_failed", self._heartbeat_ret);}}, this._heartbeat_gap, this);this._heartbeat_task.setInterval((self) => {if (self.GetTimeRemaining() == 0) {self.event.emit("heartbeat_failed", {"code": 10250, "message": "用户已到期!"});}}, 1000, this);}PJYSDK.prototype.UserLogout = function() {  // 用户退出登录this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};if (this._heartbeat_task) { // 结束心跳任务this._heartbeat_task.interrupt();this._heartbeat_task = null;}if (!this._token) {return {"code": 0, "message": "OK"};}let method = "POST";let path = "/v1/user/logout";let data = {"username": this._username, "token": this._token};let ret = this.Request(method, path, data);// 清理this._token = null;this.login_result = {"card_type": "","expires": "","expires_ts": 0,"config": "",};return ret;}PJYSDK.prototype.UserChangePassword = function(username, password, new_password) {  // 用户修改密码let method = "POST";let path = "/v1/user/password";let data = {"username": username, "password": password, "new_password": new_password};return this.Request(method, path, data);}PJYSDK.prototype.UserRecharge = function(username, card) { // 用户通过卡密充值let method = "POST";let path = "/v1/user/recharge";let data = {"username": username, "card": card};return this.Request(method, path, data);}PJYSDK.prototype.UserUnbindDevice = function() { // 用户解绑设备,需开发者后台配置if (!this._token) {return {"code": -2, "message": "请在用户登录成功后调用"};}let method = "POST";let path = "/v1/user/unbind_device";let data = {"username": this._username, "device_id": this._device_id, "token": this._token};return this.Request(method, path, data);}/* 配置相关 */PJYSDK.prototype.GetCardConfig = function() { // 获取卡密配置let method = "GET";let path = "/v1/card/config";let data = {"card": this._card};return this.Request(method, path, data);}PJYSDK.prototype.UpdateCardConfig = function(config) { // 更新卡密配置let method = "POST";let path = "/v1/card/config";let data = {"card": this._card, "config": config};return this.Request(method, path, data);}PJYSDK.prototype.GetUserConfig = function() { // 获取用户配置let method = "GET";let path = "/v1/user/config";let data = {"user": this._username};return this.Request(method, path, data);}PJYSDK.prototype.UpdateUserConfig = function(config) { // 更新用户配置let method = "POST";let path = "/v1/user/config";let data = {"username": this._username, "config": config};return this.Request(method, path, data);}/* 软件相关 */PJYSDK.prototype.GetSoftwareConfig = function() { // 获取软件配置let method = "GET";let path = "/v1/software/config";return this.Request(method, path, {});}PJYSDK.prototype.GetSoftwareNotice = function() { // 获取软件通知let method = "GET";let path = "/v1/software/notice";return this.Request(method, path, {});}PJYSDK.prototype.GetSoftwareLatestVersion = function(current_ver) { // 获取软件最新版本let method = "GET";let path = "/v1/software/latest_ver";let data = {"version": current_ver};return this.Request(method, path, data);}/* 试用功能 */PJYSDK.prototype.TrialLogin = function() {  // 试用登录let method = "POST";let path = "/v1/trial/login";let data = {"device_id": this._device_id};let ret = this.Request(method, path, data);if (ret.code == 0) {this.is_trial = true;this.login_result = ret.result;if (this._auto_heartbeat) {this._startTrialHeartheat();}}return ret;}PJYSDK.prototype.TrialHeartbeat = function() {  // 试用心跳,默认会自动调用let method = "POST";let path = "/v1/trial/heartbeat";let data = {"device_id": this._device_id};let ret = this.Request(method, path, data);if (ret.code == 0) {this.login_result.expires = ret.result.expires;this.login_result.expires_ts = ret.result.expires_ts;}return ret;}PJYSDK.prototype._startTrialHeartheat = function() {  // 开启试用心跳任务if (this._heartbeat_task) {this._heartbeat_task.interrupt();this._heartbeat_task = null;}this._heartbeat_task = threads.start(function(){setInterval(function(){}, 10000);});this._heartbeat_ret = this.TrialHeartbeat();this._heartbeat_task.setInterval((self) => {self._heartbeat_ret = self.TrialHeartbeat();if (self._heartbeat_ret.code != 0) {self.event.emit("heartbeat_failed", self._heartbeat_ret);}}, this._heartbeat_gap, this);this._heartbeat_task.setInterval((self) => {if (self.GetTimeRemaining() == 0) {self.event.emit("heartbeat_failed", {"code": 10407, "message": "试用已到期!"});}}, 1000, this);}PJYSDK.prototype.TrialLogout = function() {  // 试用退出登录,没有http请求,只是清理本地记录this.is_trial = false;this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};if (this._heartbeat_task) { // 结束心跳任务this._heartbeat_task.interrupt();this._heartbeat_task = null;}// 清理this._token = null;this.login_result = {"card_type": "","expires": "","expires_ts": 0,"config": "",};return {"code": 0, "message": "OK"};;}/* 高级功能 */PJYSDK.prototype.GetRemoteVar = function(key) { // 获取远程变量let method = "GET";let path = "/v1/af/remote_var";let data = {"key": key};return this.Request(method, path, data);}PJYSDK.prototype.GetRemoteData = function(key) { // 获取远程数据let method = "GET";let path = "/v1/af/remote_data";let data = {"key": key};return this.Request(method, path, data);}PJYSDK.prototype.CreateRemoteData = function(key, value) { // 创建远程数据let method = "POST";let path = "/v1/af/remote_data";let data = {"action": "create", "key": key, "value": value};return this.Request(method, path, data);}PJYSDK.prototype.UpdateRemoteData = function(key, value) { // 修改远程数据let method = "POST";let path = "/v1/af/remote_data";let data = {"action": "update", "key": key, "value": value};return this.Request(method, path, data);}PJYSDK.prototype.DeleteRemoteData = function(key, value) { // 删除远程数据let method = "POST";let path = "/v1/af/remote_data";let data = {"action": "delete", "key": key};return this.Request(method, path, data);}PJYSDK.prototype.CallRemoteFunc = function(func_name, params) { // 执行远程函数let method = "POST";let path = "/v1/af/call_remote_func";let ps = JSON.stringify(params);let data = {"func_name": func_name, "params": ps};let ret = this.Request(method, path, data);if (ret.code == 0 && ret.result.return) {ret.result = JSON.parse(ret.result.return);}return ret;}return PJYSDK;
})();var app_key = "c1tgra4o6itbdn9h98f0";
var app_secret = "WS5RMyA35sgHq1NkHlo2Pb0pZtjd0jcq";
var pjysdk = new PJYSDK(app_key, app_secret);
pjysdk.debug = false;pjysdk.event.on("heartbeat_failed", function(hret) {toast(hret.message);exit();
});ui.login.click(function() {var card = ui.card.getText().toString();if (card.trim() == "123466") {file = open("/sdcard/jiuai2.txt", "r")//读取,并提示var card123456=file.readline();file.close()var login_ret = pjysdk.CardLogin();pjysdk.SetCard(card123456);if (login_ret.code == 0) {toast("登录成功");
ui.run(()=>{zhujiemianUI()})}}pjysdk.SetCard(card);threads.start(function() {var login_ret = pjysdk.CardLogin();if (login_ret.code == 0) {toast("登录成功");
zhuye();
//跳转界面                          } else {// 登录失败提示toast(login_ret.message);}});
});//购买
ui.gm.click(function() {app.openUrl("http://faka.zwk365.com/product/16.html");
})ui.logout.click(function() {threads.start(function() {var ret = pjysdk.CardLogout();if (ret.code == 0) {toast("退出成功");exit()} else {// 登录失败提示toast(ret.message);}});
});function zhuye(){let kami=ui.card.text();storage.put('卡密',kami);engines.execScriptFile("./main.js");exit();
//调用脚本文件
if (!files.exists(path)) {toast("脚本文件不存在: " + path);exit();
}
}

如何用Autojs写自己的卡密验证界面?实战代码相关推荐

  1. 如何用Autojs来写脚本赚零花钱(第一课)

    先啰嗦几句 今天给大家介绍的主题是--如何用Autojs来写脚本赚零花钱,先说能赚多少零花钱,一部手机除了睡觉的时间之外,都可以给你来赚钱,手机不是用来看的,手机是用来赚钱的.我劝你把手机仍在一个角落 ...

  2. python写的脚本怎么用,如何用python写脚本

    如何用python写脚本 以Python2.7操作为例:1.首先需要打开电脑桌面,按开始的快捷键,点击Python2.7如图所示的选项进入. 相关推荐:<Python入门教程>2.打开之后 ...

  3. 如何给脚本增加卡密验证功能,权朗网络验证对接教程

    之前给大家分享过如何对接泡椒云给自己的脚本增加卡密验证功能,可以看之前分享的文章<如何对接泡椒云,给你的Auto.js脚本增加卡密验证功能?详细教程>. 今天站长给大家分享另一个给脚本增加 ...

  4. 学习js,尝试写一个表单验证框架(1)-规划

    斗胆放到首页来,如果不合适的话就删了吧,谢谢 其实这个框架也已经写了一点了,但是越写越乱越没把握,最终决定写成博客的形式,强迫自己慢下步调,一点点仔细地规划,设计,思考,期间也一定会遇到不少问题,还请 ...

  5. 自制vue组件通信插件:教你如何用mixin写插件

    "vue-unicom"的作者:szpoppy,如果觉得对你有用,请一定点个star 这个项目虽然是szpoppy的个人项目,但是在szpoppy公司内是在大面积使用的,一直由sz ...

  6. typora 公式_如何用Typora写Markdown上传至知乎

    如何用Typora写Markdown上传至知乎 [TOC] 起因 知乎自带的编辑器太恶心了,于是想要在typora本地编辑之后,使用知乎的上传md功能进行同步,但是发现会缺失图像和公式.优化思路如下: ...

  7. 如何用Pygame写游戏(九)

    本文转自:http://eyehere.net/2011/python-pygame-novice-professional-9/ 上次我们说到了向量,不得不说向量是一个伟大的发明,在单纯的数字运算之 ...

  8. python剪刀石头布_如何用python写剪刀石头布

    如何用python写剪刀石头布 发布时间:2020-07-20 11:52:16 来源:亿速云 阅读:111 本篇文章给大家分享的是有关如何用python写剪刀石头布,小编觉得挺实用的,因此分享给大家 ...

  9. 贪吃蛇博弈算法python_算法应用实践:如何用Python写一个贪吃蛇AI

    原标题:算法应用实践:如何用Python写一个贪吃蛇AI 前言 这两天在网上看到一张让人涨姿势的图片,图片中展示的是贪吃蛇游戏, 估计大部分人都玩过.但如果仅仅是贪吃蛇游戏,那么它就没有什么让人涨姿势 ...

最新文章

  1. 向日葵Ubuntu连接马上断开问题
  2. 面向对象分析和设计的几个关键步骤_(豁然开朗)《面向对象分析与设计》读书笔记 (4)- 分类...
  3. 三菱fx5u编程手册_实用分享 | 三菱FX 5U特点是什么?
  4. Android之jdbc的学习
  5. 模型融合(stackingblending)
  6. RTX5 | 消息队列04 - (实战技巧)串口中断回调函数ISR同步线程
  7. Java poi 列移动_如何在java xssf中移動列poi
  8. AndroidStudio_Build Out窗口显示乱码解决方案---Android原生开发工作笔记222
  9. 输入两棵二叉树A,B,判断B是不是A的子结构。(我们约定空树不是任意一个树的子结构)
  10. 单片机实验汇编--FlashRom读写实验
  11. QT Libvlc视频画面上覆盖透明控件
  12. 【论文解读 WSDM 2020 | KRF】Integrating Knowledge Relations into Style Correlations for 多标签音乐风格分类
  13. C语言试题七十九之请编写函数实现自然底数 e=2.718281828
  14. 自定义模型tensorboard画图命令报错 assert error assert isinstance(orig, torch.nn.Module)
  15. 29 Redis 应对并发访问的无锁原子操作
  16. 自学系列 | 就谈兴趣!
  17. 【JavaScript 刨根问底之】requestAnimationFrame以及延时器
  18. Python停车管理系统毕业设计-附源码271400
  19. 高中数学公式总结:解析几何(非常全)
  20. 分享一次自己使用 pyecharts 模块 画地图,一路踩坑和填坑的经历

热门文章

  1. 全球健身领导品牌莱美国际任命季嘉华为大中华区及韩国CEO
  2. 智慧校园管理系统开发
  3. Pinterest:难以平衡的中间人角色 毫无创新的抄袭
  4. csi mipi信号解析
  5. 小程序覆盖修改vant-ui的样式
  6. 北斗中小渔船安全动态监控信息解决方案
  7. SpringCloud Feign调用报错feign.RetryableException: too many bytes written executing
  8. 【STM32】 Keil程序开发环境
  9. C#中读取流媒体视频文件转H.264具体实现方法
  10. 上网本安装linux_微软杀死了Linux上网本吗?