Coder Social home page Coder Social logo

fasttime / jscrewit Goto Github PK

View Code? Open in Web Editor NEW
157.0 10.0 12.0 7.64 MB

Write any JavaScript with six characters: ! ( ) + [ ]

Home Page: https://jscrew.it

License: ISC License

JavaScript 82.79% HTML 0.76% Gherkin 0.91% Handlebars 0.53% TypeScript 15.02%
esoteric jsfuck obfuscation

jscrewit's People

Contributors

837951602 avatar aemkei avatar clayblockunova avatar fasttime avatar hawur avatar hazzik avatar mathiasbynens avatar subzey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jscrewit's Issues

FEATURES

Why are ['NODECONSTRUCTOR','IE_SRC'] not compatible?

Localized number in IE11 on Win7

Sorry for suggesting IE-exclusive features now.
AFAIK, IE11 on Win7 have some exclusive string related to Localised numbers. Such strings which would be useful for getting chars are listed below:

  • Arabic Infinity ("+لا نهاية");
  • Czech NaN ("Není číslo");
  • Modern Greek Infinity ("Άπειρο");
  • Modern Greek NaN ("μη αριθμός");
  • Japanese Infinity ("+∞");
  • Japanese NaN ("NaN (非数値)");
  • Russian Infinity ("бесконечность");
  • Simplified Chinese Infinity ("正无穷大");
  • Simplified Chinese NaN ("非数字").
    But, IDK will language of IE affect how "zh" is rendered in Number.prototype.toLocaleString(). It's hard to test since we might need help from someone in Hong Kong/Macau/Taiwan.

Something about `document.createElement()`

Currently, there is a definition of "V" relies on document.createElement() would be active with ANY_DOCUMENT and supposed to work in Android Webview 4.0-4.3, but MDN says document.createElement() was added in Android Webview 4.4. should we make an independent feature for document.createElement()?
Additionally, []+document.createElement(false) will return "[object HTMLUnknownElement]" in most browsers, which would be useful for leters "M" and "L". but IDK how document.createElement(false) work in Android Webview 4.0-4.3 and would that be useful for letter "U".

Extend usage of object "self" for letter "W"

Currently, (RP_3_WA + self)[11] only work as "W" when feature WINDOW available, i.e. outside web worker. if string representation of self in web worker is "[object WorkerGlobalScope]", you can add a new feature to make (RP_3_WA + self)[11] available as "W" in web worker. but, if string representation of self in web worker is "[object DedicatedWorkerGlobalScope]" etc., self may not be so useful for "W" in web worker.

some work on Arabic-Indic Numerals

if you use most valid Arabic variant as locale Parameters of Number.prototype.toLocaleString(), the output will be Arabic-Indic Numerals. usinglocale Parameters string for Arabic which have shorter code(the one with shortest generated code is all lower case version of Arabic(Saudi Arabia), ie. "ar-sa")can shorten generated code for single Arabic-Indic Numerals character. it works in new browsers and Node.JS 12+.
for example:
in all new browsers:
"١":2867 (current method)
(1).toLocaleString("ar-sa"):2764 (since converted via web, whether "String" optimized is unknown)
but converted length of code using Number.prototype.toLocaleString() is still longer than escape sequence it self(for"١", escaping sequence is "\u0661", which converted length is 1256 chars), so that method may not fit for strings escaped altogether.

Old jsfuck

There was time when [].filter is not defined, and jsfuck allowed 8 char types ! + ( ) [ ] { }.

  1. Can I slightly modify JScrewIt to make it use 8ct and allow old environments like IE7?
  2. Can I modify it so it allows 6ct as well as 8ct?

