News for hackers. Stuff that matters.
Re:JSNice: Statistical renaming, type inference, and deobfus... by andybak on Tuesday November 15, 2016 @05:28AM (#12956949)
I'd like to know more about how it picks variable names. Running it on non-obfuscated code is amusing. It occasionally comes up with better names for my variables than the ones I had picked.
Re:JSNice: Statistical renaming, type inference, and deobfus... by unhammer on Tuesday November 15, 2016 @08:05AM (#12957619)
It has read lots of code before reading yours: http://www.srl.inf.ethz.ch/jsnice.php
Re:JSNice: Statistical renaming, type inference, and deobfus... by wereHamster on Tuesday November 15, 2016 @01:09PM (#12960514)
Arguably code with better names than the OP's code ;)
Re:JSNice: Statistical renaming, type inference, and deobfus... by slig on Tuesday November 15, 2016 @06:22AM (#12957167)
I tried to de-obfuscate some HTML5 games that I made and the result was bad, marginally better than some naive JS beautifiers.

Yes, we all know that it's pointless to obfuscate client side code, but this serves as a simple deterrent. I've had games copied/pasted on some Chinese website and this seems to avoid that.

I used this [0] to obfuscate, which is free and open-source. You can also try it online here [1] if you don't feel like installing the Node.js package just for playing with it.

disclosure: I built the web interface [1] to the obfuscator, which is also open source.

[0]: https://github.com/javascript-obfuscator/javascript-obfuscat... [1]: https://javascriptobfuscator.herokuapp.com/

Re:JSNice: Statistical renaming, type inference, and deobfus... by k__ on Tuesday November 15, 2016 @07:21AM (#12957416)
I always see ads from JScrambler, does this really work?
Re:JSNice: Statistical renaming, type inference, and deobfus... by slig on Tuesday November 15, 2016 @07:37AM (#12957475)
I used JScrambler before and I really liked. If you don't mind the monthly fee, I'd say go for it.

They do nice stuff, like hiding some of your strings, other literals and random predicates inside an encrypted string. This is decrypted and eval'd at runtime using the text of the decrypt function as a parameter i.e, you can't beautify it otherwise it stop working. The random predicates are merged within your code for instance: it appends a `&& somePredicateThatReturnsTrue(someOtherRandomValue)` to ifs conditions. It makes it really hard to figure out what is happening.

Re:JSNice: Statistical renaming, type inference, and deobfus... by dsp1234 on Tuesday November 15, 2016 @12:14PM (#12959987)
Just as a general thought, not specific to this product:

This is decrypted and eval'd at runtime

Most(all?) string-based obfuscators can be bypassed by simply replacing eval with a logging eval implementation.

  var oldEval = eval; eval = function(str){console.log(str);oldEval(str)};
A similar patch to the Function constructor can bypass the other easy dynamic code generation code path.

If at some point, a string needs to be evaluated as code, then it's possible to intercept that code and output it.

Re:JSNice: Statistical renaming, type inference, and deobfus... by slig on Tuesday November 15, 2016 @06:06PM (#12963142)
That didn't work on JScrambler. The function that does the decryption checks to see if the `eval` has been tampered. (IIRC it checks for a `prototype` property). And you can't modify the body of this function otherwise the decryption fails.
Re:JSNice: Statistical renaming, type inference, and deobfus... by visarga on Tuesday November 15, 2016 @01:02PM (#12960430)
So, all you need is to break a longer eval into multiple smaller ones, shuffle them and thus make it a chore to connect the evals back.
Re:JSNice: Statistical renaming, type inference, and deobfus... by r0ckcg on Wednesday November 16, 2016 @12:46PM (#12969403)
tried it, does not work I'm afraid...
Re:JSNice: Statistical renaming, type inference, and deobfus... by k__ on Tuesday November 15, 2016 @07:46AM (#12957529)
Ah, but they're SaaS, right?

So no webpack plugin, I guess :)

Re:JSNice: Statistical renaming, type inference, and deobfus... by slig on Tuesday November 15, 2016 @07:50AM (#12957542)
They're SaaS and I believe they do have a webpack plugin (I used their grunt plugin). The plugin will send your code to their servers and wait for it to come back.
Re:JSNice: Statistical renaming, type inference, and deobfus... by lomnakkus on Tuesday November 15, 2016 @03:14PM (#12961752)
Not sure what exactly they're promising wrt. the quality of obfuscation, but if it actually works "well enough" you'd imagine they should be happy for you to run an obfuscated version of their code[1] rather than shipping your JS to their servers. Hmm... :)

[1] I'm assuming it's written in JS. It might not, of course.

Re:JSNice: Statistical renaming, type inference, and deobfus... by r0ckcg on Tuesday November 15, 2016 @11:13AM (#12959254)
There's also an on-premises version, if you don't want to send your code elsewhere..but I guess it might need a bit of investment..
Re:JSNice: Statistical renaming, type inference, and deobfus... by k__ on Tuesday November 15, 2016 @08:21AM (#12957712)
oh lord... thanks for the infos :)
Re:JSNice: Statistical renaming, type inference, and deobfus... by jwarren on Tuesday November 15, 2016 @06:07AM (#12957111)
I'm a big fan of JSNice - it's easily the best JS beautifier I've used. It's twice saved my bacon, really helping to make sense of some horrible, buggy third-party code.
Re:JSNice: Statistical renaming, type inference, and deobfus... by kwhitefoot on Tuesday November 15, 2016 @06:26AM (#12957191)
It would be useful to have this for other languages. I'd love to have it for some of the VB.net and C# I have seen.
Re:JSNice: Statistical renaming, type inference, and deobfus... by z3t4 on Tuesday November 15, 2016 @07:05AM (#12957343)
It would be cool if they made an API that an editor could interact with.
Re:JSNice: Statistical renaming, type inference, and deobfus... by bflesch on Tuesday November 15, 2016 @05:04AM (#12956870)
I really like this. Is it using the flowtype notation?
Re:JSNice: Statistical renaming, type inference, and deobfus... by phpnode on Tuesday November 15, 2016 @05:37AM (#12956988)
Re:JSNice: Statistical renaming, type inference, and deobfus... by lennelpennel on Tuesday November 15, 2016 @06:26AM (#12957193)
They are probably using closure in the background, using the new type inference with the compiler, to collect the meta information.
Re:JSNice: Statistical renaming, type inference, and deobfus... by kevinoconnor7 on Tuesday November 15, 2016 @12:27PM (#12960111)
Yes, the paper JS Nice is based on calls out that they use the Closure Compiler as a backend: http://www.srl.inf.ethz.ch/papers/jsnice15.pdf
Re:JSNice: Statistical renaming, type inference, and deobfus... by sethx on Tuesday November 15, 2016 @06:43AM (#12957255)
Doesnt seem to work with ES6 and imports ? :(
Re:JSNice: Statistical renaming, type inference, and deobfus... by SparkyMcUnicorn on Tuesday November 15, 2016 @01:42PM (#12960913)
It doesn't work with much of ES6 at all