fix: 1. exec命令适配版本;2. 新版cookie位数逻辑更新(无法过检测)

This commit is contained in:
rnet 2024-04-04 00:48:36 +08:00
parent 4caaf73979
commit ae822c7a4d
18 changed files with 332 additions and 197 deletions

View File

@ -120,7 +120,7 @@ module.exports = yargs
coerce: (input) => { coerce: (input) => {
if (['1', '2'].includes(input)) { if (['1', '2'].includes(input)) {
gv._setAttr('version', Number(input)); gv._setAttr('version', Number(input));
return paths.exampleResolve('codes', `${input}-\$_ts-full.json`); return paths.exampleResolve('codes', `${input}-\$_ts.json`);
} }
return input; return input;
} }
@ -131,6 +131,7 @@ module.exports = yargs
Math.random = () => 0.1253744220839037; Math.random = () => 0.1253744220839037;
const gv = require('@utils/initGv')(argv.file); const gv = require('@utils/initGv')(argv.file);
Object.assign(global, gv.utils); Object.assign(global, gv.utils);
Object.assign(global, require('@src/handler/viewer/'));
const output = JSON.stringify(eval(argv.code)); const output = JSON.stringify(eval(argv.code));
console.log([`\n 输入:${argv.code}`, `输出:${output}\n`].join('\n ')); console.log([`\n 输入:${argv.code}`, `输出:${output}\n`].join('\n '));
} }

View File

