-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(training): add encoding scripts
- Loading branch information
Showing
8 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const je = require('jencrypt') | ||
const category = 'jjencode' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: async (content) => { | ||
return je.encode(content) | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const jsconfuser = require('js-confuser') | ||
const category = 'jsconfuser-minified' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: (content) => { | ||
return jsconfuser.obfuscate(content, { target: 'node', deadCode: true, minify: true }) | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const jsconfuser = require('js-confuser') | ||
const category = 'jsconfuser' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: (content) => { | ||
return jsconfuser.obfuscate(content, { target: 'node', deadCode: true, minify: false, preset: 'high' }) | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const { JSFuck: { encode } } = require('jsfuck') | ||
const category = 'jsfuck' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: async (content) => { | ||
return encode(content) | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const { obfuscate } = require('javascript-obfuscator') | ||
const category = 'obfuscate' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: async (content) => { | ||
return obfuscate(content).getObfuscatedCode() | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const sake = require('sake-js') | ||
const category = 'sake' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: async (content) => { | ||
return sake.obfuscate(content, { random: true }) | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const { minify } = require('uglify-js') | ||
const category = 'uglify' | ||
|
||
const { encodeFilesInFolder } = require('./encoder.js') | ||
|
||
async function encodeFiles() { | ||
await encodeFilesInFolder({ | ||
category, callback: async (content) => { | ||
return minify(content, { compress: true }).code | ||
} | ||
}) | ||
} | ||
|
||
encodeFiles() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
|
||
const { readFile, writeFile, stat, readdir } = require('fs/promises') | ||
const path = require('path') | ||
|
||
const [, , baseFolder] = process.argv | ||
|
||
module.exports.encodeFilesInFolder = async function ({ category, callback }) { | ||
const input = `${baseFolder}/plain` | ||
try { | ||
const files = await readdir(input) | ||
|
||
for (const file of files) { | ||
const filePath = path.join(input, file) | ||
const stats = await stat(filePath) | ||
|
||
if (stats.isFile()) { | ||
const content = await readFile(filePath, 'utf-8') | ||
|
||
try { | ||
const encoded = await callback(content) | ||
const newPath = filePath.replace('plain', category) | ||
|
||
await writeFile(newPath, encoded, 'utf-8') | ||
console.log('File encoded:', filePath, '->', newPath) | ||
} catch (e) { | ||
|
||
} | ||
|
||
} | ||
} | ||
} catch (err) { | ||
console.error('Error reading directory:', err) | ||
} | ||
} |