Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Dec 27, 2019
0 parents commit 22248c6
Show file tree
Hide file tree
Showing 19 changed files with 1,146 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/.idea
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# JavaScript Obfuscate

Demo of JavaScript Obfuscate.
17 changes: 17 additions & 0 deletions demo_compact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const code = `
let x = '1' + 1
console.log('x', x)
`

const options = {
compact: false,
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
// var _0x151c=['log'];(function(_0x1ce384,_0x20a7c7){var _0x25fc92=function(_0x188aec){while(--_0x188aec){_0x1ce384['push'](_0x1ce384['shift']());}};_0x25fc92(++_0x20a7c7);}(_0x151c,0x1b7));var _0x553e=function(_0x259219,_0x241445){_0x259219=_0x259219-0x0;var _0x56d72d=_0x151c[_0x259219];return _0x56d72d;};let x='1'+0x1;console[_0x553e('0x0')]('x',x);
30 changes: 30 additions & 0 deletions demo_control_flow_flattening.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const code = `
(function(){
function foo () {
return function () {
var sum = 1 + 2;
console.log(1);
console.log(2);
console.log(3);
console.log(4);
console.log(5);
console.log(6);
}
}
foo()();
})();
`

const options = {
compact: false,
controlFlowFlattening: false
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
20 changes: 20 additions & 0 deletions demo_dead_code_injection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const code = `
console.log('abc');
console.log('cde');
console.log('efg');
console.log('hij');
`

const options = {
compact: false,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
17 changes: 17 additions & 0 deletions demo_debug_protection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const code = `
for (let i = 0; i < 5; i ++) {
console.log('i', i)
}
`

const options = {
debugProtection: true
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
14 changes: 14 additions & 0 deletions demo_disable_console_output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const code = `
console.log('hello world')
`
const options = {
disableConsoleOutput: true
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
15 changes: 15 additions & 0 deletions demo_domain_lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const code = `
console.log('hello world')
`

const options = {
domainLock: ['cuiqingcai.com']
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
17 changes: 17 additions & 0 deletions demo_identifier_names_generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const code = `
let hello = '1' + 1
console.log('hello', hello)
`

const options = {
compact: true,
identifierNamesGenerator: 'mangled'
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
16 changes: 16 additions & 0 deletions demo_identifiers_prefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const code = `
let hello = '1' + 1
console.log('hello', hello)
`

const options = {
identifiersPrefix: 'germey'
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
17 changes: 17 additions & 0 deletions demo_rename_globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const code = `
var $ = function(id) {
return document.getElementById(id);
};
`

const options = {
renameGlobals: true
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
15 changes: 15 additions & 0 deletions demo_self_defending.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const code = `
console.log('hello world')
`

const options = {
selfDefending: true
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
17 changes: 17 additions & 0 deletions demo_string_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const code = `
var a = 'hello world'
`
const options = {
stringArray: false,
rotateStringArray: true,
stringArrayEncoding: true, // 'base64' or 'rc4' or false
stringArrayThreshold: 1,
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
15 changes: 15 additions & 0 deletions demo_target.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const code = `
console.log('hello world')
`

const options = {
target: 'browser-no-eval'
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
22 changes: 22 additions & 0 deletions demo_transform_object_keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const code = `
(function(){
var object = {
foo: 'test1',
bar: {
baz: 'test2'
}
};
})();
`
const options = {
compact: false,
transformObjectKeys: true
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
15 changes: 15 additions & 0 deletions demo_unicode_escape_sequence.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const code = `
var a = 'hello world'
`
const options = {
compact: false,
unicodeEscapeSequence: true
}

const obfuscator = require('javascript-obfuscator')

function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}

console.log(obfuscate(code, options))
15 changes: 15 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const code = `
let x = '1' + 1
console.log('x', x)
`

const options = {
compact: false,
controlFlowFlattening: true
}

const obfuscator = require('javascript-obfuscator')
function obfuscate(code, options) {
return obfuscator.obfuscate(code, options).getObfuscatedCode()
}
console.log(obfuscate(code, options))
Loading

0 comments on commit 22248c6

Please sign in to comment.