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.4.tar.gz (104.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.4-py3-none-any.whl (119.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyjsclear-0.1.4.tar.gz
  • Upload date:
  • Size: 104.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.4.tar.gz
Algorithm Hash digest
SHA256 673a711a9a729f3086a9e7b54a6f99f6837a4c7e9403356dbe321318a47c565b
MD5 a604606d7fe4dab1a865a4c1204968cb
BLAKE2b-256 86ab1e29f8dca6e05186176a2b4a617452691a6ff25c14c87606b49a76559e39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyjsclear-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 119.9 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bbc5a4f6a3ae622c7e9fc5585ea8e778b76fcbf278b1fb5518202d03f10c9fea
MD5 c27a3ff41ace618d55c299f27de113c1
BLAKE2b-256 bba52f77b60eb6ea0042ecb542d524bce88a51929fca964409899be598e6fcfe

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