-
Notifications
You must be signed in to change notification settings - Fork 8
/
obfuscator.js
159 lines (157 loc) · 5.08 KB
/
obfuscator.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright 2018-2022 BadAimWeeb. All rights reserved. MIT license.
/**
* Obfuscate a string.
*
* @param {string} data A string that you want to obfuscate.
*
* @return {string} An obfuscated string.
*/
module.exports = function obf(data) {
function Obfuscator(repl) {
this.nrepl = 0;
this.replacements = {};
this.revreplacements = {};
function removeDupes(str) {
var rv = "";
for (var i = 0; i < str.length; i++) {
var ch = str.charAt(i);
if (rv.indexOf(ch) == -1) {
rv += ch;
}
}
return rv;
}
for (var i = 0; i < repl.length; i++) {
var r = repl[i];
var original = r.charAt(0);
var s = removeDupes(r);
if (s.length > 1) {
for (var j = 0; j < s.length; j++) {
this.replacements[s.charAt(j)] = s.substring(0, j) + s.substring(j + 1);
if (s.charAt(j) !== original) {
this.revreplacements[s.charAt(j)] = original;
}
this.nrepl++;
}
}
}
}
Obfuscator.prototype.obfuscate = function (str) {
str = str + "";
var rv = "";
for (var i = 0; i < str.length; i++) {
var c = str.charAt(i);
var r = this.replacements[c];
if (r) {
var j = Math.floor(Math.random() * (r.length - 1));
rv += r.charAt(r.charAt(j) == c ? j + 1 : j);
} else {
rv += c;
}
}
return rv;
};
Obfuscator.prototype.deobfuscate = function (str) {
str = str + "";
var rv = "";
for (var i = 0; i < str.length; i++) {
var c = str.charAt(i);
var r = this.revreplacements[c];
if (r) {
rv += r;
} else {
rv += c;
}
}
return rv;
};
var strongObfuscator = new Obfuscator([
"AÀÁÂÃÄÅĀĂĄǍǞǠȀȂȦΆΑАѦӐӒḀẠẢẤẦẨẬẶἈἉᾈᾉᾸᾹᾺᾼ₳ÅȺẮẰẲẴἌἎἏᾌΆǺẪ",
"BƁΒВḂḄḆ",
"CÇĆĈĊČƇʗСҪḈ₢₵ℂⅭϹϾҀ",
"DÐĎĐƉƊḊḌḎḐḒⅮ",
"EÈÉÊËĒĔĖĘĚȄȆȨΕЀЁЕӖḘḚḜẸẺẼẾỀỆḔḖỂỄԐℇƐἙῈЄ",
"FϜḞ₣ҒƑϝғҒ₣",
"GĜĞĠĢƓǤǦǴḠ₲",
"HĤĦȞΗНҢҤӇӉḢḤḦḨḪῌꜦ",
"IΊÌÍÎÏĨĪĬĮİƖƗǏȈȊΙΪІЇӀӏḬḮỈỊἸἹῘῙῚǐ1",
"JĴʆЈʃ",
"KĶƘǨΚЌКԞḰḲḴ₭K",
"LĹĻĽĿŁԼḶḸḺḼℒⅬ˪",
"MΜМӍḾṀṂⅯ",
"NÑŃŅŇǸΝṄṆṈṊ₦Ɲ",
"O0θϑ⍬ÒÓÔÕÖØŌŎŐƆƟƠǑǪǬǾȌȎȪȬȮȰΘΟϴОѲӦӨӪՕỌỎỐỒỔỘỚỜỞỠỢΌΌṌṐṒὈʘṎỖ",
"PƤΡРҎṔṖῬ₱ℙ",
"QԚℚ",
"RŔŖŘȐȒṘṚṜṞ℞ɌⱤ",
"SŚŜŞŠȘЅՏṠṢṨṤṦ",
"TŢŤŦƮȚΤТҬṪṬṮṰ₮ȾΊΊꚌ",
"UÙÚÛÜŨŪŬŮŰŲƯǓǕǗǛȔȖԱՍṲṴṶṸỤỦỨỪỬỮỰǙ⊍⊎Մ⊌Ṻ",
"VѴѶṼṾ⋁ⅤƲ",
"WŴԜẀẂẄẆẈ₩ƜШ",
"XΧХҲẊẌⅩ",
"Y¥ÝŶŸƳȲΥΫϓУҮҰẎỲỴỶỸῨῩ",
"ZŹŻŽƵȤΖẐẒẔ",
"aàáâãäåāăąǎǟǡǻȁȃȧаӑӓḁẚạảấầẩẫậắằẳẵặɑάαἀἁἂἃἄἅἆἇὰάᾀᾁᾂᾃᾄᾅᾆᾇᾰᾱᾲᾳᾴᾶᾷ⍶⍺ɑ",
"bƀƃƅɒɓḃḅḇþϸƄьҍ",
"cçćĉċčƈςϛсҫḉⅽ¢ϲҁ",
"dďđɖɗḋḍḏḑḓⅾƌժ₫ð",
"eèéêëēĕėęěȅȇȩеѐёҽҿӗḕḗḙḛḝẹẻẽếềểễệεɛϵєϱѳөӫɵ",
"fſḟẛƒғϝ£ƒ",
"gĝğġģǥǧǵɠɡգզցḡɕʛɢ",
"hĥħȟɦɧћիհḣḥḧḩḫẖℏһʜӊ",
"iį¡ìíîïĩīĭįıǐȉȋɨɩΐίιϊіїɪḭḯỉịἰἱἲἳὶίῑΐῐῒῖὶ",
"jĵǰȷɟʝјյϳ",
"kķĸƙǩκкҝҟḱḳḵ",
"lŀĺļľłƚǀɫɬɭḷḹḻḽŀ⎩ḹ",
"mɱḿṁṃ₥ⅿ",
"nɴñńņňʼnŋƞǹɲɳήηπпբդըղոռրṅṇṉṋἠἡἢἣἤἥἦἧὴήᾐᾑᾒᾓᾔᾕᾖᾗῂῃῄῆῇი",
"oòóôõöōŏőơǒǫǭȍȏȫȭȯȱʘοόоӧծձօṍṏṑṓọỏốồổỗộớờởỡợὀὁὂὃὄὅὸόσ๐",
"pþρрҏթṕṗῤῥ⍴",
"qʠԛգզϙ",
"rŕŗřȑȓɼɽгѓґӷṙṛṝṟгѓґӷ",
"sśŝşšșʂѕԑṡṣṥṧṩ",
"tţťŧƫțʈṫṭṯṱẗȶէե†ԷՒէȽҭ",
"uµùúûüũūŭůűųưǔǖǘǚǜȕȗɥμυцկմնսվևṳṵṷṹṻụủứừửữự",
"vʋνѵѷүұṽṿⅴ∨ΰϋύὐὑὒὓὔὕὖὗὺύῠῡῢΰῦῧʋ",
"wŵԝẁẃẅẇẉẘ",
"xϰхҳẋẍⅹ",
"yýÿŷƴȳγуўӯӱӳẏẙỳỵỷỹʏ",
"zźżžƶȥʐʑẑẓẕ",
"2ƻƨշ",
"3ЗҘӞƷӠЗҘӞՅɜɝзҙӟ",
"4ЧЧӴ",
"5Ƽ",
"6əǝә",
"8Ց",
// ☌øǿ - ???
"БƂ",
"ГΓЃҐӶ",
"ЖҖӜ",
"ИЍӢӤ",
"ЙҊ",
"ЛӅԒΛ",
"ПΠ",
"ЦҴ",
"ЬƄ",
"ЫӸ",
"ЪѢՒ",
"ЭӬ",
"вʙʙɞ",
"жҗӂӝ",
"зƨɜɝӟ",
"иѝӥ",
"йҋӣ",
"кĸκќқҝҟҡԟ",
"лӆԓ",
"мӎ",
"нʜңҥӈӊ",
"цџҵ",
"чҷҹӌӵ",
"шɯա",
"ъѣ",
"ыӹ",
"эǝɘəӭэӭ"
]);
return strongObfuscator.obfuscate(data) || "";
}