Skip to content

SSZcreate/Pentab_server / .agents/skills/cybersecurity/skills/deobfuscating-javascript-malware

deobfuscating-javascript-malware

Unverified

Deobfuscates malicious JavaScript found in phishing pages, web skimmers, and dropper scripts by reversing encoding layers, eval chains, string manipulation, and control-flow obfuscation to reveal the original malicious logic. Use when investigating a phishing page's obfuscated JavaScript, analyzing a Magecart-style web skimmer, or deobfuscating a JavaScript dropper that fetches second-stage malware.

FileKindSize
LICENSEother11.0 KB
SKILL.mdskill md12.8 KB
references/api-reference.mdmarkdown2.0 KB
scripts/agent.pyscript7.1 KB

references/api-reference.md

View on GitHub
# JavaScript Malware Deobfuscation API Reference

## jsbeautifier (Python)

```python
import jsbeautifier

opts = jsbeautifier.default_options()
opts.indent_size = 2
opts.wrap_line_length = 120

result = jsbeautifier.beautify(obfuscated_code, opts)
```

## jsbeautifier CLI

```bash
# Beautify a file
js-beautify malicious.js -o output.js

# npx alternative
npx js-beautify script.js -o script_pretty.js
```

## Common Decoding Patterns (Python)

```python
import re, base64, urllib.parse

# Hex strings: \x68\x65\x6c\x6c\x6f -> hello
decoded = bytes.fromhex("68656c6c6f").decode("ascii")

# Unicode escapes: \u0068\u0065 -> he
decoded = chr(0x0068) + chr(0x0065)

# Base64 (atob equivalent)
decoded = base64.b64decode("aGVsbG8=").decode("utf-8")

# URL encoding (unescape equivalent)
decoded = urllib.parse.unquote("%68%65%6c%6c%6f")

# String.fromCharCode
decoded = "".join(chr(c) for c in [104, 101, 108, 108, 111])
```

## Node.js VM Sandbox

```javascript
const vm = require('vm');
const sandbox = {
    eval: function(code) {
        console.log("EVAL INTERCEPTED:", code.substring(0, 500));
        return code;
    },
    document: { write: function(h) { console.log("DOC.WRITE:", h); } },
    atob: function(s) { return Buffer.from(s, 'base64').toString(); },
    window: { location: { href: "" } },
};
const context = vm.createContext(sandbox);
vm.runInContext(code, context, { timeout: 5000 });
```

## CyberChef Operations

| Operation | Use Case |
|-----------|----------|
| From Hex | Decode `\xNN` sequences |
| From Base64 | Decode `atob()` payloads |
| URL Decode | Decode `unescape()` strings |
| JavaScript Beautify | Format minified code |
| From CharCode | Decode `fromCharCode` arrays |
| XOR | Decode XOR-encrypted strings |
| Generic Code Beautify | Format mixed content |

## IOC Extraction Regex

```python
# URLs
re.findall(r'https?://[^\s"\'<>)]+', code)

# IP addresses
re.findall(r'\b(?:\d{1,3}\.){3}\d{1,3}\b', code)

# Domains
re.findall(r'(?:[a-zA-Z0-9-]+\.)+(?:com|net|org|io|xyz)\b', code)
```
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 192kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 192kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 192kUpdated Claude CodeCodexVerifiedInstall