Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jfogs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jfogs - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

88

lib/jfogs.js

@@ -8,16 +8,28 @@

* zswang (http://weibo.com/zswang)
* @version 0.0.10
* @date 2015-09-07
* @version 0.0.11
* @date 2015-10-12
*/
var esprima = require('esprima');
/**
* 对字符串进行 Unicode 编码
* 对字符串进行utf8编码
*
* @param {string} str 源字符串
* @return {string} 返回编码后的内容
* param {string} str 原始字符串
*/
function encodeUnicode(str) {
return String(str).replace(/[^\x09-\x7f\ufeff]/g, function (all) {
return '\\u' + (0x10000 + all.charCodeAt()).toString(16).substring(1);
});
function encodeUTF8(str) {
if (!str) {
return str;
}
return String(str).replace(
/[\u0080-\u07ff]/g,
function (c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xc0 | cc >> 6, 0x80 | cc & 0x3f);
}
).replace(
/[\u0800-\uffff]/g,
function (c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xe0 | cc >> 12, 0x80 | cc >> 6 & 0x3f, 0x80 | cc & 0x3f);
}
);
}

@@ -168,2 +180,16 @@ /**

case 'zero':
var existsUnicode = false;
expressions.every(function (item) {
if (/[\u0100-\uffff]/.test(item)) {
existsUnicode = true;
}
return !existsUnicode;
});
var t;
if (existsUnicode) {
t = parseInt('100000000', 2);
}
else {
t = parseInt('10000000', 2);
}
expressions = expressions.map(function (item) {

@@ -174,4 +200,7 @@ if (!(/^["]/.test(item)) || item.length <= 2) {

hasString = true;
var t = parseInt('10000000', 2);
return '"' + encodeUnicode(JSON.parse(item)).replace(/[^]/g, function (all) {
var value = JSON.parse(item);
if (existsUnicode) {
value = encodeUTF8(value);
}
return '"' + value.replace(/[^]/g, function (all) {
return (t + all.charCodeAt()).toString(2).substring(1).replace(/[^]/g, function (n) {

@@ -203,3 +232,10 @@ return {

rightToLeft: identFrom(guid++),
u202e: '"\u202e"'
u202e: '"\u202e"',
6: identFrom(guid++),
charCodeAt: identFrom(guid++),
'0x0f': identFrom(guid++),
'0x1f': identFrom(guid++),
'0x3f': identFrom(guid++),
regex3: identFrom(guid++),
regex4: identFrom(guid++),
};

@@ -217,3 +253,22 @@ names.push(params.rightToLeft);

names.push(params.regex2);
expressions.push('/.{7}/g');
if (existsUnicode) {
expressions.push('/.{8}/g');
names.push(params.regex3);
expressions.push('/[\\u00c0-\\u00df][\\u0080-\\u00bf]/g');
names.push(params.regex4);
expressions.push('/[\\u00e0-\\u00ef][\\u0080-\\u00bf][\\u0080-\\u00bf]/g');
names.push(params.charCodeAt);
expressions.push('"charCodeAt"');
names.push(params[6]);
expressions.push(6);
names.push(params['0x0f']);
expressions.push(0x1f);
names.push(params['0x1f']);
expressions.push(0x1f);
names.push(params['0x3f']);
expressions.push(0x3f);
}
else {
expressions.push('/.{7}/g');
}
names.push(params.String);

@@ -231,3 +286,8 @@ expressions.push('String');

expressions.push('parseInt');
decryption = format( "\nif (#{u202e} !== #{rightToLeft}) {\n return;\n}\nvar #{argv} = arguments;\nfor (var #{index} = 0; #{index} < #{len}; #{index}++) {\n if (typeof #{argv}[#{index}] !== #{string}) {\n continue;\n }\n #{argv}[#{index}] = #{argv}[#{index}][#{replace}](#{regex1},\n function (a) {\n return {\n '\\u200c': #{0},\n '\\u200d': #{1}\n }[a];\n }\n ).replace(#{regex2}, function (a) {\n return #{String}[#{fromCharCode}](#{parseInt}(a, #{2}));\n });\n}\n ", params);
if (existsUnicode) {
decryption = format( "\nif (#{u202e} !== #{rightToLeft}) {\n return;\n}\n\nvar #{argv} = arguments;\nfor (var #{index} = #{0}; #{index} < #{len}; #{index}++) {\n if (typeof #{argv}[#{index}] !== #{string}) {\n continue;\n }\n #{argv}[#{index}] = #{argv}[#{index}][#{replace}](#{regex1},\n function (a) {\n return {\n '\\u200c': #{0},\n '\\u200d': #{1}\n }[a];\n }\n )[#{replace}](#{regex2}, function (a) {\n return #{String}[#{fromCharCode}](#{parseInt}(a, #{2}));\n })[#{replace}](\n #{regex3},\n function(c) {\n var cc = (c[#{charCodeAt}](#{0}) & #{0x1f}) << #{6} | (c[#{charCodeAt}](#{1}) & #{0x3f});\n return #{String}[#{fromCharCode}](cc);\n }\n )[#{replace}](\n #{regex4},\n function(c) {\n var cc = (c[#{charCodeAt}](#{0}) & #{0x0f}) << #{6} * #{2} | (c[#{charCodeAt}](#{1}) & #{0x3f}) << #{6} | (c[#{charCodeAt}](2) & #{0x3f});\n return #{String}[#{fromCharCode}](cc);\n }\n );\n}\n ", params);
}
else {
decryption = format( "\nif (#{u202e} !== #{rightToLeft}) {\n return;\n}\n\nvar #{argv} = arguments;\nfor (var #{index} = #{0}; #{index} < #{len}; #{index}++) {\n if (typeof #{argv}[#{index}] !== #{string}) {\n continue;\n }\n #{argv}[#{index}] = #{argv}[#{index}][#{replace}](#{regex1},\n function (a) {\n return {\n '\\u200c': #{0},\n '\\u200d': #{1}\n }[a];\n }\n )[#{replace}](#{regex2}, function (a) {\n return #{String}[#{fromCharCode}](#{parseInt}(a, #{2}));\n });\n}\n ", params);
}
}

@@ -234,0 +294,0 @@ break;

2

package.json
{
"name": "jfogs",
"version": "0.0.10",
"version": "0.0.11",
"description": "Javascript code obfuscator",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc