Skip to content

Commit

Permalink
sojsonv7: add method for detecting and removing domain-lock #75
Browse files Browse the repository at this point in the history
The protection originates from javascript-obfuscator and this version starts with commit javascript-obfuscator/javascript-obfuscator@8a81043

Signed-off-by: echo094 <[email protected]>
  • Loading branch information
echo094 authored Feb 25, 2024
1 parent 5c365b6 commit f6f3101
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/plugin/sojsonv7.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function removeUniqueCall(path) {
} else if (up1.key === 'init') {
let up2 = up1.parentPath
let call = up2.node.id.name
console.info(`Remove call: ${decorator}`)
console.info(`Remove call: ${call}`)
let bind2 = up2.scope.getBinding(call)
up2.remove()
for (let ref of bind2.referencePaths) {
Expand Down Expand Up @@ -775,13 +775,50 @@ function unlockLint(path) {
removeUniqueCall(rm)
}

function unlockDomainLock(path) {
const array_list = [
'[7,116,5,101,3,117,0,100]',
'[5,110,0,100]',
'[7,110,0,108]',
'[7,101,0,104]',
]
const checkArray = (node) => {
const trim = node.split(' ').join('')
for (let i = 0; i < 4; ++i) {
if (array_list[i] == trim) {
return i + 1
}
}
return 0
}
if (path.findParent((up) => up.removed)) {
return
}
let mask = 1 << checkArray('' + path)
if (mask == 1) {
return
}
let rm = path.getFunctionParent()
rm.traverse({
ArrayExpression: function (item) {
mask = mask | (1 << checkArray('' + item))
},
})
if (mask & 0b11110) {
console.info('Find domain lock')
removeUniqueCall(rm)
}
}

function unlockEnv(ast) {
// 删除`禁止控制台调试`函数
traverse(ast, { DebuggerStatement: unlockDebugger })
// 删除`禁止控制台输出`函数
traverse(ast, { VariableDeclarator: unlockConsole })
// 删除`禁止换行`函数
traverse(ast, { StringLiteral: unlockLint })
// 删除`安全域名`函数
traverse(ast, { ArrayExpression: unlockDomainLock })
}

/**
Expand Down

0 comments on commit f6f3101

Please sign in to comment.