-
Notifications
You must be signed in to change notification settings - Fork 85
/
cli.js
executable file
·48 lines (41 loc) · 1.12 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node --harmony --harmony_arrow_functions
'use strict';
var fs = require('fs');
var deobfuscator = require('./lib/deobfuscator');
// run as a command line tool
//
// Usage:
// node deobfuscator.js input [output]
//
if (typeof process !== 'undefined') {
let argv = process.argv;
if ([3, 4].indexOf(argv.length) > -1) {
let src = argv[2];
let dst = argv[3];
fs.readFile(src, function(err, content) {
if (err) {
throw err;
}
var code = deobfuscator.clean(content.toString('utf8'));
if (dst) {
fs.writeFile(dst, code);
} else {
console.log(code);
}
});
} else if (argv.length === 2) {
process.stdin.setEncoding('utf8');
process.stdin.on('readable', function() {
var chunk = process.stdin.read();
if (chunk && chunk.length) {
try {
console.log('----'.repeat(20));
console.log(deobfuscator.clean(chunk));
} catch (ex) {
console.log(`Error: ${ex.description} at line ${ex.lineNumber}, col ${ex.column}`);
}
}
process.stdout.write('etacsufbo > ');
});
}
}