forked from HumanSecurity/obfuscation-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayReplacements.js
More file actions
31 lines (26 loc) · 946 Bytes
/
arrayReplacements.js
File metadata and controls
31 lines (26 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import {arrayHasMinimumRequiredReferences, findArrayDeclarationCandidates} from './sharedDetectionMethods.js';
const name = 'array_replacements';
/**
* Detects the Array Replacements obfuscation type.
*
* Characteristics:
* - An array (A) with many strings is defined.
* - There are many member expression references where the object is array A.
*
* @param {ASTNode[]} flatTree - The flattened AST of the code.
* @returns {string} The obfuscation name if detected; otherwise, an empty string.
*/
function detectArrayReplacements(flatTree) {
const candidates = findArrayDeclarationCandidates(flatTree);
const isFound = candidates.some(c => {
const refs = c.id.references.map(n => n.parentNode);
return arrayHasMinimumRequiredReferences(refs, c.id.name, flatTree);
});
return isFound;
}
const detector = {
name,
prioritizeOver: [],
detect: detectArrayReplacements,
};
export {detector, detectArrayReplacements};