Skip to content

Instantly share code, notes, and snippets.

@idiom
Last active November 8, 2016 22:06
Show Gist options
  • Save idiom/797303690aab3a8787e07e85865288bb to your computer and use it in GitHub Desktop.
Save idiom/797303690aab3a8787e07e85865288bb to your computer and use it in GitHub Desktop.
Setup Gulp for Quick and Dirty JS Beautification and Validation

Quick and Dirty Local JS Beautifying and validation

From 0 to hero in 60 seconds!

I often run into unknown samples which I need to quickly deobfuscate.
Scripts can often be malfomred (who has time for QA) and not play nicely during a quick dynamic analysis. 

The following instructions are for setting up a local environment that will beautify and validate 
JS files. 

!!! USE AT YOUR OWN RISK !!!

Setup Instructions

  1. Install NPM
  2. Install gulp-cli (npm install --global gulp-cli) https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md
  3. Create directory for project
  4. Copy package.json into directory
  5. Copy gulpfile.js into directory
  6. Run 'npm install'
  7. Create directories ./in/ and ./out/

Running

  • Place javascript files in ./in/
  • Run 'gulp'

Beautified files will be copied to ./out/ Any JS errors and/or warning will be displayed on screen.

var jshint = require('gulp-jshint');
var gulp = require('gulp');
var beautify = require('gulp-beautify');
var stylish = require('jshint-stylish');
gulp.task('beautify', function() {
return gulp.src('./in/*.js')
.pipe(beautify({indenSize: 2}))
.pipe(gulp.dest('./out/'));
});
// JSHint task
gulp.task('jshint',['beautify'],function() {
return gulp.src('./out/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('default',['jshint','beautify'], function() {
// run tasks
});
{
"name": "qsd",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-beautify": "^2.0.0",
"gulp-jshint": "^2.0.2",
"jshint": "^2.9.4",
"jshint-stylish": "^2.2.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment