Skip to content

Commit

Permalink
Improve augmented array coverage (#65)
Browse files Browse the repository at this point in the history
* Update dependencies

* Improve coverage for target nodes contained within a sequence expression

* Fix issue with target node not being wrapped correctly for evaluation

* 1.6.2
  • Loading branch information
ctrl-escp authored Jan 8, 2023
1 parent f7e8df8 commit 5b9f781
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "restringer",
"version": "1.6.1",
"version": "1.6.2",
"description": "Deobfuscate Javascript with emphasis on reconstructing strings",
"main": "index.js",
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions src/processors/augmentedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function replaceArrayWithStaticAugmentedVersion(arb) {

for (const c of candidates) {
let targetNode = c;
while (targetNode && targetNode.type !== 'ExpressionStatement') {
while (targetNode && (targetNode.type !== 'ExpressionStatement' && targetNode.parentNode.type !== 'SequenceExpression')) {
targetNode = targetNode?.parentNode;
}
const relevantArrayIdentifier = c.arguments.find(n => n.type === 'Identifier');
Expand All @@ -54,7 +54,7 @@ function replaceArrayWithStaticAugmentedVersion(arb) {
const contextNodes = getDeclarationWithContext(c, true);
const context = `${contextNodes.length ? createOrderedSrc(contextNodes) : ''}`;
// By adding the name of the array after the context, the un-shuffled array is procured.
const src = `${context};\n${targetNode.src}\n${ref};`;
const src = `${context};\n${createOrderedSrc([targetNode])}\n${ref};`;
const newNode = evalInVm(src); // The new node will hold the un-shuffled array's assignment
if (newNode !== badValue) {
arb.markNode(targetNode || c);
Expand Down

0 comments on commit 5b9f781

Please sign in to comment.