Obfuscation Detectors

May 19, 2025 ยท View on GitHub

Overview

This directory contains all the detection logic for identifying different types of JavaScript obfuscation. Each detector is a self-contained module that analyzes the AST (Abstract Syntax Tree) of JavaScript code for patterns characteristic of a specific obfuscation technique.

Detectors are modular and easy to extend.


List of Detectors

Detector NameWhat It DetectsImplementation File
Array ReplacementsLarge arrays of strings used as lookup tablesarrayReplacements.js
Augmented Array ReplacementsArray replacements with IIFE wrappersaugmentedArrayReplacements.js
Array Function ReplacementsFunctions that return values from obfuscated arraysarrayFunctionReplacements.js
Augmented Array Function ReplacementsArray function replacements with IIFE wrappersaugmentedArrayFunctionReplacements.js
Augmented Proxied Array Function ReplacementsObfuscation using proxies and function arraysaugmentedProxiedArrayFunctionReplacements.js
Function To Array ReplacementsVariables assigned to function calls, used as objectsfunctionToArrayReplacements.js
Obfuscator.ioPatterns from the obfuscator.io toolobfuscator-io.js
Caesar PlusCaesar cipher-like obfuscation with 3-letter IDscaesarp.js

Detector Details

Array Replacements

  • File: arrayReplacements.js
  • Description: Detects large arrays of strings used as lookup tables for obfuscated code.

Augmented Array Replacements

  • File: augmentedArrayReplacements.js
  • Description: Like array replacements, but the array is passed to an IIFE (Immediately Invoked Function Expression).

Array Function Replacements

  • File: arrayFunctionReplacements.js
  • Description: Detects functions that return values from an obfuscated array, often used to hide string literals.

Augmented Array Function Replacements

Augmented Proxied Array Function Replacements

Function To Array Replacements

Obfuscator.io

  • File: obfuscator-io.js
  • Description: Detects patterns generated by the obfuscator.io tool, including debug protection and trap functions.
  • Example: See the detailed explanation and code sample below.

Caesar Plus

  • File: caesarp.js
  • Description: Detects Caesar cipher-like obfuscation, typically with 3-letter function names and specific identifier usage.

How to Add a New Detector

  1. Create a new file in this directory, e.g., myNewDetector.js.
  2. Export a function named detectMyNewDetector that takes the AST (flatTree) as input and returns the obfuscation name (or '' if not detected).
  3. Add your detector to index.js using export * from './myNewDetector.js';.
  4. Document your detector in this README (add a row to the table above and a short description).
  5. Add tests in the tests/ directory to ensure your detector works as expected.

References & Further Reading


For questions or contributions, see the main README and CONTRIBUTING.md.