Skip to content

Commit

Permalink
Update jsfuck.js
Browse files Browse the repository at this point in the history
JSFuck mod using "<" instead of "!".
  • Loading branch information
baboures authored Jul 15, 2021
1 parent 94c3835 commit 59d7032
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions jsfuck.js
Original file line number Original file line Diff line number Diff line change
@@ -1,24 +1,27 @@
/*! JSFuck 0.5.0 - http://jsfuck.com */ /*!
* JSFuckr v1.0 (mod by @baboures)
* Write any JavaScript with 6 Characters: ([+<])
*/


(function(self){ (function(self){
const MIN = 32, MAX = 126; const MIN = 32, MAX = 126;


const SIMPLE = { const SIMPLE = {
'false': '![]', 'false': '([]<[])',
'true': '!![]', 'true': '([]<[+[]])',
'undefined': '[][[]]', 'undefined': '[][[]]',
'NaN': '+[![]]', 'NaN': '+[[]<[]]',
'Infinity': '+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])' // +"1e1000" 'Infinity': '+([+([]<[+[]])]+(([]<[+[]])+[])[([]<[+[]])+([]<[+[]])+([]<[+[]])]+[+([]<[+[]])]+[+[]]+[+[]]+[+[]])' // +"1e1000"
}; };


const CONSTRUCTORS = { const CONSTRUCTORS = {
'Array': '[]', 'Array': '[]',
'Number': '(+[])', 'Number': '(+[])',
'String': '([]+[])', 'String': '([]+[])',
'Boolean': '(![])', 'Boolean': '([]<[])',
'Function': '[]["flat"]', 'Function': '[]["flat"]',
'RegExp': 'Function("return/"+false+"/")()', 'RegExp': 'Function("return/"+false+"/")()',
'Object': '[]["entries"]()' 'Object': '[]["entries"]()'
}; };


const MAPPING = { const MAPPING = {
Expand Down Expand Up @@ -87,10 +90,10 @@
'(': '([]["flat"]+"")[13]', '(': '([]["flat"]+"")[13]',
')': '([0]+false+[]["flat"])[20]', ')': '([0]+false+[]["flat"])[20]',
'*': null, '*': null,
'+': '(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[2]', '+': '(+([+([]<[+[]])]+(([]<[+[]])+[])[([]<[+[]])+([]<[+[]])+([]<[+[]])]+[+([]<[+[]])]+[+[]]+[+[]])+[])[2]', // (+"1e100"+[])[2]
',': '[[]]["concat"]([[]])+""', ',': '[[]]["concat"]([[]])+""',
'-': '(+(.+[0000001])+"")[2]', '-': '(+(.+[0000001])+"")[2]',
'.': '(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]', '.': '(+([+([]<[+[]])]+[+([]<[+[]])]+(([]<[+[]])+[])[([]<[+[]])+([]<[+[]])+([]<[+[]])]+[([]<[+[]])+([]<[+[]])]+[+[]])+[])[1]', // (+"11e20"+[])[1]
'/': '(false+[0])["italics"]()[10]', '/': '(false+[0])["italics"]()[10]',
':': '(RegExp()+"")[3]', ':': '(RegExp()+"")[3]',
';': '("")["fontcolor"](NaN+")[21]', ';': '("")["fontcolor"](NaN+")[21]',
Expand All @@ -113,16 +116,15 @@


const GLOBAL = 'Function("return this")()'; const GLOBAL = 'Function("return this")()';


/* fill digits of the range 0-9 in mapping */
function fillMissingDigits(){ function fillMissingDigits(){
var output, number, i; var output, number, i;

for (number = 0; number < 10; number++){ for (number = 0; number < 10; number++){


output = "+[]"; output = "";

if(number == 0){ output = "+[]" }
if (number > 0){ output = "+!" + output; } for (i = 0; i < number; i++){ output += "+([]<[+[]])"; }
for (i = 1; i < number; i++){ output = "+!+[]" + output; } if (number > 1){ output = output.substr(1); } // if number > 1, strip the first + sign (not needed): ([]<[+[]])+([]<[+[]]) == +([]<[+[]])+([]<[+[]]) == 2
if (number > 1){ output = output.substr(1); }


MAPPING[number] = "[" + output + "]"; MAPPING[number] = "[" + output + "]";
} }
Expand All @@ -138,17 +140,21 @@
); );
} }


/* replace numbers consisting of only 1 digit */
function digitReplacer(_,x) { return MAPPING[x]; } function digitReplacer(_,x) { return MAPPING[x]; }


/* replace numbers consisting of 2 or more digits */
function numberReplacer(_,y) { function numberReplacer(_,y) {
var values = y.split(""); var values = y.split(""); // get the digits
var head = +(values.shift()); var head = +(values.shift()); // get the leftmost digit and remove it from the array
var output = "+[]"; var output = "";


if (head > 0){ output = "+!" + output; } /* Optimization note: the first digit does not need to be enclosed between brackets: 1+[2] == [1]+[2] == "12" */
for (i = 1; i < head; i++){ output = "+!+[]" + output; } if(head == 0){ output = "+[]" }
if (head > 1){ output = output.substr(1); } for (i = 0; i < head; i++){ output += "+([]<[+[]])"; }
if (head > 1){ output = output.substr(1); } // if head > 1, strip the first + sign (not needed): ([]<[+[]])+([]<[+[]]) == +([]<[+[]])+([]<[+[]]) == 2


/* All the remaining digits need to be enclosed between brackets: 1+2+[3] == (1+2)+[3] == "33" != "123", but 1+[2]+[3] == "123" */
return [output].concat(values).join("+").replace(/(\d)/g, digitReplacer); return [output].concat(values).join("+").replace(/(\d)/g, digitReplacer);
} }


Expand Down Expand Up @@ -178,7 +184,7 @@
} }


function replaceStrings(){ function replaceStrings(){
var regEx = /[^\[\]\(\)\!\+]{1}/g, var regEx = /[^\[\]\(\)\<\+]{1}/g,
all, value, missing, all, value, missing,
count = MAX - MIN; count = MAX - MIN;


Expand Down Expand Up @@ -346,7 +352,7 @@
replaceMap(); replaceMap();
replaceStrings(); replaceStrings();


self.JSFuck = { self.JSFuckr = {
encode: encode encode: encode
}; };
})(typeof(exports) === "undefined" ? window : exports); })(typeof(exports) === "undefined" ? window : exports);

0 comments on commit 59d7032

Please sign in to comment.