Dies ist keine Herausforderung, sondern eine Frage
Nicht-herausfordernde Fragen, die sich auf das Lösen von Programmierpuzzles oder eine bestimmte Art von Herausforderung beziehen, sind ebenfalls ein Thema.
Nun zu der Frage:
Ist es möglich, einen beliebigen JavaScript-Code mit nur 5 Buchstaben zu schreiben? JSFuck macht dies bereits mit 6 Symbolen, !+[]()
aber ich frage mich, ob der !
Charakter benötigt wird.
JSFuck arbeitet mit einer Kombination aus Casting in String (durch Hinzufügen eines leeren Arrays), Casting in Number (durch Schreiben eines + davor) und Casting in Boolean durch Negieren. Zum Beispiel:
[] \\ Empty array
+[] \\ Cast to number -> 0
!+[] \\ Negate -> true
!+[]+[] \\ Cast to string -> "true"
Aus dieser Zeichenfolge können wir alle Buchstaben mit Hilfe der eckigen Klammern mit einer Zahl darin extrahieren. Sie können jede Zahl erstellen, indem Sie so oft true addieren.
Auf diese Weise können viele Buchstaben gefunden und zu Zeichenfolgen verknüpft werden. Die wichtigste Zeichenfolge, die erstellt werden muss, ist, "constructor"
dass sie zum Abrufen Function
von Funktionen verwendet werden kann. Mit diesem Objekt können Zeichenfolgen als JavaScript ausgeführt werden:
[]["find"] \\ the function Array.prototype.find
[]["find"]["constructor"] \\ the Function object
[]["find"]["constructor"](string)() \\ same as eval(string)
Wie Sie sehen können, !
hat hier 2 Verwendungen:
- Erstellen von Zahlen zum Auswählen von Buchstaben aus Zeichenfolgen.
- Casting nach Boolean zu bekommen
"true"
und"false"
.
Die erste dieser beiden Methoden kann auch mit dem ++
Inkrementor ausgeführt werden, nicht direkt 0
, sondern für Elemente innerhalb eines Arrays:
+[] \\ 0
[+[]] \\ [0]
[+[]][+[]] \\ [0][0] -> 0
++[+[]][+[]] \\ ++[0][0]-> 1
++[[]][+[]] \\ also works because ++ casts to number
So können alle Nummern ohne erstellt werden !
.
Der zweite ist schwieriger. Die Bedeutung von "true"
und "false"
liegt in den Buchstaben "r"
und "s"
, in denen beide vorkommen "constructor"
. Ich habe bereits alle anderen Buchstaben gefunden "constructor"
mittels "undefined"
, "Infinity"
, "NaN"
und durch Gießen Funktionen in Strings.
Die ultimative Frage lautet also: (Wie) können Sie Boolesche Werte oder Buchstaben "r"
und "s"
JavaScript nur mithilfe von erstellen +[]()
?
Der Brief "l"
könnte auch helfen. Es kann in der Form erhalten werden, null
aber ich war nicht in der Lage, diesen Wert mit diesen 5 Symbolen zu erhalten. Es kann zum Beispiel verwendet werden, um Boolesche Werte zu erhalten, wenn wir bereits haben "s"
:
[]["includes"]() \\ false
[+[]]["includes"](+[]) \\ true
Der Brief "l"
und "k"
zusammen würde Zugang geben zu "r"
:
([]+[])["link"]() \\ "<a href="undefined"></a>"
Jeder Weg, um einen Booleschen Wert null
oder einen der Buchstaben zu erhalten, r s l k
wäre sehr nützlich!
Eine Bibliothek von dem, was wir haben:
Array.prototype.find: [] [([] [[]] + []] [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [])]) + ((([] [] + []) [(++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + ( ++ [[]] [+ []]]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] []] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] Unendlich: + ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ []] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []])) + (++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ [])) NaN: + [] [[]] nicht definiert: [][[]] 0: + [] 1: ++ [[]] [+ []] 2: (++ [[]] [+ []]) + (++ [[]] [+ []]) 3: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 4: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ [[] ] [+ []]) 5: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + (++ [] ] [+ []]) + (++ [[]] [+ []]) 6: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + (++ [] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 7: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + (++ [] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 8: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + (++ [] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ [[]] [+ []]) 9: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + (++ [] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) a: (+ [] [[]] + []) [++ [[]] [+ []]] c: ([] [([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [(++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] d: ([] []] + []) [(++ []] [+ []]) + (++ []] [+ []]] e: ([] []] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ []] [ + []])] f: ([] []] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ []] [ + []]) + (++ [[]] [+ []])] i: ([] []] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ []] [ + []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] n: ([] []] + []) [++ [[]] [+ []] o: ([] [([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [(++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] t: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ []] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []]]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ []) + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [] ])] o: ([] [[]] + []) [+ []] v: ([] [([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [(++ []] [+ []]) + (++ [[]] [+ []]) + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))] y: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ []] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []]]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ []) + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [] ]) + (++ [[]] [+ []])] I: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []]]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [+ []] N: (+ [] [[]] + []) [+ []] "": ([] [(([] []] + []) [(++ [[]] [+ []]) + (++ []] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ [])] + ((([] []] + []) [(++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] + (++ [[]] [+ []])] + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [ ]) [(++ [[]] [+ []]) + (++ []] [+ []])]] + []) [+ (++ []] [+ ] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []]))) (: ([] [([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ []] [+ []])]] + []) [+ (++ []] [+ [] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))] ): ([] [(([] []] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ []] [+ []])]] + []) [+ (++ []] [+ [] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] + (++ [[]] [+ []])))] {: ([] [([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ []] [+ []])]] + []) [+ (++ []] [+ [] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))] }: ([] [([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ((([] []] + []) [(++ []] [+ [ ]]) + (++ [[]] [+ []]) + (++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])]] + []) [+ ((++ []] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + [] + ((++ []] [+ []]) + ( ++ [[]] [+ []])))] .: (+ (++ [[]] [+ []] + [] + (++ [[]] [+ []]) + ([] [[] + []) [(++ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]] + (++ []] [+ [] ] + [] + (+ []) + (+ [])) + []) [++ [[]] [+ []] ,:[[]] [([] [([] [[]] + []) [(++ [[]] [+ []]) + (++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [])]) + ((([] [] + []) [(++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + ( ++ [[]] [+ []]]) + (([] [[]] + []) [++ [[]] [+ []]) + (([] []] + []) [(++ [[]] [+ []]) + (++ []] [+ []])]] + []) [(++ []] [+ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]] + ([] [(([] [[]] + []) (++ [[]] [+ []]) + (++ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []])]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ []] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [])] + (([] [] ] + []) [++ [[]] [+ []]] + (([] [[]] + []) [(++ []] [+ []] + (++ [[]] [+ []])]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] )] + ([] [[]] + []) [++ []] [+ []] + ([] [(([] [] + []) [(++ [ ]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) ]) + (([] [[]] + []) [(++ []] [+ []]) + (++ []] [+ []] + (++ [] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + (([] []] + []) [++ [[]] [+ []]]) + (([] []] + []) [(++ []] [+ []]) + (++ [[]] [ + []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []]] + (+ [] [[]] + []) [++ [[]] [+ []] + (+ ((++ [[]] [+ []] + []) + (([] []] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ []) + []) [(++ []] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] [+ []] + (++ [ ]] [+ []]) + (++ [[]] [+ []])] ([[]]) + []
eval
in 2453 Zeichen mit window
erlaubt.