question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crashed during function evaluate even though no execute directive used

See original GitHub issue
/project/dist/modifications/execution/functionExecutor.js:62
                    const directive = node.body.directives.find((d) => d.rawValue.startsWith('#execute'));
                                                           ^

TypeError: Cannot read properties of undefined (reading 'find')
    at Controller.enter (/project/dist/modifications/execution/functionExecutor.js:62:60)
    at Controller.__execute (/project/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/project/node_modules/estraverse/estraverse.js:501:28)
    at Object.traverse (/project/node_modules/estraverse/estraverse.js:713:27)
    at FunctionExecutor.findExecutedFunctions (/project/dist/modifications/execution/functionExecutor.js:59:27)
    at FunctionExecutor.execute (/project/dist/modifications/execution/functionExecutor.js:47:14)
    at /project/dist/index.js:59:34
    at Array.forEach (<anonymous>)
    at Object.deobfuscate (/project/dist/index.js:59:19)
    at Object.<anonymous> (/project/dist/run.js:27:24)

Sample formatted with esprima

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ben-sbcommented, Jan 10, 2022

It is fixed!

Is it possible to inline certain usage? For example, Input

const _0x38a2db = ['\x54\x6f\x74a\x6c', '\x6c\x6f\x67', '\x3a\x20'];
const _0x9b58d9 = function(_0x39ddb7) {
	return _0x38a2db[_0x39ddb7 + (-0x6d5 + 0x58 + 0x11 * 0x62)];
}, _0x498b9b = function(_0x48d808, _0x14da1e) {
    return _0x9b58d9(_0x48d808);
}, _0x34c7bc = function(_0x16af1d, _0x27a29e) {
    return _0x498b9b(_0x16af1d);
}
let total = 0x2 * 0x109e + -0xc * -0x16a + -0x3234;
for (let i = 0x1196 + 0x97b * 0x3 + -0x2e07; i < -0x95 * -0x38 + -0x1a75 + -0x619; i++) {
	total += i;
}
let decrypt = _0x34c7bc;
console[decrypt(-(0x1e7c + -0x1 * -0x1367 + 0x2ef * -0x11))](decrypt(-(0x1020 + 0x253 + 0x7 * -0x2a2)) + decrypt(-(0x12c5 + -0x1887 + -0x1 * -0x5c5)) + total);

Expected

let total = 0;
for (let i = 0; i < 10; i++) {
  total += i;
}
console.log("Total: " + total);

Actual

const jeiden = ["Total", "log", ": "];
let total = 0;
for (let i = 0; i < 10; i++) {
  total += i;
}
let decrypt = _0x34c7bc;
console[decrypt(-4)](decrypt(-5) + decrypt(-3) + total);

I’m currently using willnode/deobfuscator’s RegEx solution to manually inline them - not perfect but works!

I’ve added support for proxy function reassignments in https://github.com/ben-sb/javascript-deobfuscator/commit/bd7564db5d87e07bd39d5974cfe4f5f6c3e621b6

1reaction
ben-sbcommented, Jan 10, 2022

Thanks for letting me know, the problem was actually with the shift-spec module not being up to date, I employed a hacky solution to force estraverse to use the up to date spec in https://github.com/ben-sb/javascript-deobfuscator/commit/e8daa25756f3582f38785d1effdf2845038f8c65

Most of my projects nowadays use babel as the AST rather than Shift as it’s more actively developed, at some point I rewrite this repo to use babel to avoid something like this happening again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Program only crashes as release build -- how to debug?
In debug mode the code in the if is not executed but in release mode p contains an undefined value, which is unlikely...
Read more >
Directive Link, $observe, And $watch Functions Execute ...
The link functions. The attribute $observe() handlers. The $scope $watch() handlers. If you make changes to the $scope inside the synchronous ...
Read more >
The System is Crashing - Oracle Help Center
The System is Crashing. A Java application may stop running for several reasons. The most common reason is of course that the application...
Read more >
My program crashed. How do I find out why?
There's no easy answer to that. Here's what I do, though, when faced with a crash that I just don't understand: Look at...
Read more >
Modern C++ best practices for exceptions and error handling
And the Win32 API has the GetLastError function to retrieve the last error that was reported by the call stack. In both of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found