8ct Function == [][([]+![])[!![]+!![]+!![]]+({}+[])[+!![]]+([]+!![])[+!![]]+([]+!![])[+[]]][({}+{})[+!![]+!![]+[+[]]]+({}+{})[+!![]]+([][[]]+[])[+!![]]+([]+![])[!![]+!![]+!![]]+([]+!![])[+[]]+([]+!![])[+!![]]+([][[]]+[])[+[]]+({}+{})[+!![]+!![]+[+[]]]+([]+!![])[+[]]+({}+{})[+!![]]+([]+!![])[+!![]]]

Is there a decoder someone can use ?

I am a bit new to this , so forgive me if I sound like I dont understand this, I think the encoding is non-deterministic, for instance, there are multiple encodings that can be produced from a source String, does that make decoding impossible ?
Is there a decoder available somewhere ?

Better comment handling

Currently, only comments after short code with only one simple object (such as Boolean, number and string literal, one-element array or one-parameter functions) would be deleted, but otherwise code will be transformed with comment. I think the best way handling comments is unconditional deletion, but you can also create an option for toggling comments deletion just in case.

supplementary plane optimazation

currently, supplementary plane characters like emojis are escaped into 2 surrogate characters. But current JS have alternate methods to treat supplementary plane characters as single character, i.e. String.fromCodePoint(), decodeURI() (like unescape() but treat standard UTF8 better) and \u{XXXXXX}(alternate Escape sequence). when will those be supported?

potential optimization of 'L'

afaik, call Object.prototype.toString on object Location (which equals to window.location) in Edge will return "[object Location]", and Function("return ({}).toString.call(location)") only cost 5066 char in non-IE browser, and currently 'L' cost 6181 char in non-IE browser when web worker supported. since Location is web-worker-safe, definition of 'L' can be optimized with Location. But, Firefox and Safari not tested, so idk how practical it is.

Shorter encoding using toString

Let's say we encoding 'hhhhh'. I directly type 'hhhhh' and get 16679 chars. Even if I select 'All new browsers', 6014 chars are generated. However 1889567..toString(18) also be 'hhhhh' and it's length is 3532 chars(All env.) and 1611 chars(new browser),

Optimize some single char

for IE9
'\' 5120
([].filter.constructor('return/false/')().constructor('\n')+[])[1] 2438
([].filter.constructor('return/false/')().constructor([].filter)+[])[1] 2428
For some environment(e.g.Chrome*) it returns '\n', but for IE9 it's '\'

Characters in function

' ' in All env. turns into (+(+!![]+[+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]])+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+!![]]] where a simple NaN is encoded as (+(+!![]+[+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]])) (+'1NaN').
I temporary locally fixed it by changing defineFHCharAt('ANY_FUNCTION', 8), to define('(NaN + FILTER)[11]'), and get space to (+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+!![]]], but that just skip the problem

Batch `atob()` conversion

Currently, there is only 1 triplet has batch atob() definition: "mCh" == atob("bUNo"). But there are more triplets which batch atob() definition are practical:
"#!/" (common in URL hashbang grammar) currently costs 1989 chars, while atob("IyEv") only costs 1942 chars;
"{b:" (sometimes can be seen in object definitions) currently costs 1121 chars, while atob("e2I6") only costs 961 chars;
"www" (well-known part of domain name) currently costs 990 chars, while atob("d3d3") only costs 900 chars.
But batch atob() can go further since string segment made up by triplets mentioned before can be created by only one atob(), which is shorter by three-by-three conversion. additionally, some triplets are impractical with atob() as triplet, but their corresponding base64 string have code shorter than original triplet, hence can be combined into single atob() with suitable context. For example, "://" (common in URL header) currently costs 1311 chars, which base64 string "Oi8v" only costs 723 chars, but atob("Oi8v") costs 1544 chars.
Such usage of batch atob() conversion would be challenging since you need an algorithm to clip out most suitable segment form original string for batch atob() conversion.

Comma

  1. [Said]Array slice on the two(or more if the middle part has exactly 1 char) adjacent chars
  2. JScrewIt.encode('"0,00,0"',{features:['FILL','NO_IE_SRC']}).length = 766
    JScrewIt.encode('[0].concat(0)+[0].concat(0)',{features:['FILL','NO_IE_SRC']}).length = 763
  3. In output.txt 391 | 1 | FILL, IE_SRC but when I run in it's 394. [Update]Ok I know that's because WITHOUT +[] ITS 391

