1 Star 0 Fork 16

瓜皮 / 维普瑞数5解混淆工具

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
astWeiPu.js 6.83 KB
一键复制 编辑 原始数据 按行查看 历史
陈不不 提交于 2022-04-10 10:15 . AST解混淆
const fs = require('fs');
const parser = require('@babel/parser');
const traverse = require('@babel/traverse').default;
const tee = require('@babel/types');
const generator = require("@babel/generator").default;
var cbbiyhh = () => {
var text = fs.readFileSync('./weipu.js', {
encoding: "utf-8"
});
var ast = parser.parse(text.toString(), {
sourceType: "module"
});
var allverList = ['String.fromCharCode'];
var astWeiPu = {
VariableDeclarator(path) {
if (allverList.indexOf(generator(path.node.init).code) != -1 && tee.isIdentifier(path.node.init) && tee.isIdentifier(path.node.id)) {
console.log(generator(path.node.init).code)
var binDing = path.scope.getBinding(path.node.id.name);
for (let i = 0; i < binDing.referencePaths.length; i++) {
binDing.referencePaths[i].replaceWith(path.node.init)
}
;
}
;
},
};
traverse(ast, astWeiPu);
astText = generator(ast, {
minified: false,
jsescOption: {
minimal: true
}
}).code;
var ast = parser.parse(astText, {
sourceType: "module"
});
traverse(ast, {
VariableDeclarator(path) {
if (generator(path.node.init).code == "String.fromCharCode") {
if (tee.isArrayExpression(path.container[0].init) && path.container[0].init.elements.length == 0 && tee.isArrayExpression(path.container[1].init) && path.container[1].init.elements.length == 0) {
console.log(1)
} else {
return;
}
var jieHxDeName = [];
jieHxDeName.push(path.container[0].id.name);
jieHxDeName.push(path.container[1].id.name);
var jiamiName = path.parentPath.container[path.parentPath.key + 2];
var needUseList = path.parentPath.container.slice(path.parentPath.key, path.parentPath.key + 4);
let jianMi = path.scope.getBinding(jiamiName.expression.callee.name).path;
let veryListHans = jianMi.node.body.body[1].expression.right.callee.object.callee.name
let jianMi2xg = path.scope.getBinding(veryListHans)
let jianMi2 = jianMi2xg.path;
jiamiName = path.parentPath.container[path.parentPath.key + 3];
let jianMi3 = path.scope.getBinding(jiamiName.expression.callee.name).path;
eval(jianMi2 + "")
eval(jianMi + "")
eval(jianMi3 + "")
for (let i = 0; i < needUseList.length; i++) {
eval(generator(needUseList[i]).code)
}
for (let i = 0; i < jieHxDeName.length; i++) {
let habnuu = path.scope.getBinding(jieHxDeName[i]);
for (let yhh = 0; yhh < habnuu.referencePaths.length; yhh++) {
if (!(habnuu.referencePaths[yhh].parentPath.isMemberExpression() && tee.isNumericLiteral(habnuu.referencePaths[yhh].parentPath.node.property))) {
continue
}
;
// try {
habnuu.referencePaths[yhh].parentPath.replaceWith(tee.valueToNode(eval(habnuu.referencePaths[yhh].parentPath + "")));
path.stop()
// }catch (e) {
// debugger;
// }
}
}
;
//["ceil"](_$nD.length
for (let p = 0; p < jianMi2xg.referencePaths.length; p++) {
if (jianMi2xg.referencePaths[p].parentPath.isCallExpression() && jianMi2xg.referencePaths[p].parentPath.node.arguments.length == 1 && tee.isStringLiteral(jianMi2xg.referencePaths[p].parentPath.node.arguments[0])) {
jianMi2xg.referencePaths[p].parentPath.replaceWith(tee.valueToNode(eval(jianMi2xg.referencePaths[p].parentPath + "")))
}
}
;
path.stop();
}
;
},
});
astText = generator(ast, {
minified: false,
jsescOption: {
minimal: true
}
}).code;
var ast = parser.parse(astText, {
sourceType: "module"
});
var getOver = {
ArrayExpression(path) {
if (path.parentPath.isVariableDeclarator() && path.node.elements.length != 0) {
var banding = path.scope.getBinding(path.parent.id.name);
if (banding.constantViolations.length != 0) {
return;
}
for (var i = 0; i < banding.referencePaths.length; i++) {
try {
banding.referencePaths[i].parentPath.replaceWith(path.node.elements[banding.referencePaths[i].parent.property.value]);
} catch (e) {
}
;
}
;
}
;
},
}
traverse(ast, getOver);
astText = generator(ast, {
minified: false,
jsescOption: {
minimal: true
}
}).code;
for (let i = 0; i < 5; i++) {
ast = parser.parse(astText, {
sourceType: "module"
})
traverse(ast, {
BinaryExpression(path) {
let left = path.node.left;
let right = path.node.right;
if ((tee.isNumericLiteral(left) || tee.isUnaryExpression(left)) && (tee.isNumericLiteral(right) || tee.isUnaryExpression(right))) {
try {
let {confident, value} = path.evaluate();
confident && path.replaceWith(tee.valueToNode(value));
} catch (e) {
}
}
;
},
ReturnStatement(path) {
if (tee.isSequenceExpression(path.node.argument)) {
expressions = path.node.argument.expressions;
popExpressions = expressions.pop();
expressions.map((v) => {
path.insertBefore(tee.ExpressionStatement(v));
});
path.node.argument = popExpressions;
}
}
});
break
};
astText = generator(ast, {
minified: true,
jsescOption: {
minimal: true
}
}).code;
fs.writeFile('./weipu2.js',
astText, (err) => {
}
)
console.log(1);
return 1;
};
cbbiyhh()
1
https://gitee.com/guapi/AST.git
git@gitee.com:guapi/AST.git
guapi
AST
维普瑞数5解混淆工具
master

搜索帮助