Skip to content

Commit

Permalink
fix: keep unreferenced arrays (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Sep 30, 2024
1 parent 10651d3 commit 4ecd7e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/webcrack/src/deobfuscate/string-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export function findStringArray(ast: t.Node): StringArray | undefined {
m.fromCapture(arrayIdentifier),
m.numericLiteral(m.matcher((value) => value < length)),
);
if (!isReadonlyObject(binding, memberAccess)) return;
if (!binding.referenced || !isReadonlyObject(binding, memberAccess))
return;

inlineArrayElements(arrayExpression.current!, binding.referencePaths);
path.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ console[arr2[0]](arr2[1]);

const arr3 = ["requ", "m", "0x2649a392", "ire", "8", "v"];
const vm = eval(arr3[0] + arr3[3] + "(\"" + arr3[5] + "" + arr3[1] + "\")");
const v8 = eval(arr3[0] + arr3[3] + "(\"" + arr3[5] + "" + arr3[4] + "\")");
const v8 = eval(arr3[0] + arr3[3] + "(\"" + arr3[5] + "" + arr3[4] + "\")");

// ignore unreferenced array
const arr4 = ['log', 'Hello, World!'];
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ const arr2 = ["log", "Hello, World!"];
arr2[0] = "warn";
console[arr2[0]](arr2[1]);
const vm = eval("require(\"vm\")");
const v8 = eval("require(\"v8\")");
const v8 = eval("require(\"v8\")");

// ignore unreferenced array
const arr4 = ["log", "Hello, World!"];

0 comments on commit 4ecd7e9

Please sign in to comment.