Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change Log

v2.15.5
---
* Improved `stringArray` calls wrapper decode code

v2.15.4
---
* Improved `stringArray` calls wrapper code
Expand Down
2 changes: 1 addition & 1 deletion dist/index.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.cli.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "2.15.4",
"version": "2.15.5",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@types/mkdirp": "1.0.1",
"@types/mocha": "8.2.2",
"@types/multimatch": "4.0.0",
"@types/node": "15.12.2",
"@types/node": "15.12.3",
"@types/rimraf": "3.0.0",
"@types/sinon": "10.0.2",
"@types/string-template": "1.0.2",
Expand All @@ -75,7 +75,7 @@
"eslint-plugin-unicorn": "33.0.1",
"fork-ts-checker-notifier-webpack-plugin": "4.0.0",
"fork-ts-checker-webpack-plugin": "6.2.10",
"mocha": "9.0.0",
"mocha": "9.0.1",
"nyc": "15.1.0",
"pjson": "1.0.9",
"pre-commit": "1.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export function AtobTemplate (): string {
const chars = '${base64alphabetSwapped}';

let output = '';
let tempEncodedString = '';

for (
let bc = 0, bs, buffer, idx = 0;
buffer = input.charAt(idx++);
Expand All @@ -19,7 +21,12 @@ export function AtobTemplate (): string {
) {
buffer = chars.indexOf(buffer);
}
return output;

for (let k = 0, length = output.length; k < length; k++) {
tempEncodedString += '%' + ('00' + output.charCodeAt(k).toString(16)).slice(-2);
}

return decodeURIComponent(tempEncodedString);
};
`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
export function Rc4Template (): string {
return `
const {rc4FunctionName} = function (str, key) {
let s = [], j = 0, x, res = '', newStr = '';
let s = [], j = 0, x, output = '';

str = {atobFunctionName}(str);

for (let k = 0, length = str.length; k < length; k++) {
newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);
}

str = decodeURIComponent(newStr);

let i;

for (i = 0; i < 256; i++) {
Expand All @@ -36,10 +30,10 @@ export function Rc4Template (): string {
x = s[i];
s[i] = s[j];
s[j] = x;
res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
output += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
}

return res;
return output;
}
`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@ export function StringArrayBase64DecodeTemplate (
): string {
const identifierLength: number = 6;
const initializedIdentifier: string = randomGenerator.getRandomString(identifierLength);
const base64DecodeFunctionIdentifier: string = randomGenerator.getRandomString(identifierLength);
const base64Identifier: string = randomGenerator.getRandomString(identifierLength);

return `
if ({stringArrayCallsWrapperName}.${initializedIdentifier} === undefined) {
{atobPolyfill}

{stringArrayCallsWrapperName}.${base64DecodeFunctionIdentifier} = function (str) {
const string = {atobFunctionName}(str);
let newStringChars = [];

for (let i = 0, length = string.length; i < length; i++) {
newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);
}

return decodeURIComponent(newStringChars);
};

{stringArrayCallsWrapperName}.${base64Identifier} = {atobFunctionName};

{stringArrayCacheName} = arguments;

{stringArrayCallsWrapperName}.${initializedIdentifier} = true;
Expand All @@ -39,7 +29,7 @@ export function StringArrayBase64DecodeTemplate (
if (!cachedValue) {
{selfDefendingCode}

value = {stringArrayCallsWrapperName}.${base64DecodeFunctionIdentifier}(value);
value = {stringArrayCallsWrapperName}.${base64Identifier}(value);
{stringArrayCacheName}[cacheKey] = value;
} else {
value = cachedValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function StringArrayRC4DecodeTemplate (
return `
if ({stringArrayCallsWrapperName}.${initializedIdentifier} === undefined) {
{atobPolyfill}

{rc4Polyfill}
{stringArrayCallsWrapperName}.${rc4Identifier} = {rc4FunctionName};

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -693,10 +693,10 @@
resolved "https://registry.npmjs.org/@types/node/-/node-13.9.3.tgz"
integrity sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA==

"@types/[email protected].2":
version "15.12.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.2.tgz#1f2b42c4be7156ff4a6f914b2fb03d05fa84e38d"
integrity sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww==
"@types/[email protected].3":
version "15.12.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.3.tgz#2817bf5f25bc82f56579018c53f7d41b1830b1af"
integrity sha512-SNt65CPCXvGNDZ3bvk1TQ0Qxoe3y1RKH88+wZ2Uf05dduBCqqFQ76ADP9pbT+Cpvj60SkRppMCh2Zo8tDixqjQ==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -3169,10 +3169,10 @@ [email protected]:
resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

[email protected].0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.0.0.tgz#67ce848170cb6426f9e84c57e38376dc9017bab4"
integrity sha512-GRGG/q9bIaUkHJB9NL+KZNjDhMBHB30zW3bZW9qOiYr+QChyLjPzswaxFWkI1q6lGlSL28EQYzAi2vKWNkPx+g==
[email protected].1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.0.1.tgz#01e66b7af0012330c0a38c4b6eaa6d92b8a81bf9"
integrity sha512-9zwsavlRO+5csZu6iRtl3GHImAbhERoDsZwdRkdJ/bE+eVplmoxNKE901ZJ9LdSchYBjSCPbjKc5XvcAri2ylw==
dependencies:
"@ungap/promise-all-settled" "1.1.2"
ansi-colors "4.1.1"
Expand Down