-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for augmented proxied array function replacements (#3)
* Add detector for augmented proxied array function replacements * Add sample for testing * Refactor imports do be dynamic with less repetition; Add new augmentedProxiedArrayFunctionReplacements detector; * Update dependencies * 1.1.0
- Loading branch information
1 parent
86f8401
commit addaf18
Showing
5 changed files
with
12,034 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/detectors/augmentedProxiedArrayFunctionReplacements.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const obfuscationName = 'augmented_proxied_array_function_replacements'; | ||
|
||
/** | ||
* Augmented Proxied Array-Function Replacements obfuscation type has the following characteristics: | ||
* - Has at least 3 root nodes - the last one containing the actual obfuscated code and the rest are obfuscation code. | ||
* - Has a function that assigns an array full of strings to itself, and then returns itself. | ||
* - Has an anonymous IIFE that is called with the array function as one of its arguments. | ||
* @param {ASTNode[]} flatTree | ||
* @return {string} The obfuscation name if detected; empty string otherwise. | ||
*/ | ||
function detectAugmentedProxiedArrayFunctionReplacements(flatTree) { | ||
const roots = flatTree.filter(n => n.parentNode?.type === 'Program'); | ||
if (roots.length > 3) { | ||
const arrFunc = roots.find(n => n.type === 'FunctionDeclaration' && | ||
n.body?.body?.length && | ||
n.body.body.slice(-1)[0]?.argument?.callee?.name === n?.id?.name); | ||
if (arrFunc) { | ||
const augFunc = roots.find(n => n.type === 'ExpressionStatement' && | ||
n.expression.type === 'CallExpression' && | ||
n.expression.arguments.find(a => a?.name === arrFunc.id.name)); | ||
if (augFunc) { | ||
return obfuscationName; | ||
} | ||
} | ||
} | ||
return ''; | ||
} | ||
|
||
try { | ||
module.exports = detectAugmentedProxiedArrayFunctionReplacements; | ||
} catch {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.