提交 14d2a111 作者: 毛细亚

修改映射表

上级 4335f478
......@@ -4,14 +4,14 @@ module.exports = {
// seed:845729517, //此选项为随机生成器设置种子。这对于创建可重复的结果很有用
stringArray: true, // 压缩成一行 删除字符串文字并将它们放在一个特殊的数组中。例如,字符串"Hello World"invar m = "Hello World";将被替换为类似var m = _0x12c456[0x1];
// 僵尸代码
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.7,
deadCodeInjection: false,
deadCodeInjectionThreshold: 0,
// controlFlowFlatteningThreshold:0.75,// 此设置对于大型代码特别有用,因为大量的控制流转换会减慢您的代码并增加代码大小。
debugProtection: true,// 此选项几乎不可能使用开发者工具的控制台选项卡
debugProtectionInterval: true,// 如果选中,则会在“控制台”选项卡上使用间隔强制调试模式,从而更难使用“开发人员工具”的其他功能。
log: true,// 是否允许将信息记录到控制台。
disableConsoleOutput: true,// 通过用空函数替换它们来禁用console.log,console.info,console.error和console.warn。这使得调试器的使用更加困难。
identifierNamesGenerator:'hexadecimal', //标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符) dictionary 需要与identifiersDictionary同时使用 mangled-shuffled 和 mangled 相同 但是字母会被打乱 不知为何 mangled 会无响应 所以推荐用 mangled-shuffled
// identifierNamesGenerator:'mangled', //标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符) dictionary 需要与identifiersDictionary同时使用 mangled-shuffled 和 mangled 相同 但是字母会被打乱 不知为何 mangled 会无响应 所以推荐用 mangled-shuffled
// identifiersDictionary:['_zw_,_mxy_,_zwan_,-nzy_'],//dictionary选项设置标识符字典。字典中的每个标识符将用于几个变体,每个字符的大小写不同。因此,字典中标识符的数量应取决于原始源代码中的标识符数量。
identifiersPrefix:'$_',//全局标识符添加特定前缀,在混淆同一页面上加载的多个文件时使用此选项。此选项有助于避免这些文件的全局标识符之间发生冲突。为每个文件使用不同的前缀
// identifierNamesCache:{}, // 此选项的主要目标是能够在混淆多个源/文件期间使用相同的标识符名称。
......@@ -19,17 +19,18 @@ module.exports = {
// numbersToExpressions:true,//启用数字到表达式的转换 会将数字转化为表达式的形式 eg:const foo = 1234; output const foo=-0xd93+-0x10b4+0x41*0x67+0x84e*0x3+-0xff8;
renameGlobals: true,// 是否启用全局变量和函数名称的混淆
// renameProperties:true,//启用属性名称的重命名。所有内置 DOM 属性和核心 JavaScript 类中的属性都将被忽略。这个打开会报错
// renamePropertiesMode:'safe'
// renamePropertiesMode:safe 设置renameProperties重命名的方式 尝试以更安全的方式重命名属性以防止运行时错误。在这种模式下,某些属性将被排除在重命名之外。 unsafe以不安全的方式重命名属性,没有任何限制。
simplify:true,// 通过简化实现额外的代码混淆。
rotateStringArray: true,// 通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意
rotateStringArray: false,// 通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意
// 编码的所有字符串文字stringArray使用base64或rc4并插入即用其解码回在运行时的特殊代码。true(boolean):stringArray使用编码值base64;false(boolean):不编码stringArray值;'base64'(string):stringArray使用编码值base64;'rc4'(string):stringArray使用编码值rc4。大约慢30-50%base64,但更难获得初始值。建议禁用unicodeEscapeSequence带rc4编码的选项以防止非常大的混淆代码。
// splitStrings:true,//将文字字符串拆分为具有splitStringsChunkLength选项值长度的块。
// splitStringsChunkLength:0.5,//设置splitStrings选项的块长度。
stringArrayEncoding: ['base64'],
// stringArrayEncoding: ['base64'],
// stringArrayThreshold:0,
// stringArrayIndexesType:['hexadecimal-number'],'hexadecimal-number'( default): 将字符串数组调用索引转换为十六进制数 'hexadecimal-numeric-string': 将字符串数组调用索引转换为十六进制数字字符串
stringArrayIndexShift:true,// 为所有字符串数组调用启用额外的索引移位
stringArrayShuffle:true,//随机打乱stringArray数组项。
stringArrayIndexShift:false,// 为所有字符串数组调用启用额外的索引移位
stringArrayShuffle:false,//随机打乱stringArray数组项。
// stringArrayWrappersCount:1,//设置string array每个根或函数作用域内部的包装器计数。每个范围内的实际包装器数量literal受此范围内节点数的限制。
selfDefending: true,// 混淆后不能时使用代码美化
// 允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小,并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。
......
// 处理编译好的代码
var strList =[];
const path = require('path')
const fs =require("fs");
const resolve = (p) => path.resolve(__dirname, "./", p)
const rfStr = path.resolve(__dirname, '../dist/code.js')
const code =fs.readFileSync(rfStr,'utf-8')
function decode(){
let obj = {}
let newCode='';
var str = code.match(/\'.*?\'/g)
// 获取对象的
str.map(function(item,index){
obj[`zw_${scale36(index)}`] = str[index]
})
newCode = code.replace(/\'.*?\'/g,function(data){
for (const key in obj) {
if(data == obj[key]){
return `obj.${key}`
}
}
return string23;
})
console.log(newCode)
// 生成文件 保存json对象
fs.writeFileSync('newCode.js', newCode)
fs.writeFileSync('lisi.json', JSON.stringify(obj))
}
decode()
function getNums36() {
var nums36 = []
for (var i = 0; i < 36; i++) {
if (i >= 0 && i <= 9) {
nums36.push(i)
} else {
nums36.push(String.fromCharCode(i + 87))
}
}
return nums36
}
//十进制数转成36进制
function scale36(n) {
var arr = []
var nums36 = getNums36()
while (n) {
var res = n % 36
//作为下标,对应的36进制数,转换成
arr.unshift(nums36[res])
//去掉个位
n = parseInt(n / 36)
}
return arr.join('')
}
module.exports = {
decode(code){
console.log(rfStr)
// var str = code.match(/\['.*?\']/g)
console.log(rfStr)
}
}
\ No newline at end of file
var s = ['a','b','c']
var list = [];
var perm = function(s) {
var result = [];
if (s.length <= 1) {
return [s];
} else {
for (var i = 0; i < s.length; i++) {
var c = s[i];
var newStr = s.slice(0, i) +''+ s.slice(i + 1, s.length);
console.log(newStr)
var l = perm(newStr);
for (var j = 0; j < l.length; j++) {
var tmp = c + l[j];
result.push(tmp);
}
}
}
list = list.concat(result)
// console.log(list)
return result;
}
perm(s)
\ No newline at end of file
const fileList = ['/subpackage/main.min.js'] // 根目录为src文件夹
const fileList = ['code.js'] // 根目录为src文件夹
// '/subpackage/main.min.js'
module.exports = {
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=]\, initial-scale=1.0">
<title>Document</title>
<script src="./demo.js"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
const ConcatSource = require('webpack-sources').ConcatSource
const CompileCode = require('./compileCode')
class ChangeString{
constructor(options){
}
apply(compiler){
// 最新的写法
// compiler.hooks.compilation.tap('compilation',function(compilation){
// console.log(compilation)
// })
compiler.hooks.compilation.tap('emit',function(compilation){
compilation.hooks.optimizeChunkAssets.tap('CustomPlugin',(chunks)=>{
chunks.forEach(chunk=>{
chunk.files.forEach(fileName=>{
// 处理编译好的代码
// CompileCode.decode(compilation.assets[fileName])
CompileCode.decode(compilation.assets[fileName].source())
// console.log(compilation.assets[fileName].source()) // 处理之后的源码
// compilation.assets[fileName] 就是的内容
// compilation.assets[fileName] = new ConcatSource('var a=0;',compilation.assets[fileName],'var b=1;');
})
})
})
})
// compiler.plugin('emit',function(compilation,callback){
// console.log(compilation)
// })
}
}
module.exports = ChangeString
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,6 +10,7 @@ const outputDir = resolve("dist")
const Obfuscator = require('./build/WebpackObfuscator.config.js')
const entryFiles = require('./build/fileList').fileList // 这里是需要打包的文件目录
const env = process.env.ENVIROMENT.trim();
const ChangeValue = require('./build/plugin.js')
let ObfuscatorType = {};
let
entry = {},
......@@ -23,13 +24,7 @@ function configInfi() {
output.path = outputDir;
}
})
if(env=='simple'){
ObfuscatorType = Obfuscator.simple
}else if(env=='ordinary'){
ObfuscatorType = Obfuscator.ordinary
}else if(env=='highly'){
ObfuscatorType = Obfuscator.highly
}else if(env=='my'){
if(env=='my'){
ObfuscatorType = Obfuscator.my
}else{
ObfuscatorType={}
......@@ -64,6 +59,7 @@ module.exports={
plugins:[
new webpack.NoEmitOnErrorsPlugin(),
new WebpackObfuscator (ObfuscatorType),
// new ChangeValue({name:'111'})
]
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论