<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
---
name: analyzing-obfuscated-javascript
description: >-
  Deobfuscate and analyze obfuscated JavaScript code used in malware, web skimmers, and browser exploits.
domain: cybersecurity
subdomain: reverse-engineering
tags:
  - javascript
  - deobfuscation
  - web-malware
  - ast-analysis
  - browser-exploit
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1027.002"]
  cwe: ["CWE-506"]
  tools: ["babel", "js-beautify", "de4js", "node"]
---

# Analyzing Obfuscated Javascript

## Overview

Deobfuscate and analyze obfuscated JavaScript code used in malware, web skimmers, and browser exploits.

## Prerequisites

| Tool / Requirement | Details |
|---|---|
| `babel` | Security tooling |
| `js-beautify` | Security tooling |
| `de4js` | Security tooling |
| `node` | Security tooling |
| Isolated lab environment for testing | Environment requirement |
| Authorization and signed Rules of Engagement (RoE) | Environment requirement |
| Relevant target samples or systems acquired through authorized channels | Environment requirement |

## Quick Reference

```bash
# Initialize working environment
mkdir -p /tmp/analyzing-obfuscated-javascript/{output,logs,artifacts}

# Execute primary analysis with babel
echo "[*] Running Analyzing Obfuscated Javascript with babel..."

# Validate results with js-beautify
echo "[*] Cross-validating with js-beautify..."

# Generate summary report
cat /tmp/analyzing-obfuscated-javascript/output/report.json
```

## Workflow

### Step 1: Preparation and Reconnaissance

```bash
# Identify target and gather initial intelligence
file ./target_sample
babel --version 2>/dev/null || echo "Install babel"

# Set up working directory
mkdir -p /tmp/analyzing-obfuscated-javascript/{output,logs,artifacts}
```

### Step 2: Primary Analysis

```bash
# Execute primary analysis with babel
# Refer to Quick Reference above for detailed commands
echo "[*] Running Analyzing Obfuscated Javascript with babel..."

# Log all operations
script -q /tmp/analyzing-obfuscated-javascript/logs/session.log
```

### Step 3: Deep Investigation

```bash
# Apply js-beautify for secondary analysis
echo "[*] Deep investigation with js-beautify..."

# Cross-reference findings
diff /tmp/analyzing-obfuscated-javascript/output/primary.json /tmp/analyzing-obfuscated-javascript/output/secondary.json
```

### Step 4: Documentation and Reporting

```bash
# Generate structured findings report
cat <<'EOF' > /tmp/analyzing-obfuscated-javascript/output/report.json
{
  "technique": "analyzing-obfuscated-javascript",
  "domain": "reverse-engineering",
  "tools_used": ["babel", "js-beautify"],
  "findings": [],
  "recommendations": []
}
EOF
```

## Detection

```yaml
title: Obfuscated Javascript Detection
id: 8a3c5bff-6a2f-4bac-8227-f92f1dfea10d
status: experimental
description: Detects suspicious activity related to analyzing obfuscated javascript techniques in reverse engineering context
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    CommandLine: "*analyzing*obfuscated*"
  condition: selection
level: medium
tags:
  - attack.t1027.002
  - attack.defense_evasion
falsepositives:
  - Malware analysis sandbox performing automated binary inspection
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Obfuscated Javascript Detection | windows/process_creation | Sigma rule (medium) |
| ATT&CK Coverage | MITRE ATT&CK | T1027.002 |

## Verification

- [ ] Environment and tools verified and operational
- [ ] Target samples acquired through authorized channels
- [ ] Primary analysis completed with findings documented
- [ ] Secondary validation performed with independent tooling
- [ ] All artifacts preserved in structured output directory
- [ ] Detection opportunities documented for blue team

## References

- [MITRE ATT&CK T1027.002](https://attack.mitre.org/techniques/T1027/002) — Related technique
- [babel Documentation](https://babel.org/) — Primary tooling
- [js-beautify Reference](https://js-beautify.org/) — Secondary tooling
