Skip to main content

Pure Python JavaScript deobfuscator

Project description

PyJSClear

PyJSClear

Pure Python JavaScript deobfuscator.

Installation

pip install pyjsclear

For development:

git clone https://github.com/intezer/PyJSClear.git
cd PyJSClear
pip install -e .
pip install pytest

Usage

Python API

from pyjsclear import deobfuscate, deobfuscate_file

# From a string
cleaned = deobfuscate(obfuscated_code)

# From a file
deobfuscate_file("input.js", "output.js")

# Or get the result as a string
cleaned = deobfuscate_file("input.js")

Command line

# File to stdout
pyjsclear input.js

# File to file
pyjsclear input.js -o output.js

# Stdin to stdout
cat input.js | pyjsclear -

# With custom iteration limit
pyjsclear input.js --max-iterations 20

What it does

PyJSClear applies transforms in a multi-pass loop until the code stabilizes (default limit: 50 iterations). A final one-shot pass renames variables and converts var/let to const.

Capabilities:

  • Whole-file encoding detection: JSFuck, JJEncode, AAEncode, eval-packing
  • String array decoding (obfuscator.io basic/base64/RC4, XOR, class-based)
  • Constant propagation & reassignment elimination
  • Dead code / dead branch / unreachable code removal
  • Control-flow unflattening (switch-dispatch recovery)
  • Proxy function & proxy object inlining
  • Expression simplification & modern syntax recovery (?., ??)
  • Anti-tamper / anti-debug removal
  • Variable renaming (_0x… → readable names)

Large files (>500 KB / >50 K AST nodes) automatically use a lite mode that skips expensive transforms.

Limitations

  • Best results on obfuscator.io output. JSFuck, JJEncode, AAEncode, and eval-packed code are fully decoded; other obfuscation tools may only partially deobfuscate.
  • Large files get reduced treatment. Files >500 KB or ASTs >50 K nodes skip expensive transforms; files >2 MB use a minimal lite mode.
  • Recursive AST traversal may hit Python's default recursion limit (~1 000 frames) on extremely deep nesting; the deobfuscator catches this and returns the best partial result.

License

Apache License 2.0 — see LICENSE.

This project is a derivative work based on obfuscator-io-deobfuscator (Apache 2.0), javascript-deobfuscator (Apache 2.0), and webcrack (MIT). See THIRD_PARTY_LICENSES.md and NOTICE for full attribution.

Test samples include obfuscated JavaScript from the JSIMPLIFIER dataset (GPL-3.0), used solely for evaluation purposes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjsclear-0.1.3.tar.gz (98.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjsclear-0.1.3-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

Details for the file pyjsclear-0.1.3.tar.gz.

File metadata

  • Download URL: pyjsclear-0.1.3.tar.gz
  • Upload date:
  • Size: 98.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyjsclear-0.1.3.tar.gz
Algorithm Hash digest
SHA256 aa8ba1f6aa61e4d80f8e6122aba3c25771ca8b778819ffcbc86ef0737612965f
MD5 15bc160778b143d431c776ff5da6be0e
BLAKE2b-256 48be169f55cbbb03271188202311764ac972c98618b705a446e4b22218845cb3

See more details on using hashes here.

File details

Details for the file pyjsclear-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyjsclear-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 113.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyjsclear-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 415bbe13d419f678c6ea5fac91b4deb16f9918f27cb5b7423a887de484a55c07
MD5 834201d6e94a6a466b055ba52067cafd
BLAKE2b-256 41e633afead9065797a11c6badaa07fa16cccb091acec96b7b1fcd9198498264

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page