GithubHelp home page GithubHelp logo

ykankaya / unminify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shapesecurity/unminify

0.0 2.0 0.0 42 KB

reverse many of the transformations applied by minifiers and naïve obfuscators

License: Apache License 2.0

JavaScript 100.00%

unminify's Introduction

Unminify

A little project to undo several of the horrible things JavaScript build tools will do to JavaScript. In addition to undoing most minification, it reverses some of the stupider but surprisingly common "obfuscation" techniques used in the wild.

It may amuse you to try it on, say, this random bit of JavaScript I found.

Installation

npm install -g unminify

or use it without installing via npx (available since npm 5.2.0)

npx unminify [...args]

CLI Usage

unminify /path/to/file.js
  • --safety may be given to enable/disable transformations based on the user's required safety guarantees. Refer to the safety levels documentation for more details. The value of --safety may be one of
    • useless
    • safe (default)
    • mostly-safe
    • unsafe
    • wildly-unsafe
  • --additional-transform may be given zero or more times, each followed by a path to a module providing an AST transform; the function signals that the transformation was not applied by returning its input

API Usage

let unminify = require('unminify');
let sourceText = '/* a minified/"obfuscated" JavaScript program */';
console.log(unminify(sourceText));

// or, with options
console.log(unminify(sourceText, {
  safety: unminify.safetyLevels.UNSAFE,
  additionalTransforms: [function(ast) { /* ... */ }],
}));

Safety Levels

  • "safe to the point of uselessness":
    • safe for ALL programs ("programs" don't have early errors)
  • "safe": "safe to the point of uselessness" except
    • Function.prototype.toString
    • function name/arity
    • Annex B
    • direct eval
  • "mostly safe": "safe" except
    • side effecting getters/setters on the global object
    • sealed global object
    • non-writable/non-configurable properties on the global object
    • top-level var decls make global properties
  • "unsafe": "mostly safe" except
    • non-spec built-in global properties or native proto properties
  • "wildly unsafe":
    • no guarantees but it'll probably work most of the time

License

Copyright 2017 Shape Security, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

unminify's People

Contributors

bakkot avatar michaelficarra avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.