@ -29,7 +29,6 @@
"README.md", "README.md",
"utils", "utils",
"main.js", "main.js",
"test",
"src", "src",
"example" "example"
], ],

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,7 @@ const {
uuid, uuid,
string2ascii, string2ascii,
execRandomByNumber, execRandomByNumber,
execNumberByTime,
hexnum, hexnum,
ascii2string, ascii2string,
getFixedNumber, getFixedNumber,
@ -28,13 +29,27 @@ const {
runTask, runTask,
} = parser; } = parser;
const developConfig = {
// 开发时用的配置,比如时间值固定、随机数固定等
// 'window.innerWidth': 150,
// 'window.outerWidth': 1336,
// currentTime: 1711730658454,
// r2mkaTime: 1711712705,
// startTime: 1711730659,
// runTime: 1711730659,
// formatUid: 58854,
// random: 0.123,
execNumberByTime: 1778,
}
module.exports = class { module.exports = class {
constructor(ts, r2mkaText) { constructor(ts, r2mkaText) {
parser.init(ts, r2mkaText) parser.init(ts, r2mkaText)
const current = new Date().getTime() + 1000;
this.config = { this.config = {
'window.navigator.maxTouchPoints': 0, 'window.navigator.maxTouchPoints': 0,
'window.eval.toString().length': 33, 'window.eval.toString().length': 33,
'window.navigator.userAgent': randomUseragent.getRandom(), 'window.navigator.userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'window.navigator.platform': 'MacIntel', 'window.navigator.platform': 'MacIntel',
'window.name': '$_YWTU=LjFNq_oZCsth6KJ9xHOin6RRhL4fQt7Vsn8YCz9dRjl&$_YVTX=Wa&vdFm=_$hh', 'window.name': '$_YWTU=LjFNq_oZCsth6KJ9xHOin6RRhL4fQt7Vsn8YCz9dRjl&$_YVTX=Wa&vdFm=_$hh',
'window.navigator.battery': { 'window.navigator.battery': {
@ -53,46 +68,52 @@ module.exports = class {
'window.innerWidth': 1680, 'window.innerWidth': 1680,
'window.outerHeight': 1025, 'window.outerHeight': 1025,
'window.outerWidth': 1680, 'window.outerWidth': 1680,
'window.document.hidden': false,
formatUid: 46228, // 代码特征码
currentTime: current, // 完整的时间戳
runTime: Math.floor(current / 1000), // 运行时间
startTime: Math.floor(current / 1000) - 1, // 模拟浏览器启动时间
r2mkaTime: +ascii2string(gv.keys[21]), // r2mka文本解析出来的时间
random: null, // 代替Math.random方法返回值
execNumberByTime: execNumberByTime(), // 固定时间内的循环运行次数
...developConfig,
} }
this.runTime = Math.floor(new Date().getTime() / 1000); // 运行时间 // console.log(this.config);
this.startTime = this.runTime - 1; // 模拟浏览器启动时间
this.r2mkaTime = +ascii2string(gv.keys[21]); // r2mka文本解析出来的时间
} }
run() { run() {
return '0' + numarr2string( const basearr = this[`getBasearr_v${gv.version}`]();
encryptMode1([ const nextarr = numarrJoin(
...numToNumarr4(this.r2mkaTime),
...numarrJoin(
numarrJoin( numarrJoin(
gv.r2mka("0>one>32-126").taskarr[73], 2,
numarrJoin( numToNumarr4([this.config.r2mkaTime, this.config.startTime]),
numToNumarr4([this.r2mkaTime, this.startTime]),
string2ascii(gv.cp0[399])
),
gv.keys[2] gv.keys[2]
), ),
encryptMode1( encryptMode1(
xor( xor(
numarrEncrypt(this[`getBasearr_v${gv.version}`]()), numarrEncrypt(basearr),
gv.keys[2], gv.keys[2],
16 16
), ),
numarrAddTime(gv.keys[17], this.runTime)[0], numarrAddTime(gv.keys[17], this.config.runTime, this.config.random)[0],
0 0
) )
)], )
numarrAddTime(gv.keys[16], this.runTime)[0] return '0' + numarr2string(
encryptMode1(
[
...numToNumarr4(uuid(nextarr)),
...nextarr
],
numarrAddTime(gv.keys[16], this.config.runTime, this.config.random)[0],
1,
this.config.random
) )
); );
} }
getBasearr_v2() { getBasearr_v2() {
// 第2版计算cookie方法 // 第2版计算cookie基础数组cookie位数257位(当gv.keys[22]存在值)
const name = this.config['window.name'].split('&').reduce((ans, it) => {
const [key, val] = it.split('=');
return { ...ans, [key]: val };
}, {});
return numarrJoin( return numarrJoin(
3, 3,
numarrJoin( numarrJoin(
@ -102,8 +123,8 @@ module.exports = class {
128, 128,
...numToNumarr4(uuid(this.config['window.navigator.userAgent'])), ...numToNumarr4(uuid(this.config['window.navigator.userAgent'])),
string2ascii(this.config['window.navigator.platform']), string2ascii(this.config['window.navigator.platform']),
...numToNumarr4(_random(500, 1000)), ...numToNumarr4(this.config.execNumberByTime),
...execRandomByNumber(), ...execRandomByNumber(98, this.config.random),
0, 0,
0, 0,
...numToNumarr4(Number(hexnum('3136373737323136'))), ...numToNumarr4(Number(hexnum('3136373737323136'))),
@ -114,50 +135,67 @@ module.exports = class {
...numToNumarr2(this.config['window.outerWidth']), ...numToNumarr2(this.config['window.outerWidth']),
), ),
10, // 下标43 10, // 下标43
[ (() => {
0, // 运行时代码中传入的初始数组长度由于传入的是空数组因此为0 const flag = +ascii2string(gv.keys[24]);
1, // 任务编号0>one>36>one>2-131的任务列表取得 return [
...numToNumarr4(this.r2mkaTime + this.runTime - this.startTime), // ramka串返回的时间 + 当前时间 - 启动时间 flag > 0 && flag < 8 ? 1 : 0,
13,
...numToNumarr4(this.config.r2mkaTime + this.config.runTime - this.config.startTime), // ramka串返回的时间 + 当前时间 - 启动时间
...numToNumarr4(+ascii2string(gv.keys[19])), ...numToNumarr4(+ascii2string(gv.keys[19])),
...numToNumarr8(Math.floor(Math.random() * 1048575) * 4294967296 + (((this.runTime * 1000) & 4294967295) >>> 0)), ...numToNumarr8(Math.floor((this.config.random || Math.random()) * 1048575) * 4294967296 + (((this.config.currentTime + 1) & 4294967295) >>> 0)),
], flag,
7, // 下标63 ];
})(),
7, // 下标64
[ [
...numToNumarr4(16777216), // gv.cp2取得 ...numToNumarr4(16777216), // gv.cp2取得
...numToNumarr4(0), // 任务编号0-0的任务列表取得 ...numToNumarr4(0), // 任务编号0-0的任务列表取得
...numToNumarr2(getFixedNumber()), // 固定值5900 ...numToNumarr2(getFixedNumber()), // 固定值5900
...numToNumarr2(46228), // 根据方法的toString()计算 ...numToNumarr2(this.config.formatUid), // 根据方法的toString()计算, 使用了$_ts.aebi[1]作为任务的方法,
], ],
0, // 任务编号0>one>63-287的任务列表取得 0, // 任务编号0>one>63-287的任务列表取得
[0], // 任务编号0>one>63>one>4-290的任务列表取得 [0], // 任务编号0>one>63>one>4-290的任务列表取得
6, // 下标80 6, // 下标81
[ // 编号510方法执行返回 [ // 编号510方法执行返回
1, 1,
...numToNumarr2(0), ...numToNumarr2(0),
...numToNumarr2(0), ...numToNumarr2(0),
0, this.config['window.document.hidden'] ? 0 : 1,
...encryptMode2(decrypt(name.$_YWTU || ''), numarrAddTime(gv.keys[16])[0]), ...encryptMode2(decrypt(ascii2string(gv.keys[22])), numarrAddTime(gv.keys[16])[0]),
...numToNumarr2(+decode(decrypt(name.$_YVTX || ''))), ...numToNumarr2(+decode(decrypt(ascii2string(gv.keys[22])))),
],
2, // 下标98
[
factorial(5) - factorial(3) * 2 + 100, // 100是cp2里取出来的可能随版本变动
203, // cp2[76]检测window.HTMLFormElement是否存在
102, // cp2[120]检测document.createElement('from')
103, // 检测window.top值是否为null
],
9, // 下标104
[
0 | 8, // 8为cp2中的值
['bluetooth', 'cellular', 'ethernet', 'wifi', 'wimax'].indexOf(this.config['window.navigator.connection'].type) + 1,
], ],
2, // 下标99
(() => {
const taskmap = {}
runTask('0>one>71>one>4-342', [taskmap]);
return [29, 30, 31, 32].map(it => {
return taskmap[ascii2string(gv.keys[it])]();
})
})(),
9, // 下标105
(() => { // 编号133方法
const { connType } = this.config['window.navigator.connection'];
const { charging, chargingTime, level } = this.config['window.navigator.battery']
const connTypeIdx = ['bluetooth', 'cellular', 'ethernet', 'wifi', 'wimax'].indexOf(connType) + 1;
let oper = 0;
if (level) oper |= 2;
if (charging) oper |= 1;
if (connTypeIdx !== undefined) oper |= 8
return [
oper,
level * 100,
chargingTime >> 8,
chargingTime & 255,
connTypeIdx,
]
})(),
13, 13,
[0], [0],
) )
} }
getBasearr_v1() { getBasearr_v1() {
// 第1版计算cookie方法 // 第1版计算cookie基础数组cookie位数236位
const { getTaskNumber: gtn } = this; const { getTaskNumber: gtn } = this;
return numarrJoin( return numarrJoin(
3, 3,

View File

@ -1,72 +0,0 @@
const gv = require('@src/handler/globalVarible');
const monitor = require('@utils/monitor');
const logger = require('@utils/logger');
module.exports = function(...params) {
logger.trace('执行开始!');
try {
return dynamicExec(...params);
} catch (err) {
logger.error(String(err));
throw err;
} finally {
logger.trace('执行结束!');
}
}
function dynamicExec(taskItem, start = 0, args = [], loop_res = {}, global_res = {}) {
const codemap = gv.config.codemap;
const { key, taskarr: task } = taskItem;
args = monitor(args, `${key}_args`, { getLog: true, setLog: true });
loop_res = monitor(loop_res, `${key}_loop_res`, { getLog: true, setLog: true });
global_res = monitor(global_res, `${key}_global_res`, { getLog: true, setLog: true });
logger.trace(`动态代码运行,任务列表:${key}, 起点:${start},长度:${task.length}`);
const data = [];
const ret = [];
ret[0] = args;
ret[2] = [ 'window', args ];
const vars = [
`${codemap.params[0]} = taskItem`,
`${codemap.params[1]} = start`,
`${codemap.params[2]} = task.length`,
`${codemap.params[3]} = ret`,
// 任务列表
`${codemap.taskarr} = taskItem.taskarr`,
// 数据数组
`${codemap.dataKey} = data`,
// 数据数组游标
`${codemap.dataIdx} = 0`,
`${codemap.ret0} = ret[0]`,
`${codemap.ret1} = ret[1]`,
`${codemap.ret2} = ret[2]`,
`${codemap.ret3} = ret[3]`,
// 全局资源
`${codemap.globalRes} = global_res`,
// 本地资源
`${codemap.loopRes} = loop_res`,
`${codemap.forcur} = start`,
`${codemap.formax} = task.length`,
...codemap.varible,
].join(', ');
eval(`var ${vars};${codemap.commonFunc}`)
for (let t_cursor = start, idx = 0; t_cursor < task.length; t_cursor++) {
idx ++;
if (typeof codemap[task[t_cursor]] !== 'string') {
logger.error(`codemap中下标${task[t_cursor]}不存在值!`)
} else {
eval(`${codemap.forcur}=t_cursor`);
codemap[task[t_cursor]].split(';').map(it => it.trim()).forEach(c => {
try {
eval(c);
} catch(err) {
logger.error(`代码: ${c} 执行失败,当前任务:${taskItem.key}`)
debugger;
throw err;
}
})
eval(`t_cursor=${codemap.forcur}`);
}
}
return ret[5];
}

View File

@ -21,7 +21,6 @@ module.exports = {
numarrEncrypt: require('./numarrEncrypt'), numarrEncrypt: require('./numarrEncrypt'),
numarr2string: require('./numarr2string'), numarr2string: require('./numarr2string'),
numarrJoin: require('./numarrJoin'), numarrJoin: require('./numarrJoin'),
dynamicExec: require('./dynamicExec'),
numarrAlterByNumber: require('./numarrAlterByNumber'), numarrAlterByNumber: require('./numarrAlterByNumber'),
runTask: require('./runTask'), runTask: require('./runTask'),
} }

View File

@ -56,14 +56,14 @@ function getCfg(numarr) {
return [ret, arr]; return [ret, arr];
} }
function encryptMode1(valarr, keyarr, flag = 1) { function encryptMode1(valarr, keyarr, flag = 1, random) {
const cfg = getCfg(keyarr); const cfg = getCfg(keyarr);
var _$iv, _$j7, _$kb, _$ka, _$dV, _$du, _$jb; var _$iv, _$j7, _$kb, _$ka, _$dV, _$du, _$jb;
const max = Math.floor(valarr.length / 16) + 1; const max = Math.floor(valarr.length / 16) + 1;
let ans = [], arr; let ans = [], arr;
const fill = 16 - valarr.length % 16; const fill = 16 - valarr.length % 16;
if (flag) { if (flag) {
ans = arr = new Array(4).fill(4294967295).map(it => Math.floor(Math.random() * it)); ans = arr = new Array(4).fill(4294967295).map(it => Math.floor((random || Math.random()) * it));
} }
const copyarr = numToNumarr4.reverse_sign([...valarr, ...new Array(fill).fill(fill)]); const copyarr = numToNumarr4.reverse_sign([...valarr, ...new Array(fill).fill(fill)]);
for (let i = 0; i < max; ) { for (let i = 0; i < max; ) {

View File

@ -2,9 +2,9 @@
const gv = require('@src/handler/globalVarible'); const gv = require('@src/handler/globalVarible');
const numToNumarr4 = require('./numToNumarr4'); const numToNumarr4 = require('./numToNumarr4');
module.exports = function(numarr, time) { module.exports = function(numarr, time, random) {
// time为时间戳除以1000后向上取整如果不传则取当前时间戳 // time为时间戳除以1000后向上取整如果不传则取当前时间戳
const ele = Math.ceil(Math.random() * 256); const ele = Math.ceil((random || Math.random()) * 256);
const now = time || Math.floor(new Date().getTime() / 1000); const now = time || Math.floor(new Date().getTime() / 1000);
const arr = [...numarr, ...numToNumarr4(now)].map(it => it ^ ele); const arr = [...numarr, ...numToNumarr4(now)].map(it => it ^ ele);
arr.push(ele); arr.push(ele);

View File

@ -10,11 +10,11 @@ exports.execNumberByTime = function (times = 3) {
return i; return i;
} }
exports.execRandomByNumber = function (nums = 98) { exports.execRandomByNumber = function (nums = 98, random) {
// 指定次数的随机数取平均值后四舍五入 // 指定次数的随机数取平均值后四舍五入
if (typeof nums !== 'number') return; if (typeof nums !== 'number') return;
const arr = [] const arr = []
for (let i = 0; i < nums; i++) arr.push(Math.random()); for (let i = 0; i < nums; i++) arr.push(random || Math.random());
const avg = _sum(arr) / nums; const avg = _sum(arr) / nums;
return [ return [
avg * 100, avg * 100,

View File

@ -1,17 +1,16 @@
// 直接通过动态代码执行来运行任务 // 直接通过动态代码执行来运行任务
// 该方法并未完全还原,谨慎使用 // 该方法并未完全还原,谨慎使用
const gv = require('@src/handler/globalVarible'); const gv = require('@src/handler/globalVarible');
const dynamicExec = require('./dynamicExec'); const monitor = require('@utils/monitor');
const logger = require('@utils/logger');
const custask = require('../task'); const custask = require('../task');
const error = require('@utils/error'); const error = require('@utils/error');
const logger = require('@utils/logger');
module.exports = function(taskid, args, allowTask) { module.exports = function(task, args, allowTask) {
// taskid为任务idallowTask为允许执行的任务 if (typeof task === 'string') task = gv.r2mka(task);
const task = gv.r2mka(taskid); if (!task) throw new Error('任务未找到');
if (!task) { logger.debug(`${task.key}执行开始!`);
error(`任务未找到`, { taskid }); try {
}
const global_res = new Proxy({}, { const global_res = new Proxy({}, {
get(target, property, receiver) { get(target, property, receiver) {
// 由于每个版本下标都会变在解析cd值生成8位偏移数的时候只用到了cp2数组因此这里只返回cp2需要注意 // 由于每个版本下标都会变在解析cd值生成8位偏移数的时候只用到了cp2数组因此这里只返回cp2需要注意
@ -41,5 +40,99 @@ module.exports = function(taskid, args, allowTask) {
} }
}) })
return dynamicExec(task, 0, args, loop_res, global_res); return dynamicExec(task, 0, args, loop_res, global_res);
} catch (err) {
logger.error(String(err));
throw err;
} finally {
logger.debug(`${task.key}执行结束!`);
}
}
function taskFactory(task, args) {
return (...params) => {
if (custask[task.key]) return custask[task.key](...params);
return module.exports(task, params);
}
}
function getParentSubTask(task, loopRes) {
const subTask = [];
if (!task) debugger;
while (task.isReset === 0 && task.key !== '0-0') {
subTask.push(['window', 'args', ...task.child_one.slice(2).map(it => taskFactory(it))]);
task = task.parent;
}
return [loopRes, ...subTask.reverse()];
}
function dynamicExec(taskItem, start = 0, args = [], loop_res = {}, global_res = {}) {
const codemap = gv.config.codemap;
const { key, taskarr: task } = taskItem;
args = monitor(args, `${key}_args`, { getLog: true, setLog: true });
loop_res = monitor(loop_res, `${key}_loop_res`, { getLog: true, setLog: true });
global_res = monitor(global_res, `${key}_global_res`, { getLog: true, setLog: true });
logger.debug(`动态代码运行,任务列表:${key}, 起点:${start},长度:${task.length}`);
const data = [];
const ret = [];
ret[0] = args;
ret[2] = [ 'window', args ];
ret[3] = getParentSubTask(taskItem.parent, loop_res);
const taskItemProxy = new Proxy({}, {
get(target, property, receiver) {
const idx = codemap.taskAttr.indexOf(property);
if (idx === -1) debugger;
const name = ['lens', 'isReset', 'taskarr', 'child_one', 'child_two'][idx];
if (!name) debugger;
return taskItem[name];
}
})
const vars = [
`${codemap.params[0]} = taskItemProxy`,
`${codemap.params[1]} = start`,
`${codemap.params[2]} = task.length`,
`${codemap.params[3]} = ret`,
// 任务工厂函数
`${codemap.taskFactory} = taskFactory`,
`${codemap.keyname} = gv.ts.cp[1]`,
// 任务列表
`${codemap.taskarr} = task`,
// 数据数组
`${codemap.dataKey} = data`,
// 数据数组游标
`${codemap.dataIdx} = 0`,
`${codemap.ret0} = ret[0]`,
`${codemap.ret1} = ret[1]`,
`${codemap.ret2} = ret[2]`,
`${codemap.ret3} = ret[3]`,
// 全局资源
`${codemap.globalRes} = global_res`,
// 本地资源
`${codemap.loopRes} = loop_res`,
`${codemap.forcur} = start`,
`${codemap.formax} = task.length`,
...codemap.varible,
].join(', ');
eval(`var ${vars};${codemap.commonFunc}`)
for (let t_cursor = start, idx = 0; t_cursor < task.length; t_cursor++) {
idx ++;
if (typeof codemap[task[t_cursor]] !== 'string') {
logger.error(`codemap中下标${task[t_cursor]}不存在值!`)
} else {
logger.debug(`(${key}, ${idx})执行代码:${codemap[task[t_cursor]]}`);
eval(`${codemap.forcur}=t_cursor`);
codemap[task[t_cursor]].split(';').map(it => it.trim()).forEach(c => {
try {
eval(c);
} catch(err) {
logger.error(`代码: ${c} 执行失败,当前任务:${key}`)
debugger;
throw err;
}
})
eval(`t_cursor=${codemap.forcur}`);
}
}
return ret[5];
} }

View File

@ -27,8 +27,9 @@ function gtHandler(str, curr) {
const parse = (() => { const parse = (() => {
let count = 0; let count = 0;
const valMap = {}; const valMap = {};
return function(val, deep = 0, deeps = [0]) { return function(val, deep = 0, deeps = [0], parent = null) {
const str = val.taskstr; const str = val.taskstr;
val.parent = parent;
val.taskstr = str; val.taskstr = str;
val.val = {}; val.val = {};
if (!str) { if (!str) {
@ -41,12 +42,12 @@ const parse = (() => {
valMap[val.key] = val; valMap[val.key] = val;
val.child_one.map((it, idx) => { val.child_one.map((it, idx) => {
if (it) { if (it) {
parse(it, deep + 1, [...deeps, 'one', idx]); parse(it, deep + 1, [...deeps, 'one', idx], val);
} }
}); });
val.child_two.map((it, idx) => { val.child_two.map((it, idx) => {
if (it) { if (it) {
parse(it, deep + 1, [...deeps, 'two', idx]); parse(it, deep + 1, [...deeps, 'two', idx], val);
} }
}); });
return (key) => { return (key) => {

View File

@ -1,12 +1,29 @@
const gv = require('@src/handler/globalVarible'); const gv = require('@src/handler/globalVarible');
// 预期任务作用,实际还没有用到,需要多版本对比 /*
const expectTask = { * 1. 0>one>71>one>4>two>2-348与0>one>71>one>4>two>12-358返回值来源一致
'0>one>71>one>4>one>3-344': '计算阶乘' */
}
module.exports = { module.exports = {
'0>one>21-23': (num) => { '0>one>21-23': (num) => {
return Math.abs(num) % 8; return Math.abs(num) % 8;
}, },
'0>one>71>one>4>two>2-348': () => {
// 该任务首先检测document.createElement('a')是否能成功成功则返回gv.cp2中的固定值
return 102;
},
'0>one>71>one>4>two>12-358': () => {
// 该任务首先检测document.createElement('form')是否能成功成功则返回gv.cp2中的固定值
return 102;
},
'0>one>71>one>4>two>4-350': () => {
// 该任务首先检测window.navigator.userAgent是否为string格式是的话进行计算后返回
// **需要注意是否返回同一值**
return 224;
},
'0>one>71>one>4>two>14-360': () => {
// 该任务首先检测window.navigator.userAgent是否为string格式是的话进行计算后返回
// **需要注意是否返回同一值**
return 225;
}
} }

View File

@ -0,0 +1,14 @@
// 遇到的gv.keys使用放在这里方便归档查阅
const gv = require('@src/handler/globalVarible');
exports.dkeys = function () {
return {
7: gv.utils.ascii2string(gv.keys[7]).split(';'),
22: gv.utils.ascii2string(gv.keys[22]),
29: gv.utils.ascii2string(gv.keys[29]),
30: gv.utils.ascii2string(gv.keys[30]),
31: gv.utils.ascii2string(gv.keys[31]),
33: gv.utils.ascii2string(gv.keys[33]),
34: gv.utils.ascii2string(gv.keys[34]),
};
}

View File

@ -0,0 +1,3 @@
module.exports = {
...require('./dkeys'),
}

View File

@ -6,6 +6,7 @@ const Coder = require('./handler/Coder');
const Cookie = require('./handler/Cookie'); const Cookie = require('./handler/Cookie');
const unescape = require('@utils/unescape'); const unescape = require('@utils/unescape');
const gv = require('@src/handler/globalVarible'); const gv = require('@src/handler/globalVarible');
const getCode = require('@utils/getCode');
function parseR2mka(text) { function parseR2mka(text) {
const start = text.indexOf('"') + 1; const start = text.indexOf('"') + 1;
@ -13,15 +14,15 @@ function parseR2mka(text) {
return unescape(text.substr(start, end)); return unescape(text.substr(start, end));
} }
module.exports = function (ts, immucfg) { module.exports = function (ts, immucfg, mate) {
console.log('还原更多加密文件如app.js等作者开发中可关注微信订阅号`码功`获取项目更新推送!');
return
gv._setAttr('_ts', ts); gv._setAttr('_ts', ts);
const startTime = new Date().getTime(); const startTime = new Date().getTime();
const coder = new Coder(ts, immucfg); const coder = new Coder(ts, immucfg);
const { code, $_ts } = coder.run(); const { code, $_ts } = coder.run();
const r2mkaText = parseR2mka(coder.r2mkaText); const r2mkaText = parseR2mka(coder.r2mkaText);
const cookie = new Cookie($_ts, r2mkaText).run(); const cookieVal = new Cookie($_ts, r2mkaText).run();
return cookie; const cookieKey = gv.utils.ascii2string(gv.keys[7]).split(';')[5] + 'P';
debugger;
getCode(mate.url, `${cookieKey}=${cookieVal}`);
} }

View File

@ -1,5 +1,5 @@
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
const request = require('request-promise'); const { request, cookieJar } = require('./request');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const isValidUrl = require('./isValidUrl'); const isValidUrl = require('./isValidUrl');
const _get = require('lodash/get'); const _get = require('lodash/get');
@ -7,16 +7,26 @@ const urlresolve = require('url').resolve;
function addRequestHead(uri) { function addRequestHead(uri) {
return { return {
// proxy: 'http://127.0.0.1:7777', proxy: 'http://127.0.0.1:8888',
// gzip: true gzip: true,
uri, uri,
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
resolveWithFullResponse: true, resolveWithFullResponse: true,
simple: false, simple: false,
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'Connection': 'keep-alive',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
} }
} }
module.exports = async function getCode(url) { module.exports = async function getCode(url, cookieStr) {
if (cookieStr) {
cookieJar.setCookie(request.cookie(cookieStr), url);
console.log(`当前cookie${cookieJar.getCookieString(url)}`);
}
if (!isValidUrl(url)) throw new Error('输入链接不正确'); if (!isValidUrl(url)) throw new Error('输入链接不正确');
const res = await request(addRequestHead(url)); const res = await request(addRequestHead(url));
const $ = cheerio.load(res.body); const $ = cheerio.load(res.body);
@ -34,3 +44,23 @@ module.exports = async function getCode(url) {
} }
throw new Error('js外链中没有瑞数的代码文件'); throw new Error('js外链中没有瑞数的代码文件');
} }
// Host: wcjs.sbj.cnipa.gov.cn
// Connection: keep-alive
// Upgrade-Insecure-Requests: 1
// sec-ch-ua: "Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"
// sec-ch-ua-mobile: ?0
// sec-ch-ua-platform: "macOS"
// User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
// Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
// Accept-Encoding: gzip, deflate, br, zstd
// Accept-Language: zh-CN,zh;q=0.9
// Sec-Fetch-Dest: document
// Sec-Fetch-Mode: navigate
//
// Sec-Fetch-Site: none
// Sec-Fetch-User: ?1
//
//
// Sec-Fetch-Site: same-origin
// Referer: https://wcjs.sbj.cnipa.gov.cn/sgtmi

View File

@ -3,14 +3,17 @@ const fs = require('fs');
const { init } = require('@src/handler/parser/'); const { init } = require('@src/handler/parser/');
const logger = require('./logger'); const logger = require('./logger');
const gv = require('@src/handler/globalVarible'); const gv = require('@src/handler/globalVarible');
const Coder = require('@src/handler/Coder');
module.exports = function(filepath) { module.exports = function(filepath) {
if (typeof filepath !== 'string') { if (typeof filepath !== 'string') {
if (typeof filepath === 'number') gv._setAttr('version', filepath); if (typeof filepath === 'number') gv._setAttr('version', filepath);
filepath = paths.exampleResolve('codes', `${gv.version}-$_ts-full.json`) filepath = paths.exampleResolve('codes', `${gv.version}-$_ts.json`)
} }
if (!fs.existsSync(filepath)) throw new Error(`输入文件不存在: ${filepath}`); if (!fs.existsSync(filepath)) throw new Error(`输入文件不存在: ${filepath}`);
logger.debug(`初始化GlobalVarible变量$_ts配置文件${filepath}`); logger.debug(`初始化GlobalVarible变量$_ts配置文件${filepath}`);
init(JSON.parse(fs.readFileSync(filepath, 'utf8'))); const coder = new Coder(JSON.parse(fs.readFileSync(filepath, 'utf8')));
const { code, $_ts } = coder.run();
init($_ts);
return gv; return gv;
}; };

8
utils/request.js Normal file
View File

@ -0,0 +1,8 @@
const rp = require('request-promise');
const cookieJar = rp.jar()
const request = rp.defaults({ jar: cookieJar })
module.exports = {
request,
cookieJar,
}