The effect of obfuscation is not what you expect. It seems like it moves the whole difficulty up, but it only moves up the floor. By doing so it tends to remove all the signals that would warn non-experts of security issues. Remove the obfuscation and then you have all the catastrophic security issues that have accumulated in there like treasures in an egyptian king's tomb https://zemnmez.medium.com/how-to-hack-the-uk-tax-system-i-g...
It's so good.
has a pretty good crack at obfuscator.io, too: https://closure-compiler.appspot.com/home#code%3D%252F%252F%...
That's the example from the site. "console.log('Hello world')" gets deobfuscated to "console[a(482)]("Hello World!");"
That does not look deobfuscated to me.
And, even if you don't, you can always call a(482)
You make data private by not giving it to people you don't trust, or by encrypting it and not giving the key to people you don't trust.
I've been using the Google Closure compiler for many years with advanced and every time I look at the code output I'm like "there's no way in a 100 years I would be able to de-obfuscate back to my own code to a great extent". But I don't specialize in reverse engineering, so I might be missing something big.
I guess ultra-shortening the names into a,b,c,d,e, etc makes it superficially hard to understand what's going on but I agree on your point about abstract logic.
We even made a few tweaks to the code so that you couldn't just reverse it back into JS
This is why a lot of us keep our tools private... an old tradition of the cracking scene going back decades to the 80s. Think of things like IDA/Hexrays and Ghidra, then realise the most prolific crackers had similar private tools they had written many years before those appeared.
How ironic, that you want to open up other peoples code but keep your own hidden.
Irony would be applying obfuscation or other DRM protection techniques to tools intended to de-obfuscate/reverse engineer which are then distributed/sold. This is fairly common in commercial reverse engineering solutions, although I don't think the irony of the cat and mouse game is lost on the authors in that case...
Also, why do you mind me doing that?
I think the problem with this thread is people think I am writing browser code, or code that is going to be shared on GitHub.
I am not.
Also I'm only half joking as I've indicated with the "/s" below.
Seems like the logical solution would be to restrict access to it then, rather than obfuscate it making it harder for yourself to maintain. But hey, you do you.
I also wouldn't obviously edit the obfuscated production code, so it wouldn't really be a problem.
Well thanks for chiming in about a completely unrelated topic from website javascript. My comment wasn't getting downvoted until your slapfight with oauea blew up.
"It does not depend on a browser, so you can even run it on Node.js."
Otherwise, all bets are off.
These applications run on the back end. Some of the API facing VMs have been attacked and so to be honest I've configured them so that if someone did get access to them, they wouldn't find much. Maybe just some API keys I can invalidate. Although I probably won't do it -- an obfuscator like this could be very handy here.
This is my recipe for minification:
1. Apply a convention where all class properties and methods have to end with a trailing underscore (it's trivial to make an Eslint rule to enforce it)
2. Use 2 minification tools in following order: Closure Compiler (simple optimizations mode), then Terser for best output.
3. Configure Terser mangle.properties.regex: /_$/
4. If it's a desktop app, use Bytenode for Node.js processes (cannot be used for the renderer)
I also consider creating a tool to mangle string literals if they match a pattern. I.e. all string literals in the code that end with __ would be mangled. The benefit is that all internal event names and what not will not be visible.
Yep, it's not going to hide it completely, but it's just that much harder to RE and understand when there is pretty much nothing descriptive in plain English left in the code (except error messages and third party libraries).
Also I had this idea a few years earlier in a previous application where I did not use a module bundler. It was good old ES5 with files merged with Gulp and using prototype pattern. For those who do not know, prototype pattern is essentially like a class, but it's properties and methods do not have to be enclosed in one block. I did not implement it, but theoretically, it would be possible to create a mixer that would take all these prototype classes and their properties and create an output where all properties and methods from all classes would be output in a completely random order, all mixed together. Though looking back, it's probably not such a bright idea, as it would be possible to create an AST program that would reorder the methods back in place.
eJztVUESwyAIfAs3GJ60w/+/UZKiUUwzztT20OZiwgIbWJXAwARTmMAX02qRr0o9Vu02xRmwgKUPTzHv0weu8bGtZFhKyKSnTK0Z/parAJ/VI5WyXp7Uo/HYNc3qNchzKWBACnpCK3uj3N1Quvs6qCSJ4Gvah+++VT9/q3AlWLH5Pg3/cRqO94lR5SM5T6rDKSelDOUKC0+EzQ36l5N/zR7lDqti9Xjsj3U71f4AduQBlR9rUg==
https://enkhee-osiris.github.io/Decoder-JSFuck/> We even made a few tweaks to the code so that you couldn't just reverse it back into JS with something like https://enkhee-osiris.github.io/Decoder-JSFuck/.
We wanted to obfuscate this bit of code, to make life just a little bit harder for reverse engineers. We made this huge function where we pretty much passed in all our application state, and it would run this JSFuck code, and spit out a token. We even made a few tweaks to the code so that you couldn't just reverse it back into JS with something like https://enkhee-osiris.github.io/Decoder-JSFuck/.
Performance was surprisingly alright, and it has never hit an environment where it couldn't execute. All in all, a fun few hours setting it up, and I haven't had to touch it since!