<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
---
name: performing-code-deobfuscation
description: >-
  Deobfuscate obfuscated code including JavaScript, Python, and compiled binary obfuscation to recover original logic and intent.
domain: cybersecurity
subdomain: reverse-engineering
tags:
  - deobfuscation
  - javascript
  - control-flow
  - string-encoding
  - opaque-predicates
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1140", "T1027"]
  cwe: ["CWE-506"]
  tools: ["de4dot", "js-beautify", "JStillery", "Ghidra", "miasm"]
---

# Performing Code Deobfuscation

## Overview

Deobfuscate obfuscated code including JavaScript, Python, and compiled binary obfuscation to recover original logic and intent.

## Prerequisites

| Tool / Requirement | Details |
|---|---|
| `de4dot` | Security tooling |
| `js-beautify` | Security tooling |
| `JStillery` | Security tooling |
| `Ghidra` | Security tooling |
| `miasm` | 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
# JavaScript deobfuscation
js-beautify obfuscated.js > beautified.js
node -e "var code = require('fs').readFileSync('obfuscated.js','utf8'); eval(code)"

# .NET deobfuscation with de4dot
de4dot obfuscated.exe -o cleaned.exe

# Python bytecode decompilation
uncompyle6 -o ./output target.pyc
pycdc target.pyc > decompiled.py
```

## Workflow

### Step 1: Preparation and Reconnaissance

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

# Set up working directory
mkdir -p /tmp/performing-code-deobfuscation/{output,logs,artifacts}
```

### Step 2: Primary Analysis

```bash
# Execute primary analysis with de4dot
# Refer to Quick Reference above for detailed commands
echo "[*] Running Performing Code Deobfuscation with de4dot..."

# Log all operations
script -q /tmp/performing-code-deobfuscation/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/performing-code-deobfuscation/output/primary.json /tmp/performing-code-deobfuscation/output/secondary.json
```

### Step 4: Documentation and Reporting

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

## Detection

```yaml
title: Code Deobfuscation Detection
id: 519d9970-aa5c-42ae-992a-c966e6d28ab4
status: experimental
description: Detects suspicious activity related to performing code deobfuscation techniques in reverse engineering context
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    CommandLine: "*performing*code*"
  condition: selection
level: medium
tags:
  - attack.t1140
  - attack.t1027
  - attack.defense_evasion
falsepositives:
  - Malware analysis sandbox performing automated binary inspection
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Code Deobfuscation Detection | windows/process_creation | Sigma rule (medium) |
| ATT&CK Coverage | MITRE ATT&CK | T1140, T1027 |

## 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 T1140](https://attack.mitre.org/techniques/T1140) — Related technique
- [de4dot Documentation](https://de4dot.org/) — Primary tooling
- [js-beautify Reference](https://js-beautify.org/) — Secondary tooling
