Module refinery.units.scripting.js
Expand source code Browse git
from __future__ import annotations
from refinery.lib.scripts.js.deobfuscation import deobfuscate
from refinery.lib.scripts.js.model import JsScript
from refinery.lib.scripts.js.parser import JsParser
from refinery.lib.scripts.js.synth import JsSynthesizer
from refinery.units.scripting import IterativeDeobfuscator
class js(IterativeDeobfuscator):
"""
AST-based JavaScript deobfuscator and pretty-printer.
Parses the script into an abstract syntax tree, applies simplifying transformations, and
synthesizes clean output.
"""
def parse(self, data: str) -> JsScript:
return JsParser(data).parse()
transform = staticmethod(deobfuscate)
def synthesize(self, ast: JsScript) -> str:
return JsSynthesizer().convert(ast)
Classes
class js (timeout=100)-
AST-based JavaScript deobfuscator and pretty-printer.
Parses the script into an abstract syntax tree, applies simplifying transformations, and synthesizes clean output.
Expand source code Browse git
class js(IterativeDeobfuscator): """ AST-based JavaScript deobfuscator and pretty-printer. Parses the script into an abstract syntax tree, applies simplifying transformations, and synthesizes clean output. """ def parse(self, data: str) -> JsScript: return JsParser(data).parse() transform = staticmethod(deobfuscate) def synthesize(self, ast: JsScript) -> str: return JsSynthesizer().convert(ast)Ancestors
Subclasses
Class variables
var reverse-
The type of the None singleton.
Static methods
def transform(ast)-
Apply all available deobfuscators to the input.
Expand source code Browse git
def deobfuscate(ast: JsScript) -> bool: """ Apply all available deobfuscators to the input. """ t = JsSimplifications() t.visit(ast) return t.changed
Methods
def parse(self, data)-
Expand source code Browse git
def parse(self, data: str) -> JsScript: return JsParser(data).parse() def synthesize(self, ast)-
Expand source code Browse git
def synthesize(self, ast: JsScript) -> str: return JsSynthesizer().convert(ast)
Inherited members