TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Write any javascript code with just these characters: ()[]{}+

289 点作者 alcuadrado将近 13 年前

23 条评论

dherman将近 13 年前
Arg, scooped! I was working on this <i>exact</i> same thing! :D<p>Since you've beat me to it, let me offer up a couple additional tricks you might want to use. If you want to make this completely independent of browser API's, you can eliminate the dependence on window.location (or atob/btoa as the sla.ckers.org poster did).<p>Trick #1 is to get the letter "S".<p>You can extract this from the source code of the String constructor, but you want to be careful to make this as portable as possible. The ES spec doesn't mandate much about the results of Function.prototype.toString, although it "suggests" that it should be in the form of a FunctionDeclaration. In practice you can count on it starting with [whitespace] "function" [whitespace] [function name]. So how to eliminate the whitespace?<p>For this, we can make use of JS's broken isNaN global function, which coerces its argument to a number before doing its test. It just so happens that whitespace coerces to NaN, whereas alphabetical characters coerce to 0. So isNaN is just the predicate we need to strip out the whitespace characters. So we can reliably get the string "S" from:<p>[].slice.call(String+"").filter(isNaN)[8]<p>Of course, to get isNaN you need the Function("return isNaN")() trick, and you know how the rest of the encoding works.<p>Trick #2 then lets you get any lowercase letter, in particular "p".<p>For this, we can make use of the fact that toString on a number allows you to pick a radix other than 2, 8, 10, or 16. Again, the ES spec doesn't <i>mandate</i> this, but in practice it's widely implemented, and the spec does say that if you implement it its behavior needs to be the proper generalization of the other radices. So we can get things like:<p>(25).toString(26) // "p"<p>(17).toString(18) // "h"<p>(22).toString(23) // "m"<p>and other hard-to-achieve letters.<p>But once you've got "p", you're home free with escape and unescape, as you said in your post.<p>Dave
评论 #4367706 未加载
评论 #4367786 未加载
评论 #4367221 未加载
评论 #4417467 未加载
评论 #4367472 未加载
评论 #4367707 未加载
CurtHagenlocher将近 13 年前
This is like a bizarro-world lambda calculus, complete with its own Church numerals.
dag11将近 13 年前
I made a little script to extract the original javascript from a script obfuscated with OP's tool (<a href="http://patriciopalladino.com/files/hieroglyphy/" rel="nofollow">http://patriciopalladino.com/files/hieroglyphy/</a>).<p>And because I felt it was appropriate, I created this extraction script <i>in</i> an obfuscated form!<p>Use this to extract obfuscated scripts: <a href="http://pastebin.com/raw.php?i=Q9TB4wEF" rel="nofollow">http://pastebin.com/raw.php?i=Q9TB4wEF</a><p>Just save your obfuscated script in a variable called "original" and then run my code. It'll return with the extracted script.<p>Oh, and it won't work on itself. That's because I didn't use the obfuscation tool to create it. I made it mostly by hand: <a href="http://pastebin.com/9LBWCSJs" rel="nofollow">http://pastebin.com/9LBWCSJs</a>
评论 #4369516 未加载
quarterto将近 13 年前
There are no words to describe how dirty this makes me feel.
apendleton将近 13 年前
This post title omits "!" which is also necessary.
评论 #4366611 未加载
stcredzero将近 13 年前
So, basically Javascript is just a superset of an esolang that contains itself.<p><a href="http://esolangs.org/wiki/Main_Page" rel="nofollow">http://esolangs.org/wiki/Main_Page</a><p>(Especially true if you're developing with a Javascript interpreter hosted in Javascript. Really, it's esolangs all the way down.)
maartenscholl将近 13 年前
If you like reducing programs to basic expressions you should read into SKI combinator calculus and the X combinator. Here is a paper that describes the construction of an efficient X combinator[1]. Reading the paper gave me insight in how simple yet powerful combinatory logic is.<p>[1]www.staff.science.uu.nl/~fokke101/article/combinat/combinat.ps
bgeron将近 13 年前
I evalled all pieces of Javascript of &#60;30 characters in Rhino, takes 1 minute on my laptop. 4219 possible values, after stripping out some really uninteresting stuff. Doesn't seem to contain anything interesting, unfortunately.<p><a href="http://pastebin.com/CM5ac6Xi" rel="nofollow">http://pastebin.com/CM5ac6Xi</a>
评论 #4368294 未加载
jerfelix将近 13 年前
Looks cool, but I couldn't make it work.<p>I went to <a href="http://patriciopalladino.com/files/hieroglyphy/" rel="nofollow">http://patriciopalladino.com/files/hieroglyphy/</a> and put in a script "alert(1);". This provided me with a script of about 8300 characters.<p>I created a web page to execute the script:<p><pre><code> &#60;body onload=" [][(![]+[])[!+[] ... &#60;/body&#62; </code></pre> Firebug reports:<p><pre><code> ReferenceError: Unescaee is not defined. </code></pre> Looks like it's having trouble picking up a "p".
评论 #4370621 未加载
spicyj将近 13 年前
The article lists [][+[]] for undefined; you can get away with just [][[]].
infinity将近 13 年前
Some of you may also enjoy aaencode by Yosuke Hasegawa:<p><a href="http://utf-8.jp/public/aaencode.html" rel="nofollow">http://utf-8.jp/public/aaencode.html</a><p>Encode any JavaScript program to Japanese style emoticons (^_^)<p>And of course jjencode:<p><a href="http://utf-8.jp/public/jjencode.html" rel="nofollow">http://utf-8.jp/public/jjencode.html</a><p>(hint: have a look at "palindrome")
评论 #4370100 未加载
mistercow将近 13 年前
Man, if you didn't care about performance or bandwidth, this would be a hell an of obfuscation technique.
评论 #4366801 未加载
评论 #4369814 未加载
评论 #4366764 未加载
评论 #4366826 未加载
评论 #4367120 未加载
ctdonath将近 13 年前
Cross this with John Horton Conway's notion of "Surreal Numbers" and you might be onto something.
alter8将近 13 年前
This guy did it with 6 characters by removing {}. But it lacks the detailed description available in this post.<p>EDIT: I didn't check properly. You only use {} for a minor detail.<p><a href="http://utf-8.jp/public/jsfuck.html" rel="nofollow">http://utf-8.jp/public/jsfuck.html</a>
评论 #4368572 未加载
skrebbel将近 13 年前
Could someone please enlighten me as to how this helps doing an XSS attack?
评论 #4370193 未加载
jared314将近 13 年前
I remember something like this a few years ago. They were using it for XSS. <a href="http://news.ycombinator.com/item?id=1153383" rel="nofollow">http://news.ycombinator.com/item?id=1153383</a>
rubyrescue将近 13 年前
this is very cool...let me know if you want a job at inaka (we're in BA and have other people in school working for us)
chris_wot将近 13 年前
I wonder how well gzip would compress this?
评论 #4369302 未加载
michokest将近 13 年前
Minor typo:<p>&#62; "[object Object]" with {}+[]<p>I believe it should be []+{}
bazookaBen将近 13 年前
i pasted the entire json library into the field and it just hung. Any tips?
bradsmithinc将近 13 年前
Witchcraft
Fando将近 13 年前
really cool
mynameishere将近 13 年前
Write any Windows application with just the following characters: 0 1
评论 #4367598 未加载