Decomp me: Collaboratively decompile code in the browser
decomp.me
decomp.me
Most languages/compilers were quite reasonable to work with. Swift had some issues where the line number of the source statement mattered (it would be integrated into inline error reporting routines), and compiled Nim code was just really hard to read. The brutal one was Golang: the register allocator seems to depend on the ordering of the local symbol table, meaning that changing the name of a variable could end up changing which registers got used for completely unrelated variables.
In any case, it was an interesting exercise which demonstrated that full, 1:1 decompilation is really possible. I'm super happy to see a proper use-case for this approach implemented here!
With your favorite compiler, use whatever flag it offers to spit out assembly listings from its compilation process. On clang and gcc this is `-S`. Typically used like `gcc foo.c -S` and it'll produce a file `foo.S` which contains the assembly listings. Or use Compiler Explorer (aka "godbolt") https://godbolt.org/. Great resource, supports many languages and targets, has good highlighting of what code in the origin language became what assembly.
That last bit will help you gain an intuition for what code looks like when it gets converted into assembly language. This is helpful for going in the other direction, it lets you at least guess at something.
There are probably some books or other resources people can recommend, I just picked it up as I went but I'm also just a "dabbler" in the field. It's not my day job and I have no intentions of making it my day job so I've learned enough to accomplish my goals or satisfy my curiosity.
I was able to fix a 3rd party binary that was broken on our platform via dis-assembly and binary patching. Having the tools in the toolbox to do so allowed us to solve it rapidly when normally it'd take months to work with the vendor.
1. https://www.darpa.mil/program/assured-micropatching
2. https://www.iarpa.gov/newsroom/article/annotated-malicious-b...
3. https://www.darpa.mil/program/recovery-of-symbolic-mathemati...
Your example is a cool case though. Maybe someday for me :)