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) and the Obfuscated JavaScript Dataset, 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.5.tar.gz (113.2 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.5-py3-none-any.whl (129.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyjsclear-0.1.5.tar.gz
  • Upload date:
  • Size: 113.2 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.5.tar.gz
Algorithm Hash digest
SHA256 63cbe47a49c29a10fd58e3f20ead1aa82814953cc4a0c8ef046828bfdab34f77
MD5 c00eeaad57aa1f9d43f494ff8a920f5b
BLAKE2b-256 c04d6a02abbe7365a4fdf0878b550148827c956bd4649adc2a688d807d2994a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyjsclear-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 129.3 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 faca1f158b7120c2cfa4a72d8887553ee63bc82c94c67081e859f89f9886c1d5
MD5 8690deb04a7ccc2acd6eb035423035fd
BLAKE2b-256 d4ec0221b1599ec956cb75a0644e880a8d91f5399777f740343e8ba8e780ae28

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