Dropping IE support

Microsoft officially stopped IE support in Feb 14 and trying to remove IE from Windows 11. When will you drop IE support?

Deno support

On server side, there is a new JS runtime: Deno. When will you have support of Deno?

Usage of `BigInt.prototype.toString()`

Currently, only Number.prototype.toString() is used in the optimizer, but it has a disadvantage: it would be limited by MAX_SAFE_INTEGER. BigInt.prototype.toString() is not affected by that. To get number in BigInt type, you can just call "return "+number written in string+"n" in Function().

optimization for fromCharCode usage

Currently, when fromCharCode or fromCodePoint is used, the whole string is converted into decimal codepoint even if the string begin or ended with simple characters (numbers, 'N','a','d','e','f','i','l','n','r','s','t','u'). Using "+" to attach those simple characters on head or end of string genetated by fromCharCode can shorten generated code.

eval&Function

alert(1) is [].filter.constructor('return alert')()(1)
/./ is [].filter.constructor('return eval')()('/./')
Why not [].filter.constructor('return/./')()?
({}) is [].filter.constructor('return eval')()('({})'),
not [].filter.constructor('return{}')()

Number encoding

There should only be XXXeYYY and (AAA)(.BBB) -- since point costs 72 chars far larger than '9' 47, it's never cheap to use both.
With x being a positive finite number, turning x to XXXeYYY style uses x.toExponential().replace(/^(\d)\.?(\d*)e(.*)$/,function(x,a,b,c){return a+b+'e'+(c-b.length)}) and to (AAA)(.BBB) use Number.prototype.forceFixed=function(){var t=this.toString().split('e');if(t.length==1)return t.replace(/^0/,'');t[0]=t[0].replace(/\./,'');return t[1]>0?t[0]+Array(2- -t[1]-t[0].length).join(0):'.'+Array(-t[1]).join('0')+t[0]}? (code not tested fully)

Minor platform support

Currently, the tool only have major browser (i.e. IE, Firefox, Chromium-based browsers, Safari and Android browser) and Node.JS support. Should we add support for minor and local browser (e.g. Konqueror, UC, Yandex) and non-browser JS engine (e.g. Nashorn, lv, IronJS) now?

'\xxx' not recognized

'\040' 28903 bytes as Function("return '\040'")() instead of directly describe char32(space)?

require not working

When I try to compile const test = require("test") and then I run it with NodeJS v8.1.2 (which uses V8 v5.8.283.41) I get

ReferenceError: require is not defined
    at eval (eval at <anonymous> (C:\Users\H\Desktop\game\dist\server\index.js:1
:2288), <anonymous>:2:14)
    at eval (<anonymous>)
    at Object.<anonymous> (C:\Users\H\Desktop\game\dist\server\index.js:1:2288)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)

When running it directly (without compilation) I don't get any errors.
I'm building with node and JScrewIt.Feature.AUTO

Have I done something wrong or is this actually a bug?

some question about "fromCharCo"

Currently, "fromCharCo" is defined as "from3har3o".split(3).join("C"). but I tried "from0har0o".split(0).join("C"), i's shorter and works will in Chromium. What did you think at that time?

Shorter general code generator?

[All Supported Env.]
'!!!!!' 26486
unescape(unescape("false2521false2521false2521false2521false2521".split(false).join("%"))) 22547
unescape("false21false21false21false21false21".split(false).join("%")) 17058, but with 'b' or 'c' escaped that'd be too long

(though I don't know what code generated by the present way

non-HTML-related JS support

currently, "browser usage" is treated as synonym of "HTML related usage". But, XML and SVG also support JS and can be opened by browsers too. Should we add support for XML and SVG?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.