นี่ไม่ใช่ความท้าทาย แต่เป็นคำถามที่ฉันคิดว่ามันเป็นหัวข้อเนื่องจาก
คำถามที่ไม่ท้าทายที่เกี่ยวข้องกับการแก้ปริศนาการเขียนโปรแกรมหรือความท้าทายบางประเภทนั้นอยู่ในหัวข้อด้วย
ตอนนี้คำถาม:
เป็นไปได้ไหมที่จะเขียนโค้ด JavaScript ด้วยตัวอักษรเพียง 5 ตัว? JSFuckทำสิ่งนี้ด้วยสัญลักษณ์ 6 อันแล้ว!+[]()
แต่ฉันสงสัยว่าต้องใช้!
ตัวละครนี้หรือไม่
JSFuck ทำงานร่วมกับการคัดเลือกนักแสดงเป็นสตริง (โดยการเพิ่มอาร์เรย์ที่ว่างเปล่า) การคัดเลือกนักแสดงไปยังหมายเลข (โดยการเขียนเครื่องหมาย + ด้านหน้า) และการคัดเลือกนักแสดงเพื่อบูลีนโดยปฏิเสธ ตัวอย่างเช่น:
[] \\ Empty array
+[] \\ Cast to number -> 0
!+[] \\ Negate -> true
!+[]+[] \\ Cast to string -> "true"
จากสตริงนี้เราสามารถแยกตัวอักษรทั้งหมดโดยใช้เครื่องหมายวงเล็บเหลี่ยมที่มีตัวเลขอยู่ข้างในและตัวเลขใด ๆ ที่สามารถทำได้โดยการเพิ่มจริงเข้าด้วยกันหลายครั้ง
เช่นนี้สามารถพบตัวอักษรจำนวนมากและสามารถต่อกับสตริงได้ สตริงที่สำคัญที่สุดที่สามารถสร้างได้คือ"constructor"
สามารถใช้เพื่อรับค่าFunction
จากฟังก์ชั่นใด ๆ และวัตถุนี้สามารถใช้ในการเรียกใช้สตริงเป็น JavaScript:
[]["find"] \\ the function Array.prototype.find
[]["find"]["constructor"] \\ the Function object
[]["find"]["constructor"](string)() \\ same as eval(string)
อย่างที่คุณเห็น!
มี 2 ประโยชน์ที่นี่:
- การสร้างตัวเลขเพื่อเลือกตัวอักษรจากสตริง
- ส่งไปยังบูลที่จะได้รับและ
"true"
"false"
คนแรกของ 2 คนนี้สามารถทำได้โดยใช้ตัว++
เพิ่มไม่ใช่โดยตรง0
แต่มันสามารถใช้กับองค์ประกอบภายในอาเรย์:
+[] \\ 0
[+[]] \\ [0]
[+[]][+[]] \\ [0][0] -> 0
++[+[]][+[]] \\ ++[0][0]-> 1
++[[]][+[]] \\ also works because ++ casts to number
!
ดังนั้นตัวเลขทั้งหมดที่สามารถสร้างขึ้นได้โดยไม่ต้อง
อันที่สองนั้นยากกว่า ความสำคัญของการ"true"
และ"false"
วางในตัวอักษร"r"
และซึ่งทั้งสองปรากฏใน"s"
"constructor"
ผมได้พบแล้วทุกตัวอักษรอื่น ๆ"constructor"
โดยใช้วิธีการ"undefined"
, "Infinity"
, "NaN"
และฟังก์ชั่นโดยการหล่อสตริง
ดังนั้นคำถามสุดท้าย: (อย่างไร) คุณสามารถสร้างบูลีนหรือตัวอักษร"r"
และ"s"
ใน JavaScript โดยใช้เพียง+[]()
?
จดหมาย"l"
อาจช่วยได้ สามารถรับแบบฟอร์มได้null
แต่ฉันไม่สามารถรับค่านั้นได้ด้วยสัญลักษณ์ทั้งห้า ตัวอย่างเช่นสามารถใช้เพื่อรับ booleans ถ้าเรามี"s"
:
[]["includes"]() \\ false
[+[]]["includes"](+[]) \\ true
จดหมาย"l"
และ"k"
ร่วมกันจะให้การเข้าถึง"r"
:
([]+[])["link"]() \\ "<a href="undefined"></a>"
วิธีใดก็ตามที่จะได้รับบูลีนnull
หรือตัวอักษรใด ๆr s l k
จะมีประโยชน์มาก!
ห้องสมุดของสิ่งที่เรามี:
Array.prototype.find: [] [(([] [[]] + []) [(++ [[]] [+ []]) + + (++ [[]] [+ []] + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+] []) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] อินฟินิตี้: + ((++ [[]] [+ []] + []) + (([] [[]] + []) [[++] [+] [+] [+] [+] + [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ [])) NaN: + [] [[]] ไม่ได้กำหนด: [][[]] 0: + [] 1: ++ [[]] [+ []] 2: (++ [[]] [+ []]) + (++ [[]] [+ []] 3: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] 4: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] ] [+ []]) 5: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] ] [+ []]) + (++ [[]] [+ []]) 6: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 7: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 8: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 9: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ []] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) a: (+ [] [[]] + []) [++ [[]] [+ []] c: ([] [(([] [[]] + []) [(++ [[]] [+ []]) + + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] d: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]]]]] e: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []])] f: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []]) + (++ [[]] [+ []])] i: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] n: ([] [[]] + []) [++ [[]] [+ []] o: ([] [(([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+] []) + (++ [[]] [+ []])] t: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [] + + () [+] [+] [+] ++ [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [] ])] u: ([] [[]] + []) [+ []] v: ([] [(([] [[]] + []) [(++ [[]] [+ []])) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))] y: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [] + + (] [+] [+] [+] ++ [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [] ]) + (++ [[]] [+ []])] ฉัน: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) []) [(++ [[]] [+]] [+] [+] ++ [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [+ []] N: (+ [] [[]] + []) [+ []] "": ([] [(([] [[]] + []] +])) [(++ [[]] [+ []]) + (++ [[]] [+] [+] [+] [+] + [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [ ]) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ [] ] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []])))] (: ([] [(([] [[]] + []) [(++ [[]] [+ []])) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])))] ): ([] [(([] [[]] + []) [(++ [[]] [+ []]) + + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])))] {: ([] [(([] [[]] + []) [(++ [[]] [+ []])) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])))] }: ([] [(([] [[]] + []) [(++ [[]] [+ []]) + + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ ((++ [[]] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + [] + ((++ [[]] [+ []]) + ( ++ [[]] [+ []])))] .: (+ (++ [[]] [+ []] + [] + (++ [[]] [+ []]) + ([] [[]] + []] [[] [+] []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + (++ [[]] [+ [] ] + [] + (+ []) + (+ []))) + []) [++ [[]] [+ []]] :[[]] [([] [(([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [(++ [[]] [+] []) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ([] [(([] [] [] + []) [ (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []])]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[] ] + []) [++ [[]] [+ []]]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] )] + ([] [] [] + []) [++ [[]] [+ []]] + ([] [(([] [] [] + []) [(++ [[ ]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) ]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [] [] + []) [++ [[]] [+ []]]) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [ + []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + (+ [] [[]] + []) [++ [[]] [+ []]] + (+ ((++ [[]] [+ []] + []) + (([] [] [] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + ( ++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ [])) + []) [(++ [[]] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[ ]] [+ []]) + (++ [[]] [+ []])]] ([[]]) + []
eval
เมื่อปี 2453 window