[GSTC]gantt-schedule-timeline-calendar LICENSE验证原理解析

1,105 阅读2分钟

声明:本文仅供学习

官方repo:neuronetio/gantt-schedule-timeline-calendar: Gantt Gantt Gantt Timeline Schedule Calendar [ javascript gantt, js gantt, projects gantt, timeline, scheduler, gantt timeline, reservation timeline, react gantt, angular gantt, vue gantt, svelte gantt, booking manager ] (github.com)

版本

本文调试版本:3.35.2

LICENSE验证原理解析

请求发起源文件

image.png浏览器开发者工具(F12)network中可以看到验证license的请求源于gstc.esm.min.js:538(由于调试关系,在文件名后加了_1

发起脚本位置

点击network中发起程序即可跳转至逻辑代码具体位置

image.png 由于gstc.esm.min.js已经打包编译过,所以代码无法直接看出具体逻辑;

通过conlose.log方法打印对象信息

调用位置找到了其实就很好办了,把不知名的哪些对象都打出来可以还原成具体的代码了

逐个对象打印查看

t[(e = 604, a = 629, n(e - 29, a))]

打印结果为200

(H = !1, b = $)

打印结果为含有license验证错误的htmlstring对象

t[(o = 378, i = "KT^#", d(o - 314, i))]

打印结果为Promise对象,他后方加了()调用,暨实际发出license验证请求就是这块逻辑

替换实际请求

我将原始试用license请求成功的对象返回直接替换,现有请求逻辑,就得到如下:

image.png

继续debug发现问题

当我将license请求对象结果直接写死后,出现了一个验证license请求中token有效性的请求

image.png

继续排除代码

通过排除发现 image.png 发现这个逻辑判断无法成功会走到下方的else代码块

image.png

查看else代码块

通过debug,发现验证token的请求就是在这块发出

image.png

让上方逻辑判断必定成功

if (s[m(1126, "zEM]")] && s[w(658, "Y48A")] === W)直接替换为if(!0),使之永远不去运行else的代码块

仍然会发出license的请求

继续debug发现上面我已经写死了license的请求,理论上是不会再发起请求才对

仔细研究代码

image.png 发现这块代码是个类似链式调用的逻辑

查看[]包裹的对象到底是啥

使用 console.log打印后发现:

  • T得到的结果https://gstc.neuronet.io/api/license
  • y(985, "2CW3")得到的结果fetch
  • c(-267, -282)得到的结果then
  • z(1393, 1308)得到的结果post
  • d(-18, "PPpB")得到的结果follow

还原真实的代码

所以其实这块代码类似

window["fetch"]("https://gstc.neuronet.io/api/license", {
    method: "post",
    redirect: "follow",
    headers: {"Content-Type": d(-17, "Uwgf")},
    body: O
})["then"](t=>())

彻底屏蔽远程请求

因为fetch方法的请求参数redirect设置为follow,这样无论本次请求是否成功都会运行then方法,所以我直接把T换成虚假的地址

image.png

至此,加载GSTC时只会发送一个预期失败(404)的fake_request请求

image.png