Skip to content

Commit 0178183

Browse files
committed
Stack update
1 parent cd2859e commit 0178183

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/plugin/jsconfuser.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,25 @@ function processAssignLeft(vm, cache, path, prop_name, stk_name) {
379379
vm.evalSync(generator(father.node).code)
380380
cache[prop_name] = {
381381
type: 'value',
382-
value: right.node.value,
382+
value: right.node,
383383
}
384384
return
385385
}
386+
if (right.isArrayExpression()) {
387+
const elements = right.node.elements
388+
if (elements.length === 1 && elements[0]?.value === 'charCodeAt') {
389+
cache[prop_name] = {
390+
type: 'value',
391+
value: right.node,
392+
}
393+
return
394+
}
395+
}
386396
if (right.isUnaryExpression() && right.node.operator === '-') {
387-
const value = vm.evalSync(generator(right.node).code)
388397
vm.evalSync(generator(father.node).code)
389398
cache[prop_name] = {
390399
type: 'value',
391-
value: value,
400+
value: right.node,
392401
}
393402
return
394403
}
@@ -442,7 +451,7 @@ function processReplace(cache, path, prop_name) {
442451
return true
443452
}
444453
if (type === 'value') {
445-
safeReplace(path, value)
454+
path.replaceWith(value)
446455
return true
447456
}
448457
return false
@@ -522,7 +531,10 @@ function tryStackReplace(path, len, invalid) {
522531
}
523532

524533
function getStackParamLen(path) {
525-
const stk_name = path.node.params[0].argument.name
534+
const stk_name = path.node.params?.[0]?.argument?.name
535+
if (!stk_name) {
536+
return 'unknown'
537+
}
526538
const body_path = path.get('body')
527539
let len = 'unknown'
528540
body_path.traverse({
@@ -1712,6 +1724,8 @@ module.exports = function (code) {
17121724
traverse(ast, deStringConcealingPlace)
17131725
// StringSplitting
17141726
traverse(ast, calculateConstantExp)
1727+
// Stack (run again)
1728+
traverse(ast, deStackFuncOther)
17151729
// OpaquePredicates
17161730
traverse(ast, deOpaquePredicates)
17171731
traverse(ast, calculateConstantExp)

0 commit comments

Comments
 (0)