3 ms·
I saw a very cool security talk a few years ago about how you can use the browser to do all kinds of evil things (did you know that the Same Origin Policy does
by IgorPartola 13y ago
I saw a very cool security talk a few years ago about how you can use the browser to do all kinds of evil things (did you know that the Same Origin Policy does not prevent you from making the request, but just seeing the response? And even then, you can guess at what kind of response you got).
One of the great points in the talk was JS obfuscation. Now, there are many techniques for doing this, but I really like this one as it just looks cool. Since you can translate most functional JS into ASCII, you simply encode every character into a binary coding using spaces for 0 and tabs for 1. Then you write a very simple converter + put an eval() around it, and viola, you are running arbitrary code. To a casual observer it would look like you have delivered a mostly empty file, while in fact you are delivering perfectly valid JS. Not unbreakable, but certainly fun.
- nilliams 13y agoWas it Billy Hoffman's 'JavaScript the Evil Parts'? http://blip.tv/jsconf/billy-hoffman-javascript-the-evil-parts-3704053 http://blip.tv/jsconf/billy-hoffman-javascript-the-evil-part...
- IgorPartola 13y agoYes, that's the one.
- dzuc 13y agoI recently did this exact thing for Ruby: https://github.com/dzucconi/negative https://github.com/dzucconi/negative
- deleted 13y ago[deleted]
- frozenport 13y agoI am worried about the file size.
- IgorPartola 13y agoDon't worry about it? :) Realistically, how big is your exploit? 30KB? So it'll be 30*7 = 210 KB (JS is actually 7 bit ASCII). That's plenty of code to do something malicious. Nothing is preventing you from minifying the code before converting it to this whitespace encoding. I suppose you could make your encoding include other whitespace chars, like newlines, carriage returns, etc. Then you could use base 4 instead of base 2.
- tghw 13y agogzip and a file that contains sequences of only two different characters should compress pretty well.
- Yoshi- 13y agoIt is kinda irrelevant that the Same Origin Policy doesn't prevent requests since, you don't even need to use a javascript request, a simple image tag does the same