PerimeterX / restringer

A Javascript Deobfuscator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance Issue with resolveFunctionToArray when Dealing with Large Arrays

lanvent opened this issue · comments

Description:

When deobfuscating code that contains large array initializations (e.g., var item=Array(200000);), the library becomes unresponsive for an extended period of time. The resolveFunctionToArray function tries to expand the array to its full size, bloating the AST and causing performance issues.

Reproduce:

  1. Obfuscate the following code snippet using Obfuscator.io with the "Low" preset:
var item=Array(200000);
function hi() {
  item[2]=3;
  console.log("Hello World!");
}
  1. Attempt to deobfuscate the resulting code.

Possible Solutions:

  1. Implement a filter to skip array initializations over a certain size (e.g., 10,000 elements). If size field is a binary expression, need to evaluate to determine if it should be skipped.
  2. Add a timeout feature to resolveFunctionToArray.
  3. Limit the maximum size of an array that can be expanded in the AST.

I am not certain which approach is best, and would appreciate input from more experienced contributors like you.
Thanks again for developing such an excellent tool. Looking forward to future improvements.